Cups-PDF – free virtual pdf-printer

For some time I’ve been bugged by the inability to just print to PDF in OS X. It is rather cumbersome to always select ‘Save as PDF’ from the print menu, rather than just press enter when you have your PDF-printer selected. And rather than cough up money for professional Acrobat-product I wanted something simple.

Through Google I found Cups-PDF, which was released also as a nice package for OS X.

http://www.tuaw.com/2007/03/22/cups-pdf-for-os-x-make-a-pdf-printer/

http://www.codepoetry.net/projects/cups-pdf-for-mosx

http://www.physik.uni-wuerzburg.de/~vrbehr/cups-pdf/

However I noticed a small problem, when printing pages from Firefox. Filenames for documents where the title of the HTML-page, and that meant some of the documents where overwritten if title of the pages happened to be the same.

I sent a quick email to the author, and lo behold – in few minutes got a reply that there already is a switch available in the software for these situations.

Below is the reply from Volker Christian Behr:

for this, there is already an option provided in cups-pdf.conf:
set the option “Label” to 1:

Label 1

Then all filenames will be prepended by a unique number (the job-ID).

Alternatively, if you prefer a different kind of labeling, e.g. a
timestamp, you can easily do this via a postprocessing script. CUPS-PDF
offers an interface to scripts to be run after the conversion. These
scripts will receive the filename of the PDF as first and the username
of the printing user as second argument and they will be called with the
printing user’s privileges.

So set “PostProcessing” to your script’s full path:

PostProcessing /usr/local/bin/my_label_script

And write a small bash-Script like this:

—cut here—

#!/bin/bash

FILENAME=`basename $1`
DIRNAME=`dirname $`
DATE=`date +”%Y-%m-%d–%H-%M-%S”`

mv $1 $DIRNAME”/”$DATE”_”$FILENAME

—cut here—

(make sure it is executable by any user who is going to use the PDF
printer!)

This will label any output in the following way:
/var/spool/cups-pdf/username/file.pdf
will become
/var/spool/cups-pdf/username/2007-09-02–12-07-15_file.pdf

Of course you can adapt this any way you like :-)

Happy PDFing,

Volker Behr

Configuration naturally resides in /etc/cups/cups-pdf.conf

This is why I love open source.

One Response to “Cups-PDF – free virtual pdf-printer”

  1. CUPS-PDF « Huima Says:

    [...] lisää täältä. Posted in OS X, [...]


Leave a Reply