Convert a PDF to PostScript Safely with pdf2ps
A PostScript-only printer will not touch your PDF until pdf2ps converts it first. This small Ghostscript wrapper reads one PDF and writes one PostScript file, and the source is never changed. Allow about five minutes for a normal conversion, plus a bit more if the output feeds a print workflow you need to check.
The route
Jump straight to the step you need, or tick off Done means at the end.
This guide uses Ghostscript 10.02.1, from the installed ghostscript package. The output file can be replaced by a later run, so name it deliberately.
1. Check the installed command and input
Start without elevated privileges: you only need read access to the PDF and write access to the output directory. Confirm the executable and package version before trusting an option in a script:
$ command -v pdf2ps
/usr/bin/pdf2ps
$ dpkg-query -W -f='${Package} ${Version}\n' ghostscript
ghostscript 10.02.1~dfsg1-0ubuntu7.9
$ pdf2ps -h
Usage: pdf2ps [-dASCII85EncodePages=false] [-dLanguageLevel=1|2|3] input.pdf [output.ps]
The package revision can differ on another host, but the program version behind it here is Ghostscript 10.02.1, and the local manual page was revised for that version.
2. Convert to an explicit output path
Give pdf2ps the input PDF and the output path as separate arguments, swapping in real paths for the placeholders:
$ pdf2ps /path/to/input.pdf /path/to/output.ps
A successful run normally prints nothing, and a zero exit status just means the command finished. That is not the same as useful output, so check the file itself:
$ test -s /path/to/output.ps && echo "PostScript file is non-empty"
PostScript file is non-empty
$ head -n 1 /path/to/output.ps
%!PS-Adobe-3.0
PostScript is text with embedded page data, so the first line is a quick sanity check, not full validation of every page. Keep the original PDF until the output has been used successfully.
3. Use the default output name when it is convenient
Omit the second argument and the wrapper strips the final .pdf from the input basename and adds .ps. For /srv/reports/invoice.pdf, the default output is invoice.ps in your current working directory, not necessarily beside the input:
$ cd /srv/reports/converted
$ pdf2ps /srv/reports/invoice.pdf
$ test -s invoice.ps && file invoice.ps
invoice.ps: PostScript document text conforming at level 3.0
The exact wording from file varies by version. Check the file landed in the directory you intended and that its size is plausible: an explicit output path is easier to audit in scripts and does not depend on remembering where your shell happened to be.
4. Choose a PostScript language level only when needed
By default pdf2ps allows PostScript Level 2 constructs but not LanguageLevel 3. Use -dLanguageLevel=1 for an older Level 1 consumer, or -dLanguageLevel=3 when the destination supports Level 3:
$ pdf2ps -dLanguageLevel=1 /path/to/input.pdf /path/to/legacy-output.ps
$ head -n 1 /path/to/legacy-output.ps
%!PS-Adobe-3.0
The header alone does not prove every generated construct suits a particular printer. Language level is a compatibility choice for the destination, not a quality setting for the PDF. Stick with the default and test a representative page if you do not know the destination's limits.
The installed wrapper also documents -dASCII85EncodePages=false. Use it only when a downstream consumer specifically needs a different page encoding, and never paste an unreviewed Ghostscript switch from an unrelated command into a script.
5. Avoid overwriting a useful result
Warning
Writing to an existing output path can replace that file. Use a temporary name and move it into place only after conversion and a basic check succeed:
$ pdf2ps /path/to/input.pdf /path/to/output.ps.new
$ test -s /path/to/output.ps.new
$ head -n 1 /path/to/output.ps.new
%!PS-Adobe-3.0
$ mv /path/to/output.ps.new /path/to/output.ps
mv replaces the destination when the filesystem allows it. If conversion fails, leave the existing output.ps alone and inspect the error rather than guessing. To recover, remove only the incomplete output.ps.new after checking its exact path, and never delete the original PDF as part of cleanup.
6. Diagnose the common failures
A usage message usually means an input or output argument is missing, or an option landed where a filename was expected. The accepted form is:
$ pdf2ps [options] input.pdf [output.ps]
- Filename starting with a hyphen gets misread as an option. Prefer an absolute or relative path that does not start with a hyphen, such as
./-report.pdf, and test it in a disposable directory first. - Ghostscript reports a malformed or unsupported PDF. Leave the source unchanged and try opening it with a trusted PDF tool instead of forcing the conversion again.
Check paths and permissions without changing anything:
$ test -r /path/to/input.pdf && echo "input is readable"
$ test -w /path/to && echo "destination is writable"
$ ls -l /path/to/input.pdf /path/to/output.ps.new
A successful conversion still does not guarantee a particular printer renders every font, transparency effect or page feature the way you expect. Compare a printed or previewed page when fidelity matters.
Done means
- Version confirmed: you checked the installed
pdf2psand Ghostscript version. - Source untouched: the input PDF remains unchanged and readable.
- Output in place: the PostScript file was written to the intended directory.
- Header verified: the output is non-empty and starts with a PostScript header.
- Level chosen deliberately: you set a language level only for a known destination requirement.
- Replacement staged safely: any overwrite used a temporary filename first, leaving the previous output recoverable.