Combine PDF files with pdftk in Ubuntu

PDF (i.e. Portable Document Format) is a file format. It was developed by Adobe. A PDF document may contain text, links, images, videos, form fields etc. There are times when we have multiple PDF files available. And, for some reason we may want them as one entity. One tool which can help achieve exactly that is pdftk. So, in this article we cover how to combine multiple PDF files with pdftk in Ubuntu.

pdftk is a command-line tool, which is used to manage PDF documents. We cover its installation steps first. And, later the usage part.

Note: Following operations require you to have superuser privileges. In case you don’t have one then, we advise you to contact your System Administrator for assistance.

Install pdftk in Ubuntu

If you already have pdftk-java package installed then, skip this section. Otherwise, follow along – since the package is already a part of standard Ubuntu repository. Therefore, to download the latest version we would have to update repository first. Hence, open a terminal and issue the following –

sudo apt update

Next, to install pdftk

sudo apt install pdftk-java

This would install few additional packages along-with it.

Combine PDF files with pdftk in Ubuntu

Method I. To combine PDFs, use the following syntax –

pdftk <input1.pdf> <input2.pdf> <inputn.pdf> cat output <output.pdf>

here, inputn.pdf represents the nth pdf.

For instance, if we had three PDFs – 1.pdf, 2.pdf, 3.pdf

Now, to combine them as one entity – Example.pdf. Under such scenario, use the following command –

pdftk 1.pdf 2.pdf 3.pdf cat output Example.pdf

But, if there are numerous PDFs as input. Then, it won’t be feasible to provide multiple inputs. In that case, use command in Method II.

Method II. If you want to combine all the PDFs available in a directory then,

pdftk *.pdf cat output <output.pdf>

Furthermore, we can also create an additional directory and place all our PDFs in the directory to combine them. That way we don’t have to provide multiple inputs and use Method II.

In conclusion, we have covered how to combine multiple PDFs with pdftk in Ubuntu here.

Similar Posts