Extract even-numbered and odd-numbered pages of a PDF into two separate PDFs
I'd do it with pdftk.
pdftk A=all.pdf cat Aodd output odd.pdf
pdftk A=all.pdf cat Aeven output even.pdf
pdftk is not Open Source any longer, unfortunately. (That is a long story.)
Plain gs engine can do it, though:
gs -sDEVICE=pdfwrite \
-sPageList=odd \
-sOutputFile=odd.pdf \
-dBATCH -dNOPAUSE \
file.pdf
Then substitute 'odd' with 'even' to select even pages.
With poppler-utils
tools you could first extract single pages with pdfseparate
:
pdfseparate infile.pdf piece-%d.pdf
into pieces like piece-1.pdf
, piece-2.pdf
... piece-n.pdf
where n
is the total number of pages in your original pdf.
You could then join them with pdfunite
(and a shell that supports using an increment value with range expansion: {<START>..<END>..<INCR>}
):
pdfunite piece-{1..n..2}.pdf odd.pdf
pdfunite piece-{2..n..2}.pdf even.pdf
Finally, remove the pieces:
rm piece-{1..n}.pdf