<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Kdeprint on Roberto Selbach</title><link>https://rselbach.com/tags/kdeprint/</link><description>Recent content in Kdeprint on Roberto Selbach</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 11 Aug 2002 16:49:12 +0000</lastBuildDate><atom:link href="https://rselbach.com/tags/kdeprint/index.xml" rel="self" type="application/rss+xml"/><item><title>KDEPrint and CUPS: Where the Options Go</title><link>https://rselbach.com/kdeprint-and-cups-where-the-options-go/</link><pubDate>Sun, 11 Aug 2002 16:49:12 +0000</pubDate><guid>https://rselbach.com/kdeprint-and-cups-where-the-options-go/</guid><description>&lt;p&gt;I was chasing a printing bug because the application appeared to ignore duplex selection. The drawing code was innocent. The useful clue was that printing to a PostScript file worked while the CUPS queue did not apply the requested option.&lt;/p&gt;
&lt;p&gt;KDEPrint sits between the application and the print system. The application paints pages through Qt&amp;rsquo;s printer interface, KDEPrint presents the common and driver-specific choices, and the selected backend submits the resulting job. With CUPS, queue capabilities and options come from CUPS rather than being invented by every application.&lt;/p&gt;
&lt;p&gt;For an application, the core remains ordinary painting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-cpp" data-lang="cpp"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;KPrinter printer;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (printer.setup(&lt;span style="color:#66d9ef"&gt;this&lt;/span&gt;)) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; QPainter &lt;span style="color:#a6e22e"&gt;painter&lt;/span&gt;(&lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;printer);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; painter.drawText(&lt;span style="color:#ae81ff"&gt;72&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;72&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;Printer test&amp;#34;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; painter.end();
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The setup dialog gathers destination, page range, copies, and available properties. &lt;code&gt;KPrinter&lt;/code&gt; then carries those choices into the KDEPrint path. The application&amp;rsquo;s responsibility is to paginate correctly and draw each requested page. It should not run &lt;code&gt;lpr&lt;/code&gt; itself and then wonder why the desktop&amp;rsquo;s settings vanished.&lt;/p&gt;
&lt;p&gt;When options misbehave, I now separate the stages. First I print to a file and inspect whether the PostScript pages are sane. Next I check the queue and its advertised defaults:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;lpstat -p -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;lpoptions -p office -l
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then I submit a small known document directly with &lt;code&gt;lp&lt;/code&gt; to see whether CUPS and the printer agree without the application involved. This distinguishes a rendering defect from a queue, PPD, filter, or device problem.&lt;/p&gt;
&lt;p&gt;Driver-specific settings deserve some humility. Duplex names, available resolutions, and media trays are described by the printer&amp;rsquo;s PPD and may differ across queues. Hard-coding one printer&amp;rsquo;s option into application code is therefore both fragile and impolite. KDEPrint already has the unenviable job of asking the printer what it thinks it can do.&lt;/p&gt;
&lt;p&gt;Page ranges require coordination with the application. If the print dialog says pages 3 through 5, my painting loop must honor the values reported by the printer object and call &lt;code&gt;newPage()&lt;/code&gt; between pages. I test one page, a middle range, reverse order when offered, and several copies. These cases expose off-by-one errors that a ten-page full print politely hides under ten sheets of paper.&lt;/p&gt;
&lt;p&gt;I also end the painter explicitly before inspecting the job. That completes PostScript generation and lets the backend submit a finished stream. Error reporting after setup deserves attention; cancellation from the dialog is not the same event as a backend rejecting a job.&lt;/p&gt;
&lt;p&gt;I prefer letting KDEPrint expose those details and keeping application settings limited to document matters. The caveat is that a successful job submission only means the print system accepted responsibility. It does not mean paper will emerge. Printers retain a small but determined independence from software engineering.&lt;/p&gt;</description></item></channel></rss>