A guide to using PDFs on GNU/Linux
Although GNU/Linux has long supported postscript format, full support for the related PDF file format has been longer in arriving. Today, however, PDF support is finally starting to equal what is available on other operating systems. Whether you are printing, editing, or viewing PDF files, you now have the choice of a variety of applications on both the command line and the desktops.
What follows is not an exhaustive list of choices, but a survey of the main tools available. Taken together, they should be enough to fill most of your PDF needs.
Printing to PDF
GNU/Linux offers several options for producing .PDF files. At the command line, you can use ps2pdf, a script that comes bundled with Ghostscript. As its name suggests, ps2pdf converts postscript files to .PDF format. You can convert a file to postscript within any application by setting up a postscript printer to print to file (you don't actually need the physical printer). From there, all you need is to enter the command
ps2pdf <input.ps> <output.pdf>. If you don't want to change the path or name of the output file, you can omit it altogether to produce a file that has the same name as the postscript input file, but with a .pdf extension.
On the desktop, you can use Print to File (PDF) for KDE-aware applications like KWord, selecting it as a printer from within the application. A more universally useful solution is the CUPS-PDF driver, which you can set up as a CUPS printer. For CUPS-PDF, use the device URI of
cups-pdf:/, and select Generic from the list of manufacturers and Postscript from the list of models. All output from CUPS-PDF is to a sub-folder of your home directory with the same name as the printer you set up.
However, all three of these solutions fall far short of the full functionality available for other operating systems.If you want more control over the PDF files you produce, a better choice is OpenOffice.org's File -> Export to PDF, especially when the extendedPDF add-on is installed. This option gives you control over image compression, bookmarks, forms, the default view, and security options -- just about everything except font embedding, which is enabled by default (an option that simplifies the sharing of files between different computing systems). The main drawback is that the combination produces PDF files that are, on average, about one-third larger than those produced by CUPS-PDF. Otherwise, the degree of control it allows should make it the preferred method of PDF production.
When you have an existing PDF file that you need to edit, the quickest solution on any platform is to make your changes in the source file and produce a new file. However, if you don't have the source file, you have at least two options.
From the command line, pdftk offers a variety of functions. Using pdftk, you can split, merge, decrypt, encrypt PDF files, as well as fill out forms, rotate pages, add watermarks, or edit metadata. In some cases, you can even repair a corrupted file. The one drawback to pdftk is that it involves editing in text mode what is basically a graphical document. For this reason, editing with pdftk can often be a challenge, even if you have a copy of the file that you are editing open in a viewer.
For many, a more practical solution is PDFedit. Although still in early development, PDFedit has many of the functions of pdftk. Even more importantly, it allows you to edit individual characters. This ability is painfully slow, and limited to a buffer of about fifty characters. Nor is it up to editing more than a line at a time, which would require massive reformatting of the document. Still, Adobe Acrobat itself offers no better character editing of PDFs, and, even in its current release, PDFedit is a welcome addition to the PDF tool kit. Between it and pdftk, GNU/Linux users should be able to achieve approximate parity with users of other operating systems, at least in terms of functionality -- convenience,unfortunately, remains elusive.
PDF viewers are easier to implement than PDF generators or editors, so GNU/Linux has a number of them. For those with no objections to use non-free software, Adobe has released Adobe Acrobat Reader for Linux 7.0, which is on a par with its readers for other operating systems, and allows viewers to see both bookmarks and metadata.
The available free viewers are a mixed lot. Both gv and xpdf display the pages of a PDF document, and include the standard options for changing the magnification and for navigating documents. However, neither shows thumbnails, bookmarks, or metadata. Since both GNOME's Evince and KDE's KPDF can display all three, either one of them is generally a better choice for a free view -- about nine times out of ten. However, every now and then, gv or xpdf manages to read PDF files that Evince or KDPF cannot. Whatever the reason for this difference in functionality, it means that you should at least keep the full range of choices in the back of your mind, even if you do not want to install every free viewer on the off-chance that you need it.
PDF support on GNU/Linux still has some gaps. Still, it has improved immensely from even a few years ago, until today it is rapidly approaching the functionality found on other platforms. Most of the time, the challenge now is not finding the tools you need so much as switching between a variety of shell and desktop interfaces in your search. A single suite of programs like Adobe Acrobat with a more or less common interface would improve the situation immensely for the average user.
However, that is a challenge for another day. For now, what matters is that, with a little bit of flexibility and ingenuity, you can consider one of the long-standing gaps in GNU/Linux functionality close to be bridged.
Bruce Byfield is a computer journalist who writes regularly for NewsForge, Linux.com, and IT Manager's Journal.