Home Linux Commandline Tools How to Merge Multiple PDF Files into One PDF in Linux

How to Merge Multiple PDF Files into One PDF in Linux

PDF or Portable Document Format files have more to offer to its users apart from the obvious advantages of being easily printable and shareable over a network.

Some other uniqueness of having a file converted or existing in PDF includes the following:

  • eSigning capabilities to give a file the needed authenticity.
  • Built-in security as a PDF file can be protected with passwords.
  • File encryption support.
  • Compact file size support.

Now that you know the advantages and importance of having your document files existing as PDF, there comes a time when you will have multiple inter-related PDF files existing separately.

At this point, collecting and moving these relatable PDF files into a single folder or directory might fix your file reference problem at the cost of efficiency.

You will have to switch between multiple open PDF files to get the bits of information you need from each file. An ideal solution, in this case, will be to merge all these relatable PDF files into a single PDF file.

Create PDF Files in Linux

Before we look at the techniques and approaches of merging multiple PDF files into a single PDF file, let us create three sample PDF files that we will attempt to merge. You can use LibreOffice to create three different word document texts and then export each of them to be saved as PDF files.

Export PDF in LibreOffice
Export PDF in LibreOffice

In my case, I created three PDF files for this tutorial article:

PDF Files in Linux
PDF Files in Linux

Ways to Merge Multiple PDF Files to a Single PDF File in Linux

We are going to look at two methods of merging multiple PDF files into a single PDF file in Linux. The First method considers merging a selection of PDF files into a single file. The second method considers merging all PDF files within a given folder or directory to a single file.

Method 1: Merging a Selection of PDF Files to a Single PDF File

Let us try to merge pdf1.pdf and pdf2.pdf files into a single file. To achieve this file merging objective, we are going to install and use the pdftk utility.

Reference the following pdftk installation commands in regards to your Linux operating system distribution. Make sure you are a Sudoer user or you have Sudo privileges on your Linux system.

$ sudo apt-get install pdftk     [On Debian, Ubuntu and Mint]
$ sudo yum install pdftk         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a sys-apps/pdftk  [On Gentoo Linux]
$ sudo pacman -S pdftk           [On Arch Linux]
$ sudo zypper install pdftk      [On OpenSUSE]    

To merge our two PDF files, we will reference the following command syntax:

$ pdftk pdf_file_1 pdf_file_2 cat output final_pdf_file

The above command syntax merges pdf_file_1 and pdf_file_2 to a newly created file called final_pdf_file.

Let us now merge our pdf1.pdf and pdf2.pdf files:

$ pdftk pdf1.pdf pdf2.pdf cat output pdf12.pdf
Merge PDF Files in Linux
Merge PDF Files in Linux

Check for the existence of the merged file:

$ ls
Check PDF Files in Linux
Check PDF Files in Linux

On opening the pdf12.pdf file, it showcases pdf1.pdf and pdf2.pdf files successfully merged in it.

View PDF Files in Linux
View PDF Files in Linux

Method 2: Merging All PDF Files to a Single PDF File

In this section, we are going to attempt merging all PDF files inside the “LinuxShellTips PDF” folder without specifying their names.

List PDF Files in Linux
List PDF Files in Linux

The command syntax to use is as follows:

$ pdftk *.pdf cat output final_pdf_file

In reference to the above command syntax, all files in the directory with a “.pdf” extension will be merged to a newly created PDF file called final_pdf_file.

Let us now merge our files:

$ pdftk *.pdf cat output pdf123.pdf
Merge PDF Files into One PDF
Merge PDF Files into One PDF

Check for the existence of the merged PDF file:

$ ls
List Merged PDF Files in Linux
List Merged PDF Files in Linux

On opening the pdf123.pdf file:

View Merged PDF File in Linux
View Merged PDF File in Linux

It accommodates all the three PDF files we created earlier.

Whether you want to merge multiple selections of PDF files or all PDF files existing in a single folder or directory, this article guide has shown you how to get the job done in a seamless manner. We hope this article lessens your file management routines.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

2 thoughts on “How to Merge Multiple PDF Files into One PDF in Linux”

  1. I use PDF Arranger to merge my pdf files. I also use it to remove pdf pages in a larger pdf document.

    Example: I download a User Manual for one of my tools, and it has English, Spanish, and French sections. I will remove the Spanish and French sections, so my resulting document does not take as much memory space.

    Reply

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.