Multi Media

How to Merge PDF Files Using the Command Line on Ubuntu

“Did you happen to see a presentation? You would have seen the screen with graphs and text, right? That data is in the PDF or portable documents format is, perhaps, the most popular for the ease of sharing documents that can be viewed on almost any device. The data presented on them is the same as it means to be, there can be an occasion when you need to show a single file of PDF, but it is divided into multiple parts; then what are you going to do?”

This article will go through the methods to help you merge different PDF files on your Linux-based system.

Method 1: Merging PDF Files Through pdftk Utility

You must follow the following steps to merge PDF files using the pdftk utility.

Step 1: Installing pdftk Utility

First, you need to install the pdftk utility using the following command in the terminal.

sudo apt-get install pdftk

 

Once you enter this command, it will ask for your permission to install it, so press “Y” and enter to continue

We have 2 files in our “Root folder” that we will merge into a single file.

Step 2: Let’s Merge the PDF Files

Using the following command, we will now merge the two PDF files.

pdftk file1.pdf file2.pdf cat output file3.pdf

 

Before the “cat” keyword, you can use the many PDF files you want to merge while the name of the output PDF file comes after it.

Although it won’t show you any message, you can confirm if it worked or not by looking for the “file3” as you can see in the image below.

You can also merge all files in the directory by altering the command in the following way.

pdftk *.pdf cat output file3.pdf

 

Note: The “*” represents all the files inside the directory, while the “.pdf” is the extension of PDF files.

Method 2: Merging PDF Files Through the Poppler Utility

There is another way of merging files through the poppler utility on Linux, and you need to follow these steps to combine your PDF files.

Step 1: Install Poppler Utility

You can install the poppler utility by using the following command.

sudo apt-get install poppler-utils

 

Step 2: Let’s Merge the PDF Files Using the Poppler Utility

To merge the PDF files using the poppler utility, use the following command.

Pdfunite 2.pdf File2.pdf final.pdf

 

Note: 2.pdf and File2.pdf are the names of the files we are merging, while the final.pdf is the file that will be the combined form of your PDF files.

It won’t display any message, so you will need to go to the directory to confirm if it worked or not, as seen in the image below.

Pdftk Utility vs. Poppler Utility: Who is the Winner?

Both the utilities have a simple command-based procedure to merge different files, and both are pretty quick, but in our opinion, the pdftk utility is better because it also provides you with the functionality to merge all PDF files found inside a directory into a single file which isn’t yet possible, while using the poppler utility.

Conclusion

PDF is undoubtedly the king when it comes to presenting anything, whether online or offline, you need to have the perfect presentation for better results, and PDF shows everything in the same manner that you have saved or converted it from the word file. Today we merged different PDF files into one using two methods discussed above.

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.