Home / Alt manpages / pdftops(1)

  • pdftops(1)
  • User command
  • linux

Convert a PDF to PostScript safely with pdftops

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; neither operation normally needs sudo. Do not use an owner or user password on a shared command line: 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 does not change any 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. If you omit the output argument, pdftops derives a name by replacing .pdf with .ps. 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 is unexpectedly small.

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

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 discards 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 contains 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 software supporting forms can import. Do not combine -eps and -form, and do not expect EPS to preserve a multi-page document.

If the output will be consumed by an old printer or interpreter, compatibility may matter more than size. The default is Level 2 PostScript. -level1 targets Level 1 devices, but 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 may 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 often sensible, but they explain why a printed result can differ from an application's preview.

Use -origpagesizes, an alias for -paper match, when you want the intent to be obvious in a script. Use -nocrop to disable CropBox cropping, -noshrink to prevent shrinking, -expand to enlarge smaller pages and -nocenter to align them to the lower-left instead of centring them. Test one page before sending a large job to a printer.

Pages that contain 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 a different resolution. -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. The -q option suppresses messages and errors, so it is appropriate only when a calling program has another reliable error channel. Use pdftops -h for usage information, or pdftops -v for version details.

The documented exit codes identify 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. Verify 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'

If a PDF requires a password, supply it only through a controlled mechanism appropriate to your environment. The -opw option supplies an owner password and bypasses security restrictions; -upw supplies a user password. Because these values are command-line arguments, avoid putting real secrets into shell history or shared process listings. If you do not have authorisation to bypass the document's restrictions, stop and obtain it instead.

7. Replace output only after checking it

When a conversion replaces a file, use a temporary destination in the same directory, inspect it, then rename it. The rename is the state-changing step and may replace 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

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

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