Friday, November 21, 2008

Generating PDF documents is easy enough on Window$: install PDFCreator and print from any application to the newly created PDF printer.

The same is possible on Linux using a CUPS-PDF printer. It's even easier if the source document is an OpenOffice.org document, because you can directly export it to PDF. Not to mention a lot of other applications that let you create PDF documents directly, or convert from most formats to PDF.

I recently needed to generate PDF documents on my VirtualBox hosted Window$ XP virtual PC. But instead of installing PDFCreator, it seemed to make more sense to "simply" print to the existing CUPS-PDF printer - it's just a matter of installing a new IPP printer at the Window$ side...

click the Printers tab, scroll down until you find the PDF printer - write down its URL

And now for the main event, at a real or virtual Window$ XP box:

open the Printers and Faxes folder

from the menu select File->Add Printer

click Next until the wizard asks you to choose between a local or network printer, select the network printer and click Next

specify the printer with the URL recorded earlier, but replace localhost with the Linux box IP address, e.g.http://10.0.0.1:631/printers/PDF-Printerand click Next

select a printer driver - in our case any Color PostScript printer should be OK

a few more mouse clicks and we're done

At this point the newly created PDF printer can be used to generate PDF documents by printing to it from any application.

The documents will be created, by default, in the PDF directory at your Linux user account. If you're printing from a Window$ user account with a username that does not match any user account on the Linux box, then the generated PDF files will land in /var/spool/cups-pdf/ANONYMOUS/ (the paths can be configured by editing /etc/cups/cups-pdf.conf).

The problem with the procedure above is that the printer driver selected for the new printer does not match the capabilities and limitations of the CUPS-PDF printer. The Right ThingTM to do is to install a PostScript printer driver with the correct CUPS-PDF PPD file:

copy the file CUPS-PDF.ppd from the Linux box (find it at /usr/share/ppd/cups-pdf/CUPS-PDF.ppd) to a temporary folder on the Window$ box

I hope you realize by now that it's much simpler to install PDFCreator and be done with it, instead of all this futzing around with PPD files and all those printer installations and driver replacements.

Bottom line: sharing a CUPS-PDF printer is perfectly feasible, yet, at the same time, quite pointless.

There was one snag that had to fixed: fonts. The original document uses Bitstream Vera Sans TrueType fonts, which aren't installed on the Window$ PC. I could've switched to Tahoma, which look similar enough, but, being a perfectionist (read: obsessive-compulsive), I decided to install the fonts.

when prompted, find the temporary folder from step 1, and select all the fonts

press OK and wait for the fonts installation to complete

But at the last step I got the following error message, no matter what I tried:

The font folder is busy and cannot install the selected fonts at this time. You may retry now or cancel and retry later.

Annoying as hell. What gives?

A quick search got me to a certain blog entry, which pointed me to Microsoft's TweakUI tool, available as a separate download on the PowerToys package page (search the downloads side bar at the right):

install Tweak UI

launch it

use the mouse to select the "Repair" branch from the left side selection tree