Home / Alt manpages / pdftops(1)

  • pdftops(1)
  • User command
  • linux

Convert a PDF to PostScript Safely with pdftops

An old printer or RIP that only speaks PostScript is not going anywhere, and pdftops is what turns a modern PDF into something it can read. You will turn a PDF into a PostScript file, or into a single-page EPS file, while checking the page range and keeping the original PDF untouched. Allow about ten minutes for a one-off conversion, longer if you need to diagnose fonts or printer compatibility.

The examples use the poppler-utils package installed on this machine, version 24.02.0-1ubuntu9.9, with pdftops reporting Poppler 24.02.0. Run the conversion as your normal user: it reads the PDF and writes a destination file, and neither operation normally needs sudo. Do not use an owner or user password on a shared command line, because shell history, process listings or logs can expose it.

1. Check the installed command

Confirm that the binary you will run is the expected one. This changes no files:

$ command -v pdftops
/usr/bin/pdftops
$ pdftops -v 2>&1 | head -3
pdftops version 24.02.0
Copyright 2005-2024 The Poppler Developers - http://poppler.freedesktop.org

The local manual page describes the interface as pdftops [options] <PDF-file> [<PS-file>]. Its page is labelled version 3.03, while the installed executable identifies itself as Poppler 24.02.0. Use the executable's version when recording what produced an output file.

Checkpoint

You have a readable input PDF, a writable output directory and the expected pdftops on your path.

2. Convert the whole PDF to PostScript

Give the input and a new output name. Omit the output argument and pdftops derives a name by swapping .pdf for .ps, but naming the destination explicitly makes scripts and reviews clearer:

$ pdftops /path/to/input.pdf /path/to/output.ps
$ printf 'exit status: %s\n' "$?"
exit status: 0
$ file /path/to/output.ps
/path/to/output.ps: PostScript document text conforming DSC level 3.0, Level 2

A successful exit status means the conversion completed. The exact file description varies, but the result should be identified as PostScript and should be non-empty. Check its size with ls -lh if the destination looks unexpectedly small.

Warning

Do not put an existing valuable output after > in an unrelated shell pipeline. When pdftops opens a named output file, an existing file there may be replaced. Choose a fresh name first, or make a backup before deliberately replacing one.

3. Convert selected pages

Use -f for the first page and -l for the last page. Page numbers are inclusive. This makes a two-page extract from pages 4 and 5:

$ pdftops -f 4 -l 5 /path/to/input.pdf /path/to/pages-4-5.ps
$ file /path/to/pages-4-5.ps
/path/to/pages-4-5.ps: PostScript document text conforming DSC level 3.0, Level 2

Check the range before running it: the option selects PDF pages, not printed sheet numbers shown in a document's footer. If the input has fewer pages than requested, treat the command's diagnostic and non-zero status as the useful result rather than assuming a complete extract.

To send PostScript to standard output, use - as the output file. This is useful when another program consumes the stream:

$ pdftops -f 1 -l 1 /path/to/input.pdf - | head -3
%!PS-Adobe-3.0
%Produced by poppler pdftops version: 24.02.0 (http://poppler.freedesktop.org)
%%Creator:

The pipe above is only a preview. Do not use head as the output of a real conversion, because it deliberately throws away the rest of the PostScript.

4. Make a single-page EPS file

EPS is a different output mode from ordinary multi-page PostScript. An EPS file holds one image, so select exactly one PDF page with matching -f and -l values:

$ pdftops -eps -f 1 -l 1 /path/to/input.pdf /path/to/page-1.eps
$ file /path/to/page-1.eps
/path/to/page-1.eps: PostScript document text conforming DSC level 3.0, type EPS, Level 2

The manual also provides -form for a PostScript form that forms-aware software can import. Do not combine -eps and -form, and do not expect EPS to preserve a multi-page document.

If an old printer or interpreter will read the output, compatibility can matter more than size. The default is Level 2 PostScript. -level1 targets Level 1 devices, but it can make image-heavy output much larger and converts images to black and white. Only one of the Level 1, 2 or 3 mode options can be used at a time.

5. Keep page sizing and rasterisation deliberate

By default, the output paper size matches the PDF page size. The output is cropped to the PDF CropBox, pages larger than the paper are shrunk, and smaller pages are centred after scaling. These defaults are usually sensible, but they explain why a printed result can differ from an application's preview.

  • -origpagesizes. An alias for -paper match, useful when you want the intent obvious in a script.
  • -nocrop. Disables CropBox cropping.
  • -noshrink. Stops shrinking of oversized pages.
  • -expand. Enlarges smaller pages.
  • -nocenter. Aligns pages to the lower-left instead of centring them.

Test one page before sending a large job to a printer.

Pages with transparency, and Level 1 output with colour masks, may need rasterisation. The default rasterisation resolution is 300 DPI. Set -r when the target printer needs something different. -rasterize always forces rasterisation, while -rasterize never prevents it but may produce output that displays incorrectly. If the PostScript is for viewing rather than printing, -aaRaster yes can make rasterised text easier to read.

6. Diagnose failures without hiding them

Leave diagnostics enabled while testing. -q suppresses messages and errors, so it only belongs in a script with another reliable error channel. Use pdftops -h for usage information, or pdftops -v for version details.

The documented exit codes mark several common boundaries: 0 means no error, 1 means the PDF could not be opened, 2 means the output could not be opened, 3 indicates a PDF permission error and 99 is another error. Check both the status and the output file: a stale or truncated destination is not a successful conversion.

For an input permission problem, check the path and access without changing anything:

$ test -r /path/to/input.pdf && echo 'input is readable'
$ test -w /path/to/output-directory && echo 'directory is writable'

Security warning

If a PDF needs a password, supply it only through a controlled mechanism appropriate to your environment. -opw supplies an owner password and bypasses security restrictions; -upw supplies a user password. Because these are command-line arguments, keep real secrets out of shell history and shared process listings. If you do not have authorisation to bypass a document's restrictions, stop and get it first.

7. Replace output only after checking it

When a conversion replaces a file, write to a temporary destination in the same directory, inspect it, then rename it. The rename is the state-changing step and may overwrite the old file, so keep a backup if recovery matters:

$ cp --preserve=all /path/to/output.ps /path/to/output.ps.backup
$ pdftops /path/to/input.pdf /path/to/output.ps.new
$ file /path/to/output.ps.new
/path/to/output.ps.new: PostScript document text conforming DSC level 3.0, Level 2
$ mv /path/to/output.ps.new /path/to/output.ps

Recovery

If conversion fails, leave the original in place and remove the incomplete .new file after checking the error. If the final rename has already happened and the result is wrong, restore the backup with mv /path/to/output.ps.backup /path/to/output.ps. Do not delete the backup until the replacement has been opened by its real consumer.

Done means

  • Version confirmed. You confirmed the installed Poppler version and picked a readable PDF.
  • Output identified. The result is identified as PostScript or, for one selected page, EPS.
  • Sizing matched. Any page range, paper sizing and rasterisation choices match the actual consumer.
  • Both checks done. You checked both the exit status and the output instead of suppressing diagnostics.
  • Recovery kept. You did not expose a PDF password unnecessarily, or overwrite a useful output without a recovery path.