Saturday, May 12, 2012

Tip: Merge PDF files into a single PDF using Pdftk

In a previous post I've explained how to extract pages from a PDF document.

Funny enough a few days latter I needed to merge some PDF files into a single document, instead of hunting the web for a Windows application to do that (I have to use Windows at work) I used scp to send the files to the home server, ran pdftk there and scp the merged PDF back ;)

So today I'll use Pdftk this time to merge several PDF documents into a single PDF.

Start by installing Pdftk if you haven't using your distributions package manager:
  • Instructions for installing Pdftk for FreeBSD can be found here
  • If you are using a Debian based distribution issue apt-get install pdftk.
  • Users of RPM distribution's such as RHEL, CentOS, Scientific Linux and Fedora can install it by running yum install pdftk.
  • To install the program on Gentoo use emerge pdftk.
Now onto using Pdftk for our purpose!

The steps to merge PDF documents into a single PDF consist of:

  1. $ cd change_to_directory_with_target_pdfs
  2. $ pdftk first.pdf second.pdf third.pdf cat output merged-pdf.pdf

The PDF should be listed in the order in which they are to be placed in the final document. More information on Pdftk can be found using man pdftk.

No comments: