Splitting And Combining Odd/Even Pages With Pdftk

I'm working on a fun printable project at the moment, but part way through I realised I would need to process odd and even pages of the document separately. So separately, that I split the doc into two separate ones, with odd pages in one and event pages in another - and then had to recombine them. Here's the commands that I used, with an excellent tool called pdftk.

Splitting Document into Odd and Even Pages

This needs two commands, one to grab the odd pages, and one to get the even ones. Mine look like this:

pdftk hints.pdf cat 1-endeven output hints1.pdf
pdftk hints.pdf cat 1-endodd output hints2.pdf

This leaves the original document intact, and creates two new ones with half the pages in each one.

Combining Documents With Alternate Pages

The interleave is a single command in pdftk, using the shuffle feature and giving two documents to use:

pdftk A=doc1.pdf B=doc2.pdf shuffle A B output complete.pdf

This creates the file complete.pdf using alternate pages from each of the two documents you provide to the first two arguments. Very handy, either for the odd/even processing case I mentioned above, or I have also used this when printing two-sided documents which are made from different front/back sources.

If you use these, or have any tips to add, please leave me a comment - it's always interesting to see what others are making with my favourite tools.

One thought on “Splitting And Combining Odd/Even Pages With Pdftk

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>