Merge pdfs In Linux
It’s often useful to merge multiple pdf files in a single pdf file. I recently had to do this to merge all my monthly statements into a single pdf to print.
Let’s take an example where we have a folder full of pdfs in /usr/myPdfs and we want to merge them all together.
First, let’s get a listing of the pdf files in that folder:
sudo ls /usr/myPdfs/*.pdf
/usr/myPdfs/one.pdf /usr/myPdfs/two.pdf /usr/myPdfs/three.pdf
Next, lets cd into the directory so we can use relative paths
cd /usr/myPdfs
Next, lets cd into the directory so we can use relative paths
sudo pdftk /usr/myPdfs/one.pdf /usr/myPdfs/two.pdf /usr/myPdfs/three.pdf cat output comboPdf.pdf
If you get an error that says: pdftk: command not found. Then you need to install the pdftk program and retry the above command.
sudo apt-get install pdftk