Ubuntu: Using pdftk to stitch together two-sided PDF

ubuntuThere are many consumer side printers that provide the ability to scan a document to PDF.  But unless you have a high-end series, the printer may only be capable of scanning one side at a time, which means you end up with a “front.pdf” and “back.pdf”.

If you have a Linux desktop or laptop, luckily the solution is as simple as calling ‘pdftk’.

To install pdftk:

$ sudo apt-get install pdftk -y

To collate a “front.pdf” with “back.pdf” into a single PDF with interleaved pages:

$ pdftk A=front.pdf B=back.pdf shuffle A Bend-1 output final.pdf

If “back.pdf” needed to be rotated 180 degrees before merging (scanned upside down):

$ pdftk back.pdf cat 1-endsouth output back-corrected.pdf

And if you needed to append two PDF together, without collation:

$ pdftk in1.pdf in2.pdf cat output appended.pdf

Using only pages 2-4 of a document:

$ pdftk in1.pdf cat 2-4 output smallerfile.pdf