Thursday, 13 June 2013

Combine (concatenate) PDF files

I'm a digital packrat - OK, well, I hoard real stuff too, but I like to collect scans of interesting bits.  I had scanned a bunch of pages out of a book about steam engines.  This was back before I knew how to scan a bunch of pages into one pdf with Simple Scan.  So I had a directory with a dozen pdfs that I wanted to make into one pdf for easy viewing.  Enter pdftk.

At first I was going to do the following:

pdftk 'steam engine1.pdf' 'steam engine2.pdf' 'steam engine3.pdf' cat output steamengines.pdf

Note single quotes to allow use of spaces in filenames, which I've stopped doing as apparently it's a Bad Thing in Linux.  But then I realised that with the magic of wildcards, I could save a bit of typing:

pdftk steam*.pdf cat output steamengines.pdf

and voila, a dozen files into one, and a "booyah" and fist pump and an odd look from my wife at the other end of the couch.

And it's in the usual repositories so getting it is as easy as:

sudo apt-get install pdftk