How to Merge PDF Files on Command Line

Recently, I needed to combine 2 or more PDF files into one. Merging these PDF files could be due to the company's demand or a need to track all files in one file. In this tutorial, I'd show you how I accomplished this particular task on my machine. There are several tools online to merge pdf files but I will use pdfunite.


To install pdfunite on your machine, follow the steps below.


First, we'll install the poppler package.

sudo yum -y install poppler

Next, we update the system

sudo yum update


The Ubuntu/Debian OS follows the same installation procedures as CentOS but with a different package name.

sudo apt install poppler-utils

Then, we updated the system using

sudo apt update


On macOS, you can use Bash and execute the Linux commands or you can choose to use the brew package manager.

brew install poppler


Using the chocolatey command-line tool on Windows, execute the following command:

choco install poppler


├── 1300.pdf
├── 1500.pdf
├── 1750.pdf
├── 1980.pdf
└── 1990.pdf

I assume we have all the pdf files in a folder to form the above file structure. To merge these, execute this command on the terminal

pdfunite 1300.pdf 1500.pdf 1750.pdf 1980.pdf 1990.pdf output.pdf

The last file output.pdf is the merged pdf. Hence, the last parameter to pass is the output of all merges.


In this short tutorial, we've seen how to merge several using the command line on our machines.

No Comments Yet