<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BenV&#039;s notes &#187; printing</title>
	<atom:link href="http://notes.benv.junerules.com/tag/printing/feed/" rel="self" type="application/rss+xml" />
	<link>http://notes.benv.junerules.com</link>
	<description>Rants and notes</description>
	<lastBuildDate>Wed, 28 Jul 2010 13:36:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>CMSMadeSimple</title>
		<link>http://notes.benv.junerules.com/all/software/cmsmadesimple/</link>
		<comments>http://notes.benv.junerules.com/all/software/cmsmadesimple/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 10:49:40 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[cmsmadesimple]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[printing]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=831</guid>
		<description><![CDATA[One of our customers has a website with some custom-made CMS made in php. The customer asked us to fix some things, but since I hate touching pleuris-hoeren-product code, especially when the original coder is prutser and has never heard of templates (which is really weird, considering this is a CMS&#8230; maybe it&#8217;s just lazyness&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>One of our customers has a website with some custom-made CMS made in php.<br />
The customer asked us to fix some things, but since I hate touching pleuris-hoeren-product code, especially when the original coder is prutser and has never heard of templates (which is really weird, considering this is a CMS&#8230; maybe it&#8217;s just lazyness&#8230; then again, the <code class="codecolorer text vibrant"><span class="text">echo &quot;&lt;html&gt;blabla\&quot;escaping\&quot;quotes\&quot;is\&quot;so\&quot;much\&quot;fun\n\n\n50 more lines here&quot;;</span></code> style really doesn&#8217;t show much intelligence&#8230;)</p>
<p>Anyway, I figured I might as well move the entire thing to an open CMS project that I&#8217;ve heard some good things about and already implements everything and more that the customer could ever want. That&#8217;s <a href="http://www.cmsmadesimple.org/">CmsMadeSimple</a>.</p>
<p>Converting the old website to the new one was trivially easy. Copy/paste the stylesheet (first mistake), edit the basic template with a menu section, create the pages (copy/paste, copy/paste).<br />
After fixing the html errors that were in the source the page looked like a pixel-perfect copy of the original.<br />
Except for the places where the HTML errors were fixed that is. (the center class now actually worked for instance)</p>
<p>However, when adding the print links I ran into an interesting issue.<br />
Adding print links is also a trivial thing, simply put <code class="codecolorer text vibrant"><span class="text">{print}</span></code> somewhere in the template, and possibly add some options to show an image instead of a text link etc.<br />
However, the links were kinda broken, they gave empty pages. So I figured &#8220;duh, the print template still needs to be fixed&#8221;. However, as soon as I added the <code class="codecolorer text vibrant"><span class="text">{content}</span></code> tag to the template, I got a nice internal server error. WTF.</p>
<p>Checking the logs I could only find nice reports of this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2530</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: segfault at bf04b3f0 ip 08348d32 sp bf04b3f4 error <span style="color: #000000;">6</span> <span style="color: #000000; font-weight: bold;">in</span> php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8048000</span>+6e9000<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2564</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: segfault at bf639750 ip 08348d32 sp bf639754 error <span style="color: #000000;">6</span> <span style="color: #000000; font-weight: bold;">in</span> php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8048000</span>+6e9000<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2804</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: segfault at bf200230 ip 08348d32 sp bf200234 error <span style="color: #000000;">6</span> <span style="color: #000000; font-weight: bold;">in</span> php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8048000</span>+6e9000<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2896</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: segfault at bf00cbb0 ip 08348d32 sp bf00cbb4 error <span style="color: #000000;">6</span> <span style="color: #000000; font-weight: bold;">in</span> php-cgi<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">8048000</span>+6e9000<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<p>Well&#8230; .I expect nothing less from php. Pleuris-hoere-product. But how the heck&#8230; just because I added content to the print page? What&#8217;s so special about that?</p>
<p>After digging around (enabling logs etc) and enabling <span style="color:#FF00FF">fopen</span> for php (which I had disabled for security), I noticed this:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">&#91;</span>Wed Jul <span style="color: #000000;">14</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">22</span>:<span style="color: #000000;">29</span> <span style="color: #000000;">2010</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>error<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>client 123.611.204.37<span style="color: #7a0874; font-weight: bold;">&#93;</span> PHP Warning: &nbsp;file_get_contents<span style="color: #7a0874; font-weight: bold;">&#40;</span>http:<span style="color: #000000; font-weight: bold;">//</span>some-site<span style="color: #000000; font-weight: bold;">/</span>oncmsmadesimple<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">'function.file-get-contents'</span><span style="color: #000000; font-weight: bold;">&gt;</span>function.file-get-contents<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>: failed to open stream: HTTP request failed<span style="color: #000000; font-weight: bold;">!</span> HTTP<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span> <span style="color: #000000;">401</span> Authorization Required\r, referer: http:<span style="color: #000000; font-weight: bold;">//</span>some-site<span style="color: #000000; font-weight: bold;">/</span>oncmsmadesimple<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>Wed Jul <span style="color: #000000;">14</span> <span style="color: #000000;">12</span>:<span style="color: #000000;">22</span>:<span style="color: #000000;">29</span> <span style="color: #000000;">2010</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>error<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>client 123.611.204.37<span style="color: #7a0874; font-weight: bold;">&#93;</span> &nbsp;<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>vhosts<span style="color: #000000; font-weight: bold;">/</span>some-site<span style="color: #000000; font-weight: bold;">/</span>cmsmadesimple<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Printing<span style="color: #000000; font-weight: bold;">/</span>Printing.module.php on line <span style="color: #000000;">96</span>, referer: http:<span style="color: #000000; font-weight: bold;">//</span>some-site<span style="color: #000000; font-weight: bold;">/</span>oncmsmadesimple<span style="color: #000000; font-weight: bold;">/</span></div></div>
<p>AHA!. Apparently the printing module fetches the content (or at least, tries to) from the webserver, fails, and then segfaults php. Excellent code guys!<br />
The reason for the failing is obvious from the logs here, I require authentication for the website since this is a test location that shouldn&#8217;t be public. Quick fix, allow the server to skip the login (vhost config):</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #000000; font-weight: bold;">&lt;</span>Location <span style="color: #000000; font-weight: bold;">/&gt;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; AuthType Basic<br />
&nbsp; &nbsp; &nbsp; &nbsp; AuthName <span style="color: #ff0000;">&quot;Testsite CmsMadeSimple&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; AuthUserFile <span style="color: #000000; font-weight: bold;">/</span>lala<span style="color: #000000; font-weight: bold;">/</span>passwordfile<br />
&nbsp; &nbsp; &nbsp; &nbsp; Require valid-user<br />
&nbsp; &nbsp; &nbsp; &nbsp; Allow from 127.0.0.1<br />
&nbsp; &nbsp; &nbsp; &nbsp; Allow from 192.168.1.1<br />
&nbsp; &nbsp; &nbsp; &nbsp; Satisfy Any<br />
&nbsp; <span style="color: #000000; font-weight: bold;">&lt;/</span>Location<span style="color: #000000; font-weight: bold;">&gt;</span></div></div>
<p>Problem solved. (Hint Printing Module: render your own shit, don&#8217;t cheat with fopen/curl)</p>
<p>Oh yeah: CmsMadeSimple rocks for these simple websites where your customer wants to &#8220;change some texts and add a picture&#8221;. If they can handle word, you can make them handle this (but show them how!).<br />
Give them permissions to add pages and nothing else, write a decent template for them, done.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/cmsmadesimple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDF printing and Cups (The Cups Drama &#8482; Part 2!)</title>
		<link>http://notes.benv.junerules.com/all/software/pdf-printing-and-cups-the-cups-drama-tm-part-2/</link>
		<comments>http://notes.benv.junerules.com/all/software/pdf-printing-and-cups-the-cups-drama-tm-part-2/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 14:01:54 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[printing]]></category>
		<category><![CDATA[slackware]]></category>
		<category><![CDATA[xpdf]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=243</guid>
		<description><![CDATA[Here we are today, trying to do a very simple thing. Print a stupid little PDF document so our customers can pay their bills. Easy huh? Especially after the previous cups drama? So we fire up xpdf on the document, hit the print icon, lpr, GO! *time passes* Mhm, what is it now? *check http://localhost:631* [...]]]></description>
			<content:encoded><![CDATA[<p>Here we are today, trying to do a very simple thing. Print a stupid little PDF document so our customers can pay their bills.<br />
Easy huh? Especially after the <a href="http://notes.benv.junerules.com/software/printing-and-cups/" title="Printing and Cups">previous cups drama</a>?</p>
<p>So we fire up xpdf on the document, hit the print icon, lpr, GO!<br />
*time passes*<br />
Mhm, what is it now?<br />
*check <span style="color:#F00F00">http://localhost:631</span>*<br />
Nope, no document there, seems like it was handled by the printer.<br />
*check cups <span style="color:#F000F0">error_log</span>*<br />
Heaps of garbage there. </p>
<p>Remember that we had this issue left in our previous cups story? Something about PDF printing causing issues?<span id="more-243"></span><br />
Well, since then cups got upgraded to version 1.3.11 and some other stuff too, like ghostscript.<br />
This time the error log showed something like this (only the relevant part here):</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">49</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> backendRunLoop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">print_fd</span>=<span style="color: #000000;">0</span>, <span style="color: #007800;">device_fd</span>=<span style="color: #000000;">5</span>, <span style="color: #007800;">use_bc</span>=<span style="color: #000000;">0</span>, <span style="color: #007800;">side_cb</span>=0x804a23f<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">49</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Wrote <span style="color: #000000;">1</span> pages...<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">49</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> PID <span style="color: #000000;">26288</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cups<span style="color: #000000; font-weight: bold;">/</span>filter<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">pstops</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> exited with no errors.<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Error: error occurred at print phase <span style="color: #000000; font-weight: bold;">!!</span><br />
E <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> No pages found<span style="color: #000000; font-weight: bold;">!</span><br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> Discarding unused printer-state-changed event...<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> Discarding unused job-progress event...<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> GPL Ghostscript <span style="color: #000000;">8.70</span>: Unrecoverable error, <span style="color: #7a0874; font-weight: bold;">exit</span> code <span style="color: #000000;">1</span><br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #c20cb9; font-weight: bold;">cat</span>: <span style="color: #c20cb9; font-weight: bold;">write</span> error: Broken pipe<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> PID <span style="color: #000000;">26289</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cups<span style="color: #000000; font-weight: bold;">/</span>filter<span style="color: #000000; font-weight: bold;">/</span>brlpdwrapperdcp135c<span style="color: #7a0874; font-weight: bold;">&#41;</span> exited with no errors.<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> PID <span style="color: #000000;">26299</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cups<span style="color: #000000; font-weight: bold;">/</span>backend<span style="color: #000000; font-weight: bold;">/</span>usb<span style="color: #7a0874; font-weight: bold;">&#41;</span> exited with no errors.<br />
D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> File <span style="color: #000000;">0</span> is complete.<br />
I <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">14</span>:<span style="color: #000000;">19</span>:<span style="color: #000000;">50</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">652</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> Completed successfully.</div></div>
<p>Some weird definition of &#8216;successfully&#8217; you have there, cups.<br />
After a few hours of debugging through that error_log, fucking with filters in /usr/share/cups/filters (cursing at Brother for their half baked wrapper scripts), turning on and off debug and log options<br />
I was getting more and more annoyed with it. Considering on how to pick up the Brother DCP-135C and smashing it through the 2nd story window onto the pavement, but then not being<br />
sure if it really was the brother&#8217;s fault at all, I decided to make sure once and for all which one I had to throw through the window.</p>
<p>Time for a manual debug session with the filters again. If you are having trouble with stuff like this, I can commend it to you. The steps I took (after the usual turning on debug and log options etc):</p>
<ol>
<li>Grab your input file, in my case some PDF document which I ran through xpdf.</li>
<li>Instead of sending it to the printer, print using the &#8220;save to file&#8221; option so we have the source that cups has to deal with to work with.</li>
<li>Manually run this file through the filters as cups does. I curse on cups for not being more specific &#8212; EVEN WITH THE <code class="codecolorer bash vibrant"><span class="bash">LogLevel debug2</span></code> OPTION TURNED ON (it just becomes MORE unreadable, but without more information) &#8212; about how it runs these filters, but there are some shell scripts floating around that you can use. What I did was just use
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">strace</span> <span style="color: #660033;">-qfve</span> execve <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">pidof</span> cupsd<span style="color: #000000; font-weight: bold;">`</span> <span style="color: #660033;">-s</span> <span style="color: #000000;">250</span></div></div>
<p>to figure out how my filters were called, but be ready to read tons of output on that one <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Anyhow, to save you some trouble, the call syntax seems to be</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">filterprogram PRINTER JobNum User title copies documentoptions <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #c20cb9; font-weight: bold;">file</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<p>or a real example from my test case:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>cups<span style="color: #000000; font-weight: bold;">/</span>filter<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">pstops</span> <span style="color: #ff0000;">&quot;DCP135C&quot;</span> <span style="color: #000000;">666</span> benv jemoeder <span style="color: #000000;">1</span> <span style="color: #ff0000;">&quot;document-name=4a93e8d852a17 number-up=1 job-uuid=urn:uuid:873e2907-cf50-35e2-5626-741377b394be&quot;</span> <span style="color: #ff0000;">&quot;/var/spool/cups/d00666-001&quot;</span></div></div>
</li>
<li>Find out which part fails. The pstops had some output that looked fine by me, as far as I can read postscript as it scrolls through my terminal.</li>
</ol>
<p>Funny thing is&#8230;. it seemed to me like pstops worked fine, as did the brother cups wrapper&#8230;.<br />
However, there was still this soab left:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">D <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">25</span><span style="color: #000000; font-weight: bold;">/</span>Aug<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2009</span>:<span style="color: #000000;">15</span>:<span style="color: #000000;">48</span>:<span style="color: #000000;">21</span> +0200<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Job <span style="color: #000000;">667</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> GPL Ghostscript <span style="color: #000000;">8.70</span>: Unrecoverable error, <span style="color: #7a0874; font-weight: bold;">exit</span> code <span style="color: #000000;">1</span></div></div>
<p>Execution of /usr/bin/gs showed up in strace as well btw, don&#8217;t worry <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
So now the big question was: when did ghostscript become retarded?</p>
<p>I took my &#8220;print to file&#8221; postscript document, and tried opening it in ghostview.<br />
It just looked at me like a cow looks at an oncoming train. Or in its own words:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Error: <span style="color: #000000; font-weight: bold;">/</span>undefined <span style="color: #000000; font-weight: bold;">in</span> ilQ2-amMq3gmMqGPL Ghostscript <span style="color: #000000;">8.70</span>: Unrecoverable error, <span style="color: #7a0874; font-weight: bold;">exit</span> code <span style="color: #000000;">1</span><br />
<br />
Operand stack:<br />
<br />
Execution stack:<br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">%</span>interp_exit &nbsp; .runexec2 &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #000000;">2</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>stopped_push &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #c20cb9; font-weight: bold;">false</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>stopped_push &nbsp; <span style="color: #000000;">1862</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; <span style="color: #000000;">3</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>oparray_pop &nbsp; <span style="color: #000000;">1861</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; <span style="color: #000000;">3</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>oparray_pop &nbsp; <span style="color: #000000;">1845</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; <span style="color: #000000;">3</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>oparray_pop &nbsp; <span style="color: #000000;">1739</span> &nbsp; <span style="color: #000000;">1</span> &nbsp; <span style="color: #000000;">3</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>oparray_pop &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>errorexec_pop &nbsp; .runexec2 &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #660033;">--nostringval--</span> &nbsp; <span style="color: #000000;">2</span> &nbsp; <span style="color: #000000; font-weight: bold;">%</span>stopped_push &nbsp; <span style="color: #660033;">--nostringval--</span><br />
Dictionary stack:<br />
&nbsp; &nbsp;--dict:<span style="color: #000000;">1150</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1684</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>ro<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>G<span style="color: #7a0874; font-weight: bold;">&#41;</span>-- &nbsp; --dict:<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>G<span style="color: #7a0874; font-weight: bold;">&#41;</span>-- &nbsp; --dict:<span style="color: #000000;">71</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">200</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>L<span style="color: #7a0874; font-weight: bold;">&#41;</span>-- &nbsp; --dict:<span style="color: #000000;">65</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">75</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>L<span style="color: #7a0874; font-weight: bold;">&#41;</span>-- &nbsp; --dict:<span style="color: #000000;">18</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">25</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>L<span style="color: #7a0874; font-weight: bold;">&#41;</span>--<br />
Current allocation mode is <span style="color: #7a0874; font-weight: bold;">local</span><br />
Last OS error: <span style="color: #000000;">11</span></div></div>
<p>Ah-HA!</p>
<p>&#8230;.</p>
<p>What?</p>
<p>Since I&#8217;m by no means an expert on postscript, I googled it. The search revealed that apparently this could be the result of an eps image conversion gone bad.<br />
Postscript doesn&#8217;t like to deal with binary data, so it&#8217;s not supposed to be there.<br />
<span style="color:#FFFF00">This can mean only one thing</span>!<br />
<span style="color:#FF0000">xpdf failed!!!!!!</span></p>
<p>Some testing revealed that xpdf on the old slackware32 chroot environment still does work, and printing the exact same PDF file there works fine, while printing that document from the 64 bit<br />
slackware envrionment fails with the above story. Fascinating. Seems like it isn&#8217;t a library issue though, unless it&#8217;s cleverly hidden in the X libraries. I hope they&#8217;ll fix this soon <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Just for reference, this is the <span style="color:#FF00FF">xpdf-3.02pl3-x86_64-1</span> package that fails.</p>
<p>Well, now that we all know the details we can go to bed.<br />
And if you need to print that pdf document: simply use <span style="color:#00FF00">pdf2ps</span>, it works. (and stay away from habbokrat reader)</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/pdf-printing-and-cups-the-cups-drama-tm-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing and cups</title>
		<link>http://notes.benv.junerules.com/all/software/printing-and-cups/</link>
		<comments>http://notes.benv.junerules.com/all/software/printing-and-cups/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 13:29:06 +0000</pubDate>
		<dc:creator>BenV</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[cups]]></category>
		<category><![CDATA[printing]]></category>
		<category><![CDATA[slackware]]></category>

		<guid isPermaLink="false">http://notes.benv.junerules.com/?p=199</guid>
		<description><![CDATA[We tried to do something that seems fairly simple. &#8220;Print out these tickets for HAR2009&#8220;, where we went last weekend and had a great time The tickets were delivered to me by mail in PDF format. Sounds easy huh? Note that this story was written the day before we went there, just not finished, so [...]]]></description>
			<content:encoded><![CDATA[<p>We tried to do something that seems fairly simple. &#8220;Print out these tickets for <a href="https://wiki.har2009.org/page/Main_Page" title="Hacking At Random 2009">HAR2009</a>&#8220;, where we went last weekend and had a great time <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
The tickets were delivered to me by mail in PDF format. Sounds easy huh?<br />
Note that this story was written the day before we went there, just not finished, so timing might be a bit awkward. Here are the details.<span id="more-199"></span></p>
<p>Attempt 1:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">lpr</span> har_ticket_00.pdf<br />
$</div></div>
<p>Easy. It even works, the printer starts rumbling and out it comes. Oh&#8230;. seems like the barcode is a bit screwed&#8230;. mhm, wonder how it managed to do that. (the rest looked fine).<br />
Browsing through the cups error_log gave some gibberish, this line caught my attention:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">W [11/Aug/2009:16:58:55 +0200] [Job 624] This document does not conform to the Adobe Document Structuring Conventions and may not print correctly!</div></div>
<p>Mhm, interesting. Google returned a bunch of filter thingies, and I was like &#8220;maybe it&#8217;ll work better if I try converting it to ps myself first&#8221;.<br />
So I ran pdf2ps (instead of pdftops as cups does) and viewed the resulting ps file. Looks a lot better. Print it!<br />
lpr on the file, and out it comes. Huh, no landscape? I try <code class="codecolorer text vibrant"><span class="text">lpr -o landscape stupidfile.ps</span></code> which also does portrait. RAAAH, STUPID KANKER CUPS.<br />
After an hour of google and cursing I said &#8220;Fine, you do it&#8221; to lotjuh, who asked me earlier if she had to do it with her <a href="http://www.adobe.com/nl/products/reader/">Habbokrat Reader</a>&#8230;. what a piece of garbage that is&#8230;.</p>
<p>Anyway, lotjuh soon ran into a new issue. First of all, her new Windows 7 didn&#8217;t have a printer driver, and trying to install the Vista on failed. Our printer is a cheap Brother DCP135C, which isn&#8217;t THAT old I thought. Oh well, that&#8217;s your windows problems for you <img src='http://notes.benv.junerules.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
So she booted to linux. Surprise! Print didn&#8217;t work. That is, it said &#8220;OK&#8221; but out came nothing. Jobs just collected at her local cups.</p>
<p>*grumble*WHYYYYY???</p>
<p>Debugging this is a tough, since none of the logs give any useful information whatsoever, even in debug mode.</p>
<p>To understand this problem you might want some more network background info:<br />
We have our internet through xs4all, who gave us a Fritzbox for that. Since I couldn&#8217;t get it to work like our previous internet setup with the external IP address on our local server,<br />
we eventually decided that the thing could route for us, but we have our own DHCP server running on our local server.<br />
So in our LAN the default gateway is the fritzbox, but our local server has most ports forwarded to it. In order to also run a dns server and dns cache it has multiple IP addresses in our local lan.<br />
In fact, it has 3 IPs in the 192.168.1.x range on a single ethernet device.</p>
<p>Back to cups:<br />
In cupsd.conf I have <code class="codecolorer text vibrant"><span class="text">Listen 192.168.1.1:631</span></code>. That should work, right?<br />
However, BrowseAddress only accepts a .255 at the end, or an @IF statement. So I had @IF(eth_local) there.<br />
Result: clients get confused, try to send data to all 3 IP addresses on the network. And since I can&#8217;t put the primary IP address in the BrowseAddress&#8230;. it fails.<br />
My guess is that cups detects all 3 IP addresses on that interface and happily announces those, while only 1 of them should be used. Especially because of the listen statement.<br />
I fixed this by using the second address, which I conviently have on a &#8216;different&#8217; ethernet device eth_local:0. This seems to work a lot better, the clients now have a single printer in their cups<br />
configuration and it even provides its location!</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Device URI: ipp://192.168.1.2:631/printers/DCP135C</div></div>
<p>instead of the old</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Device URI: file://dev/null</div></div>
<p>However, my first problem was still present. The whining about invalid PDF files. Printing from KWord also gave this error. The local cups would happily forward my job to our server, which then barfed on the thing:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">D [11/Aug/2009:19:47:17 +0200] [Job 637] Printer using device file &quot;/dev/usblp0&quot;...<br />
D [11/Aug/2009:19:47:17 +0200] Discarding unused printer-state-changed event...<br />
D [11/Aug/2009:19:47:17 +0200] [Job 637] backendRunLoop(print_fd=0, device_fd=5, use_bc=0, side_cb=0x804a23f)<br />
D [11/Aug/2009:19:47:17 +0200] [Job 637] Page = 595x842; 9,9 to 586,833<br />
D [11/Aug/2009:19:47:17 +0200] [Job 637] slow_collate=0, slow_duplex=0, slow_order=1<br />
W [11/Aug/2009:19:47:17 +0200] [Job 637] This document does not conform to the Adobe Document Structuring Conventions and may not print correctly!<br />
D [11/Aug/2009:19:47:17 +0200] Discarding unused printer-state-changed event...<br />
D [11/Aug/2009:19:47:17 +0200] Discarding unused job-progress event...<br />
D [11/Aug/2009:19:47:17 +0200] PID 12180 (/usr/lib/cups/filter/pdftops) exited with no errors.<br />
D [11/Aug/2009:19:47:17 +0200] PID 12181 (/usr/lib/cups/filter/pstops) exited with no errors.<br />
D [11/Aug/2009:19:47:18 +0200] [Job 637] Error: error occurred at print phase !!<br />
E [11/Aug/2009:19:47:18 +0200] [Job 637] No pages found!<br />
D [11/Aug/2009:19:47:18 +0200] Discarding unused printer-state-changed event...<br />
D [11/Aug/2009:19:47:18 +0200] Discarding unused job-progress event...<br />
D [11/Aug/2009:19:47:18 +0200] [Job 637] GPL Ghostscript 8.64: Unrecoverable error, exit code 1</div></div>
<p>&#8230; well, that&#8217;s just lovely.<br />
(insert your curse of the day here).</p>
<p>Oh btw, if anyone ever wonders about the status of their printer and cups and everything:</p>
<div class="codecolorer-container bash vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ lpstat <span style="color: #660033;">-t</span><br />
scheduler is running<br />
system default destination: DCP135C<br />
members of class default:<br />
&nbsp; &nbsp; unknown<br />
members of class printers:<br />
&nbsp; &nbsp; unknown<br />
device <span style="color: #000000; font-weight: bold;">for</span> DCP135C: ipp:<span style="color: #000000; font-weight: bold;">//</span>192.168.1.2:<span style="color: #000000;">631</span><span style="color: #000000; font-weight: bold;">/</span>printers<span style="color: #000000; font-weight: bold;">/</span>DCP135C<br />
device <span style="color: #000000; font-weight: bold;">for</span> default: ipp:<span style="color: #000000; font-weight: bold;">//</span>192.168.1.2:<span style="color: #000000;">631</span><span style="color: #000000; font-weight: bold;">/</span>classes<span style="color: #000000; font-weight: bold;">/</span>default<br />
device <span style="color: #000000; font-weight: bold;">for</span> printers: ipp:<span style="color: #000000; font-weight: bold;">//</span>192.168.1.2:<span style="color: #000000;">631</span><span style="color: #000000; font-weight: bold;">/</span>classes<span style="color: #000000; font-weight: bold;">/</span>printers<br />
DCP135C accepting requests since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">45</span> PM CEST<br />
default accepting requests since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">46</span> PM CEST<br />
printers accepting requests since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">47</span> PM CEST<br />
printer DCP135C is idle. &nbsp;enabled since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">45</span> PM CEST<br />
printer default is idle. &nbsp;enabled since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">46</span> PM CEST<br />
printer printers is idle. &nbsp;enabled since Tue <span style="color: #000000;">11</span> Aug <span style="color: #000000;">2009</span> 07:<span style="color: #000000;">44</span>:<span style="color: #000000;">47</span> PM CEST</div></div>
<p>So far I haven&#8217;t found a solution for this problem yet, except for a print to file, scp, manually convert, lpr style workaround, but that&#8217;s tedious.<br />
If anyone knows, I&#8217;m interested in the cause and fix for it.</p>
]]></content:encoded>
			<wfw:commentRss>http://notes.benv.junerules.com/all/software/printing-and-cups/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
