Got several PDFs on the same subject and now you want to combine them into a single PDF?
Or perhaps you need to upload a single file consisting of different files? Many government and academic portals require that.
As a Linux user, if you are in a situation where you need to merge PDFs, this tutorial will help you out.
In this tutorial, I’ll share three methods of combining multiple PDF files:
- Using PDF Tricks GUI tool
- Using LibreOffice (allows you to select pages as well)
- Using the ImageMagick command line tool (Can a Linux tutorial be completed without the terminal method?)
You can read them all and pick the one that works best for you.
Method 1: Use PDF Tricks GUI tool to merge PDF in Linux
After experimenting with several GUI tools, I found that the PDF Tricks was straightforward to use and easy to navigate.
Furthermore, it includes additional functionality beyond only merging PDF files, including:
- Compress PDFs.
- Split PDFs.
- Compress PDFs (into JPG, PNG, and text formats).
It is available as a Flatpak. Please ensure that your Linux system has Flatpak support enabled.
I am sharing the steps for enabling Flatpak on Ubuntu:
sudo apt install flatpak flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Now, use the below command to install PDF Tricks in your system:
flatpak install flathub com.github.muriloventuroso.pdftricks
Once you are done with the installation, open the PDF Tricks application from the system menu.
On the first run, you will get you a list of actions you can perform with this tool. To merge PDF files, go with the third option, obviously.
In the next step, click on Add file and select the files you want to merge:
Once you select files, click on the Merge button:
And it will open the default file manager of your system. Here you can select where you want to save the merged file and what it should be named:
And that’s it. The combined pdf has been saved.
And if you are looking for a tool, we have a list of the best PDF readers that you can use to read and edit PDF files.
Method 2: Merge PDF Files using LibreOffice
The awesome LibreOffice is capable of handling many PDF related tasks. You can even edit PDF files with LibreOffice Draw tool for adding a digital signature, adding text, and much more.
The good thing is that you don’t need to install another application. LibreOffice is already installed on most distributions, if not all.
Open the file manager and select the PDF files that you want to merge.
Right-click on selected files > Open With Other Application > LibreOffice Draw from there, and it will open selected PDF files.
And it will open every PDF file you selected in a separate LibreOffice Draw instance:
Now, you have to select individual pages or entire PDF file (using Ctrl + A) from the left preview bar and drop it to the preview bar of the file that you want to combine with:
Once you are done with drag and drop, click on the 5th option from the top left, labeled as Export Directly as PDF:
And it will open a file manager from where you can locate and name the file:
And that’s it!
Bonus Tip: Merge PDFs in the command line [For advanced users]
What kind of Linux tutorial would it be if I didn’t include the command line method? To merge PDF files in the command line, you can use ImageMagick.
ImageMagick is actually an image-related tool. PDF files are essentially images and this is why ImageMagick can work with them.
You probably don’t even need to install ImageMagick as it is already installed in most distros by default.
For example, I will be adding 3 PDF files named pdf-1.pdf, pdf-2.pdf, and pdf-3.pdf and will name the final merged PDF file output as MergedFile.pdf (how clever):
convert pdf-1.pdf pdf-2.pdf pdf-3.pdf MergedFile.pdf
Troubleshooting no images defined
If you see a policy error like this:
The problem is quite easy to solve. You just have to make minor changes in the ImageMagick policy file.
Open the policy file for editing:
sudo nano /etc/ImageMagick-6/policy.xml
And look for the following line:
<policy domain="coder" rights="none" pattern="PDF" />
Now, you have to change the
<policy domain="coder" rights="read|write" pattern="PDF" />
Save the changes, and now you can easily merge files using ImageMagick:
Now you know several ways of combining PDF files in Linux. Chances are that the merged PDF file is big in size. If you have to upload the merged PDF file on a portal that has size restrictions, you can compress the PDF file.
Similarly, you can use this neat little trick for simple PDF editing tasks such as adding comments and highlighting texts in PDF.
Let me know if you face any issues with above discussed methods.