[Samba] Printing with CUPS and PDF

Kurt Pfeifle kpfeifle at danka.de
Tue Apr 1 00:31:26 GMT 2003


> Tom samba-lists at fleet.ucdavis.edu wrote on Samba-Digest:

> Mon Mar 31 15:00:22 GMT 2003
> 
> 
> PDF printing through CUPS backend: Got it to work. Gory details follow.
> 
> Kurt Pfeifle wrote:
>>> Tom samba-lists at fleet.ucdavis.edu wrote on Samba-Digest:
>> 
>> 
>>> Mon Mar 31 11:57:58 GMT 2003
>>>
>>>
>>> Everything goes smoothly with the installation... drop 'pdfdistiller' 
>>> into /usr/lib/cups/backend,
>> 
>> 
>> I hope you didn't use "copy'n'paste" from your browser, but "Save as..."
>> to get it?
> 
> I didn't. That file was fine.
> 
>> 
>>> chmod +x, restart cups service. Add a printer in cups with:
>>>
>>> 'lpadmin -p PDF -E -v pdf:/tmp/'
>>>
>>> ...and voila! Nothing happens.
>> 
>> 
>> Of course not. You have not yet associated a PPD with it, which means you
>> are running it as a "raw" printer.
> 
> Gentle readers, remember this lesson. A PPD file is necessary even for 
> printing to PDF files.

It needs to be a PPD for a real PostScript printer, best a very generic one,
with little or now device-specific settings contained.

The reason is this: it makes CUPS to convert anything it accepts as print
input to PostScript (because it thinks a PostScript printer is hanging at
the end). Then our backend is guaranteed to receive PostScript (the only
input it can process) and can do its ps-to-pdf cconversion work.

In theory, you could run it without the PPD too -- but then you can only
send PostScript files to the PDF-converter.

If you use the suggested "distiller.ppd", you can set for instance the
"media size" and the "resolution" parameters in any GUI (such as "kprinter",
"gtklp" or "xpp"). If you offer this driver for download to the Windows
clients and make them print the driver test page, you can see how the
setting of the resolution takes effect on the MS flag in the upper left
corner, because this originally is a vector graphic (You won't see it in
fonts...)

>>> Doesn't give any errors, but it won't print ('lpr -P PDF foo.ps'). 
>>> Delete the printer ('lpadmin -x PDF'), download distiller.ppd (found 
>>> here: http://www.pentondigitalads.com/downloads/adist4.zip). Copy new 
>>> ppd file to /usr/share/cups/model. Re-add printer with:
>>>
>>> 'lpadmin -p PDF -E -v pdf:/tmp/ -m distiller.ppd'
>>>
>>> ...and there we go! Still nothing prints. :(
>> 
>> 
>> OK.
>> 
>> Did you re-start cupsd after dropping the "distiller.ppd" into
>> "/usr/share/cups/model/" ? This is required to allow CUPS to rebuild
>> its cache of available PPDs from that directory. Only if there is a
>> valid cache, you can install the PPD using the "-m" parameter without
>> the path.
>> 
>> Otherwise use the absolute path; then you don't need to re-start cupsd
>> after updating your PPD "model" directory:
>> 
>>   'lpadmin -p PDF -E -v pdf:/tmp/ -P /usr/share/cups/model/distiller.ppd'
>> 
>> Do you see a "/etc/cups/ppd/PDF.ppd" ?
>> 
>> To check if CUPS is recogizing the newly available backend, let root run
>> 
>>   "lpinfo -v"
>> 
>> and grep for "pdf".
>> 
>> To check if it basically works as a backend, first run it with no 
>> arguments:
>> 
>>   "/usr/lib/cups/backend/pdfdistiller"
>> 
>> and it should output
>> 
>>   'direct pdf "Unknown" "PDF Writing"'
>> 
>> Then run it with a wrong number of arguments (use 1, 2, 3, or 4 dummy 
>> arguments)
>> 
>>    "/usr/lib/cups/backend/pdfdistiller 1 2 a b"
>> 
>> and it should output
>> 
>>    "Usage: pdf job-id user title copies options [file]"
>> 
>> The PDF should go to "/tmp/", according to your installation. Backends 
>> are running
>> as root, and for paranoid security you may not want to write files as 
>> root into
>> "/tmp/". Better use a separate directory with access rights you need:
>> 
>>    "lpadmin -p PDF -E -v pdf:/home/username/pdfs/ -P 
>> /usr/share/cups/model/distiller.ppd"
>> 
>> Further, the script relies on "ps2pdf" to be present on your system. Do 
>> you get
>> an answer to this:
>> 
>>    "which ps2pdf"
> 
> I did restart, I did get all of those messages, 'which ps2pdf' comes up 
> fine, everyone works great according to your docs up to this point.
> 
>> 
>> Last: If you want to get some more debugging info into the CUPS error_log
>> (in "/var/log/cups/error_log"), insert this line
>> 
>>    "set -x"
>> 
>> into the "pdfdistiller" as the right after the first line. Set cupsd.conf
>> to "LogLevel debug" and re-start cupsd.
> 
> This is what fixed it for me... adding "set -x" in pdfdistiller and 
> "LogLevel debug" into cupsd.conf gave me much better info to dig through 
> in /var/log/cups/error_log.
> 
> Here's a chunk of what I found:
> 
> D [31/Mar/2003:14:19:22 -0800] StartJob: backend = 
> "/usr/lib/cups/backend/pdf"
> D [31/Mar/2003:14:19:22 -0800] StartJob: filterfds[1] = -1, 9
> D [31/Mar/2003:14:19:22 -0800] 
> start_process("/usr/lib/cups/backend/pdf", 0xbfffb730, 0xbfffabe0, 10, 9, 7)
> I [31/Mar/2003:14:19:22 -0800] Started backend /usr/lib/cups/backend/pdf 
> (PID 4179) for job 155.
> E [31/Mar/2003:14:19:22 -0800] PID 4179 stopped with status 22!
> D [31/Mar/2003:14:19:22 -0800] [Job 155] /usr/lib/cups/backend/pdf: No 
> such file or directory	
> 
> It was looking for "/usr/lib/cups/backend/pdf" as the backend instead of 
> "/usr/lib/cups/backend/pdfdistiller", which is what the file was named. 
> I made a copy called "/usr/lib/cups/backend/pdf" and it worked fine. I 
> do not yet know why cups was looking for the file as "pdf" instead of 
> "pdfdistiller", but this was the entirety of the issue.

D'oooh!

I forgot to mention this. CUPS looks for the backend name as is shown
in the output of "lpinfo -v".

(I have it symlinked on my other box from the short "pdf", and thusly
forgot to mention, because I had no direct access for a check at the
time of writing. Sorry.)


>>> I dig the simplicity of the solution at
>>> http://printing.kde.org/downloads/
>>> but given that it doesn't seem to work for me, I can hardly recommend it.
>> 
>> 
>> You don't need to recommend it -- *I'll* be doing it...   ;-)
> 
> Ok, now that makes two of us! :)

OK then... Now let's chase the 3rd...  ;-)

> 
> Thanks Kurt!
> 
> -Tom
> 

Bye,
Kurt



More information about the samba mailing list