Convert a PDF to PostScript safely with pdf2ps
You will convert a PDF into a PostScript file that can be sent to a PostScript-aware printer or processed by another tool. The installed pdf2ps is a small Ghostscript wrapper: it reads one PDF and writes one PostScript file. Allow about five minutes for a normal conversion, plus time to check the output if it will be used in a print workflow.
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 source PDF is not changed. The output file can be replaced, so choose its name deliberately.
1. Check the installed command and input
Start without elevated privileges. You normally need only read access to the PDF and write access to the directory receiving the PostScript file. Confirm the executable and package version before relying on 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. The relevant program version 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. Replace the two obvious placeholders with paths that exist on your machine:
$ pdf2ps /path/to/input.pdf /path/to/output.ps
The command normally prints no progress text. A zero exit status means the conversion command completed. Check the file rather than assuming that a quiet command produced useful output:
$ 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 useful quick check but not a complete validation of every page. Keep the original PDF until the output has been consumed successfully.
3. Use the default output name when it is convenient
If you omit the second argument, the wrapper removes the final .pdf suffix from the input basename and adds .ps. For /srv/reports/invoice.pdf, the default output is invoice.ps in the 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 its version. Check that the file is in the directory you intended and that its size is plausible. An explicit output path is easier to audit in scripts and avoids losing track of the current directory.
4. Choose a PostScript language level only when needed
By default, pdf2ps permits PostScript Level 2 constructs, but not LanguageLevel 3 constructs. 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 that every generated construct is acceptable to a particular printer. Language level is a compatibility choice for the destination, not a PDF quality setting. If you do not know the destination's limits, use the default and test a representative page.
The installed wrapper also documents -dASCII85EncodePages=false. Use it only when a downstream consumer specifically requires a different page encoding. Do not add Ghostscript switches from an unrelated command or paste an unreviewed option string into a script.
5. Avoid overwriting a useful result
Writing to an existing output path can replace that file. This is a state-changing step, so 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 permits it. If the conversion fails, leave the existing output.ps alone and inspect the error. To recover from a failed attempt, remove only the incomplete output.ps.new after checking its exact path, or keep it for diagnosis. Do not delete the original PDF as part of cleanup.
6. Diagnose the common failures
A usage message usually means that an input or output argument is missing, or that an option was placed where a filename was expected. The accepted form is:
$ pdf2ps [options] input.pdf [output.ps]
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 filename beginning with a hyphen can be mistaken for an option because the wrapper treats leading option-like arguments as switches. Prefer an absolute or relative path that does not begin with a hyphen, such as ./-report.pdf, and test it in a disposable output directory before automating the conversion.
If Ghostscript reports a malformed or unsupported PDF, keep the source unchanged and try opening it with a trusted PDF tool. A successful conversion does not guarantee that a particular printer will render every font, transparency effect or page feature as expected. Compare a printed or previewed page when fidelity matters.
Done means
- You confirmed the installed
pdf2psand Ghostscript version. - The input PDF remains unchanged and readable.
- The PostScript output was written to the intended directory.
- The output is non-empty and starts with a PostScript header.
- You selected a language level only for a known destination requirement.
- A replacement used a temporary filename, leaving the previous output recoverable if conversion failed.