Merge PDF Files In Command Line On Linux

Method 1: 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.

Let us install pdftk.

In Arch LInux and derivatives:

PDFtk is available in the AUR. You can install it using any AUR helper programs such as Yay.

$ yay -S pdftk

In Debian, Ubuntu and derivatives:

$ sudo apt-get install pdftk

On CentOS, Fedora, Red Hat:

First, Install EPEL repository:

$ sudo yum install epel-release

Or

$ sudo dnf install epel-release

Then install PDFtk application using command:

$ sudo yum install pdftk

Or

$ sudo dnf install pdftk

Now, let us merge some pdf files and made it a single file.

I have three pdf files namely file1.pdf, file2.pdf, file3.pdf in my current working directory. I want to merge them into a single file called outputfile.pdf. So, I ran the following command from the Terminal:

$ pdftk file1.pdf file2.pdf fiel3.pdf cat output outputfile.pdf

Alternatively, you can run:

$ pdftk *.pdf cat output outputfile.pdf

This command will merge all pdf files in the current directory into a single file.

Method 2: 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.

That’s it. You know now how to split a pdf file into many and how to merge many PDF files into a single file. As you can see in this guide, it is not that difficult. You can do this in couple minutes.

If you know any other methods or commands to do this, feel free to let us know in the comment section below. I will be here with another interesting guide soon. Until then, stay tuned with OSTechNix.