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.
[ You might also like: How to Merge PDF Files Using GUI Tools in Linux ]
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.
In my case, I created three PDF files for this tutorial article:
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
Check for the existence of the merged file:
On opening the pdf12.pdf file, it showcases pdf1.pdf and pdf2.pdf files successfully merged in it.
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.
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
Check for the existence of the merged PDF file:
On opening the pdf123.pdf file:
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.