Sean Mackesey
Sean Mackesey

Reputation: 10939

Extract 2nd page of each document and merge into a single document with Ghostscript

I have a set of pdf files from which I would like to:

I know how to do each of these independently with Ghostscript (generating a bunch of temporary 1-page PDF files on the way), but is there any way to do it in one command?

Upvotes: 1

Views: 268

Answers (1)

KenS
KenS

Reputation: 31159

What have you tried ?

Provided you want the same page(s) from every file then this:

gs -sDEVICE=pdfwrite -o out.pdf \
   -dFirstPage=2 -dLastPage=2 \
    input1.pdf input2.pdf

should work.

Please note that my usual caveats apply; pdfwrite is not 'manipulating' the source PDF files, it is fully interpreting them to produce lists of drawing primitives, which are then reassembled to form a brand new PDF file. At no point are you 'extracting' or 'merging' PDF files, the content of the output file(s) bears no relation, other than visual appearance, to the input file(s).

Upvotes: 1

Related Questions