Having to scan 150 double-sided sheets, I ran into the problem of merging them into a single PDF file. We have an Automatic Document Feeder at the office, but it can only scan one side at a time, giving me two PDFs; one with all fronts, one with all backs.
The problem consists of two parts: - The PDF containing the backs is in reversed page order, since I simply flipped the stack over and put it back in the ADF.
- The two PDF files need to be interleaved into a single file such that the back of page 1 lies between the front of page 1 and the front of page 2.
To address problem 1, simply enter the following command:
pdftk backs.pdf cat end-1 output backs-rev.pdf
To address problem 2, enter the following set of commands:
mkdir pages pdftk fronts.pdf burst output pages\%04d_a.pdf pdftk backs-rev.pdf burst output pages\%04d_b.pdf pdftk pages\*_?.pdf cat output combined.pdf
Presto! You have all the pages neatly combined into combined.pdf — in the correct order! You can then proceed to delete the temporary pages folder. |