Split & Combine PDF Files With pdftk In Ubuntu 17.10 Artful Aardvark

PDF stands for Portable Document Format, and has become the de facto standard for official government documents and corporate documents – think of how many times you have had to visit a government website or your employer’s website to download and fill out an official form in PDF. The upside to this is that a document creator can arrange to have a PDF look exactly the way he wants it, since PDFs are readable on many different operating systems and devices. The downside is that if you need to change a PDF file after it has been created, changing it is both annoying and difficult.

The is where the pdftk utility comes into play. The pdftk utility (it’s short for “PDF Toolkit”) allows you to combine and separate PDF files. It’s not included in the default installation of Ubuntu, but you can rectify that in short order from the command line. Log into an account with administrative rights, go to a Terminal window, and type this command:

sudo apt-get install pdftk

Enter your password to authenticate, and apt will download and install pdftk for you. After the installation is complete, you can use pdftk from the command line.

Now that you have pdftk installed, we’ll show you how to use it combine PDF files. Let’s say, for example, that you have three PDF files: Page1.pdf, Page2.pdf, and Page3.pdf. You need to combine them into a single PDF document called FinalDraft.pdf. You could do this via LibreOffice or another document editing program. Or you could do it with pdftk:

pdftk Page1.pdf Page2.pdf Page3.pdf output FinalDraft.pdf

This command will take the three PDF files and combine them into a single PDF named FinalDraft.pdf. Note that pdftk will combine the files in the order they are listed. So if you wanted Page3.pdf to actually be the first page in FinalDraft.pdf instead of Page1.pdf, you would use this command:

pdftk Page3.pdf Page2.pdf Page1.pdf output FinalDraft.pdf

This will create the FinalDraft.pdf document with the Page3.pdf as its first page.

You can also use pdftk to extract single pages from larger PDF documents. In this example, let’s say you have a 90-page PDF document named Report.pdf. You want to extract only page 9 from this document so you can email it to a coworker. To extract page 9 from Report.pdf and save it as its own PDF document named Page9.pdf, use pdftk with these options:

pdftk A=Report.pdf cat A9 output Page9.pdf

This will take the ninth page from Report.pdf and save it as its own PDF document named Page9.pdf.

Likewise, you can also use pdftk to extract a range of pages from a PDF document and save them in their own file. To return to our previous example, if you wanted to extract pages 19 through 37 of Report.pdf in their own file named Extract.pdf, you would use pdftk with these options:

pdftk A=Report.pdf cat A19-37 output Extract.pdf

With pdftk, you can disassemble and reassemble PDF documents with ease.

Was this post helpful? These books might be useful:

Leave a Reply

Your email address will not be published. Required fields are marked *