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.

Installation

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

CentOS/Fedora/RHEL

First, we'll install the poppler package.

sudo yum -y install poppler

Next, we update the system

sudo yum update

Ubuntu/Debian

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

MacOS

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

brew install poppler

Windows

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

choco install poppler

Usage

.
├── 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.

Conclusion

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

No Comments Yet