How to Merge PDF Files in Linux

Got several PDF files and now you have to combine them into one? Here are different ways you can use to merge PDF files in Linux.
Warp Terminal

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.

merge pdf files using in ubuntu

In the next step, click on Add file and select the files you want to merge:

choose files to merge

Once you select files, click on the Merge button:

click on 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:

locate and name the merged pdf file

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.

11 Best Linux PDF Editors You Can Use in 2023
Looking for the best PDF editing options? You should find some awesome options here!

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:

open pdf file in libreoffice

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:

merge pdf in linux

Once you are done with drag and drop, click on the 5th option from the top left, labeled as Export Directly as PDF:

export directly as pdf in libreoffice

And it will open a file manager from where you can locate and name the file:

save merged file from libreoffice

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:

convert im6.q16: attempt to perform an operation not allowed by the security policy `pdf' @ error constitute.c iscoderauthorized 421.

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 rights="none" to rights=read|write:

<policy domain="coder" rights="read|write" pattern="PDF" />
change policy in imagemagick to merge pdf files

Save the changes, and now you can easily merge files using ImageMagick:

merge pdf files using imagemagick in linux terminal

Wrapping Up

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.

How to Compress PDF in Linux [GUI & Terminal]
Brief: Learn how to reduce the size of a PDF file in Linux. Both command line and GUI methods have been discussed. I was filling some application form and it asked to upload the necessary documents in PDF format. Not a big issue. I gathered all the scanned images and

Similarly, you can use this neat little trick for simple PDF editing tasks such as adding comments and highlighting texts in PDF.

How to Add Comments to PDF in Linux
You don’t need a dedicated PDF editor to add comments and highlight text. Here’s how you can use GNOME’s Document Viewer to annotate PDFs in Linux.

Let me know if you face any issues with above discussed methods.

About the author
Sagar Sharma

Sagar Sharma

A software engineer who loves to write about his experience with Linux. While reviving my crashed system, you can find me reading literature, manga, or watering my plants.

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

itsfoss happy penguin

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.