How to Combine Multiple PDF Files With pdftk

At first glance this topic might seem like an easy fix, but if you stop and think about it, there are few quick and easy methods for merging two or more PDF files. The desired end result is one PDF file that contains all of the information from the original two or more files without any noticeable breaks or ugly indications of a hack.

If the PDF files are yours, the intelligent thing to do is to combine them before you export them into PDF format. But if you no longer have the original documents, or you want to combine files that were not yours originally, such as bank statements, tax forms, etc., you will need pdftk.

Short for “pdf toolkit”, pdftk allows you to merge PDF documents, split PDF pages into new documents, rotate PDF pages, decrypt and encrypt, update metadata, apply watermarks, and much more. It is free and open source software available for Windows, Linux, Mac OS X, FreeBSD, and Solaris. Best of all, it does not require Acrobat or any other Adobe products to work.

To begin you will need to make sure that you have pdftk installed. In Ubuntu, run this command in a terminal:

(or use Synaptic to install pdftk)

1. Once you have pdftk installed, you will need to run it from the command line, so start the terminal application you prefer (i.e. gnome terminal, xterm, xfterm, konsole).

2. Change to the directory containing your PDF files:

3. Decide what order you want the PDF files to appear in the final document. You will use that order when typing the command line string.

4. Type the following string, listing your PDF files in the order you want them to appear:

That is all it takes. Be sure to check the new PDF file to make sure all of the new pages display correctly. The merging process is seamless, painless, and should work on any regular PDF files you have.

To combine multiple documents in a directory without listing each one, use wildcards (*):

As an added bonus, pdftk can perform many other tasks. For example, to split a pdf file’s pages into multiple documents, run the following command:

This will split the document into single pages that you can then manipulate as you see fit.

With pdftk you can even merge certain pages from within multiple documents into one new document. Just enter the following command:

In this case, “A” and “B” are used as “handles” for the names of your documents. You can use as many as you need.

To encrypt your new PDF file, use the following command:

This only touches the surface of the many functions of PDF manipulation available with pdftk. The project’s website gives a good overview of commands and also provides full documentation. The site itself describes this powerful program the best:

“If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses.”

pdftk is available for installation on many Linux distributions or can be built from source on numerous operating systems.