Occasionally, I have to convert a PDF file to Postscript (e.g. for subsequent processing with some PostScript utility). In the Linux/command line area, I know two options: pdf2ps and pdftops. I also know that one of the two is wonky and the other is better. But because their names are so close I can't manage to remember which one to take. This post should put an end to that!
Spoiler alert (and a questionable mnemonic) "pdftops is da top".
The pdf2ps tools is based on Ghostscript, a PostScript interpreter. It is actually a fairly thin shell script wrapper around the "gs" tool.
Basic usage is pretty straight forward:
pdf2ps [options] input.pdf [output.ps]
In case you don't specify the output file name, it's extracted from the input file name by replacing the ".pdf" extension with ".ps".
Help: the man page is minimalistic, the only interesting thing is the
note about the option
pdf2ps -h also
gives you this info. However, as the tool is based on Ghostscript, you
can also give it other options that "gs" accepts (for example
to set the resolution to 300 dpi).
The pdftops tool comes with Xpdf or is successor Poppler (e.g. on Ubuntu 9.10, it's part of the "poppler-utils" package).
Basic usage is straight forward:
pdftops [options] input.pdf [output.ps]
Help: the man page explains a lot of options and
pdftops -h gives you
a short version of that.
pdf2ps versus pdftops: pdftops wins hands down
Problem with pdf2ps: fonts are converted to bitmap fonts (at a pretty
high resolution by default, but configurable with the
For starters, the PDF-to-PS conversion can take quite some time. But
more importantly, the resulting file can be huge, which puts a burden on
subsequent processing of the PostScript file. I also remember having
issues with pdf2ps rather aggressively cropping to bounding boxes.
With pdftops on the other hand, the conversion takes less time, the
resulting file is smaller, and fonts are better preserved. Also, pdftops
provides some interesting additional options like
-eps to generate an
-l to limit the page range to convert, and options
to control/change the page size:
-noshrink. Check out the man page for more info.
Even more Poppler goodies
Apart from the pdftops tool, the poppler-utils package also provides some other interesting toosl: pdfinfo (PDF document information extractor), pdfimages (PDF image extractor), pdftohtml (PDF to HTML converter), pdftotext (PDF to text converter), and pdffonts (PDF font analyzer).