We already have covered how to split or extract particular pages from a PDF file in Linux using pdftk utility a while ago. That tutorial described how to extract a page range or a part of a PDF file in Linux. Today, we will see how to merge two or more PDF files using PDFtk and Poppler applications in Linux.
First, we will discuss how to combine PDF files or merge PDF files from commandline using Pdftk tool.
1. Merge PDF Files In Command Line On Linux Using pdftk
PDFtk is free graphical tool that can be used to split or merge PDF files. It is available as free and paid versions. You can use it either in CLI or GUI mode.
PDFtk is available in the default repositories of most Linux distributions. Let us install pdftk.
Install PDFtk in Arch LInux and derivatives:
$ paru -S pdftk
$ yay -S pdftk
Install PDFtk In Debian, Ubuntu and derivatives:
$ sudo apt-get install pdftk
Install PDFtk On CentOS, Fedora, Red Hat:
$ sudo yum install epel-release
$ sudo dnf install epel-release
Then install PDFtk application using command:
$ sudo yum install pdftk
$ sudo dnf install pdftk
Now, let us merge some pdf files and made it a single file.
I have three pdf files named
file3.pdf in my current working directory. I want to merge them into a single file called
To merge the above three PDF files into one, run the following command from the Terminal:
$ pdftk file1.pdf file2.pdf fiel3.pdf cat output outputfile.pdf
Alternatively, you can use wildcards to merge all files that has
$ pdftk *.pdf cat output outputfile.pdf
This command will merge all pdf files in the current directory into a single file.
2. Merge PDF Files In Command Line On Linux Using Poppler
Poppler is a PDF rendering library based on the xpdf-3.0 code base.
To install Poppler on Arch Linux based distributions, run:
$ sudo pacman -S poppler
On Debian, Ubuntu, Linux Mint:
$ sudo apt-get install poppler-utils
On RHEL, CentOS, Fedora:
$ sudo yum install poppler-utils
Once Poppler installed, run the following command to merge the pdf files in the current working directory.
$ pdfunite file1.pdf file2.pdf file3.pdf outputfile.pdf
The above command will merge file1.pdf, fiel2.pdf and file3.pdf files into a single file called outputfile.pdf.
You know now how to split a pdf file into many parts and how to merge many PDF files into a single file using PDFtk and Poppler tools in Linux. As you can see in this guide, combining or merging PDF files in Linux is not that difficult. You can do this in couple minutes.