Search code examples
pdfpostscriptghostscriptpdftk

Converting .ps to .pdf and removing a single page


I have a postscript file of a poster made in latex, and want to convert this to a pdf (I'm using ubuntu)

I am using ps2pdf but if possible I would like to remove the first, blank page, and keep only the second page.

Is there a command that allows this? Been trying to find one for longer than would seem sensible!

Thanks!


Solution

  • First convert to PDF the complete file with whatever tool you prefer. (For quality output I would not use ps2pdf which is only a shortcut to run a fully fledged Ghostscript commandline. I would use the appropriate Ghostscript commandline directly, because it gives greater and direct control over all the parameters used. But it needs some GS expertise to use...).

    Then, to extract the second page only, you have two options:

    1. pdftk (PDF ToolKit from here)
    2. gs (Ghostscript from here)

    pdftk commandline:

    pdftk \
      A=/path/to/input.pdf \
      cat A2 \
      output /path/to/page2-from-input.pdf
    

    gs commandline:

    gs \
      -o /path/to/output.pdf \
      -sDEVICE=pdfwrite \
      -dFirstPage=2 \
      -dLastPage=2 \
      /path/to/input.pdf