Home / Alt manpages / pdf2dsc(1)

  • pdf2dsc(1)
  • User command
  • linux

Make a Browsable PostScript Page List with pdf2dsc

pdf2dsc turns a PDF into a tiny PostScript stub that lists every page, for viewers that want to jump around. It does not convert the PDF into standalone image or PostScript pages, and it does not touch the source document. Budget about five minutes.

You need a readable PDF, the ghostscript package, and space for the new DSC file. None of the steps below needs sudo.

1. Check the installed command

Confirm the command is on your machine and note the Ghostscript package version. Since pdf2dsc is a Ghostscript wrapper rather than a standalone PDF engine, the package version is what you compare across hosts:

command -v pdf2dsc
dpkg-query -W -f='${Package} ${Version}\n' ghostscript

On this host the expected version is ghostscript 10.02.1~dfsg1-0ubuntu7.9. The installed script has no version flag: pass an unsupported option such as --help and it gets read as a PDF filename instead. Use the manpage or the package query when you need version details.

Checkpoint

Continue when command -v prints a path and the package query prints a Ghostscript version.

2. Point at the right PDF

  • Swap the placeholder path. Change the example below to the document you actually want to process.
  • Confirm it is readable. Check it is a regular, readable file with the name you expect, catching the classic mistake of converting a half-finished download or a similarly named directory.
pdf='/path/to/input.pdf'
test -f "$pdf" && test -r "$pdf" && ls -lh -- "$pdf"

A successful check shows the size and path from ls. If it fails, fix the path or permissions rather than reaching for sudo: the generated file should normally belong to the user running the conversion.

3. Generate the DSC file with the default name

Run pdf2dsc with the PDF as its only argument:

cd /path/to/the/output/directory
pdf2dsc /path/to/input.pdf

With no second argument, the command strips the input extension and appends .dsc, so /path/to/input.pdf produces /path/to/input.dsc next to the PDF, not next to your shell's current directory. The file holds DSC comments such as %%Pages plus page entries that tell Ghostscript how to display individual PDF pages.

Check the output without opening an editor, confirming it exists and looks like PostScript rather than an error report:

test -s /path/to/input.dsc
sed -n '1,12p' /path/to/input.dsc

A good result starts with %!PS-Adobe-3.0 and usually includes a line like %%Pages: 19 matching the source document. Exact page count and media dimensions depend on the PDF.

Checkpoint

Stop here if the output is missing, empty, or does not start with a PostScript header. Ghostscript's diagnostic normally names a missing, unreadable, or invalid input file.

4. Choose a separate output name when needed

Pass a second argument when the default name is awkward, or you want the file in a different directory:

pdf2dsc /path/to/input.pdf /path/to/output/input-page-list.dsc
test -s /path/to/output/input-page-list.dsc
head -n 4 /path/to/output/input-page-list.dsc
  • Directory must already exist. You need write permission there too.
  • Use a fresh name while testing. That way you will not accidentally clobber a DSC file another workflow still relies on.
  • Keep the PDF regardless. If you do replace a disposable generated DSC file, hang on to the source PDF: it is what the DSC file gets recreated from.

5. Use the result with the right expectations

The DSC file is a page-list wrapper, not a copy. A PostScript viewer processing it still needs the original PDF at the path embedded in the DSC setup section, so moving the PDF afterwards can break the DSC file even though the DSC file itself is untouched. Keep the two together, or regenerate the DSC file once the PDF has moved.

The output relies on Ghostscript-specific procedures, so it is aimed at Ghostscript-based viewers such as Ghostview rather than every general-purpose PostScript interpreter. A compatible viewer can browse pages in any order, but pdf2dsc never edits the PDF, extracts pages, or produces a portable standalone copy.

Common traps

  • /undefinedfilename or a file error. Check the exact input path, read permission, and current working directory. Quoting the path protects spaces and shell metacharacters, for example pdf2dsc "$pdf".
  • Output turns up somewhere unexpected. The one-argument form puts the .dsc beside the PDF, not beside your shell's current directory. Give an explicit second path when that matters.
  • Viewer cannot open the pages. Put the PDF back at the path the DSC file references, or rerun pdf2dsc after moving it. The DSC file is never self-contained.
  • Non-Ghostscript viewer rejects it. That is a documented compatibility boundary, not a bug. Try a Ghostscript-based viewer, or use a workflow that consumes PDF directly.

Done means

  • Command confirmed: pdf2dsc is installed and its Ghostscript version is known.
  • File exists: the DSC file is non-empty and starts with a PostScript header.
  • Page count checks out: the number in %%Pages is plausible for the source PDF.
  • Source intact: the original PDF remains at the path the DSC file records.
  • Viewer ready: you have a Ghostscript-based viewer or another known consumer for the result.