How to Merge PDF Linux [4 Easy Methods]

TL;DR

To effectively merge PDF Linux, use any of the following four methods:

  1. Open a Terminal window.
  2. Update your package list with sudo apt-get update.
  3. Install PDFtk by running sudo apt-get install pdftk.
  4. Navigate to your PDF files’ directory: cd /path/to/your/pdfs.
  5. Merge your PDF files using pdftk file1.pdf file2.pdf cat output mergedfile.pdf.

In this guide, I will introduce you to four different methods for merging PDF files, from command-line utilities like pdftk and Ghostscript to graphical interfaces such as PDF Arranger and PDFSam Basic. I’ll walk you through each step, ensuring you can easily merge PDF Linux. Additionally, I’ve included troubleshooting tips for common issues you might encounter. Let’s start and turn those multiple files into a single, organized PDF document.

Benefits of Using Linux for Managing PDFs

Linux offers a powerful and flexible environment for managing PDFs, making it a popular choice among users. Here are some key benefits:

  • Free and Open-Source Tools: Linux provides many free and open-source tools for managing PDFs. You don’t need to spend money on expensive software, and you can customize these tools to fit your specific needs.
  • Strong Command-Line Support: Linux has powerful command-line tools for handling PDFs. You can quickly merge, split, or edit PDFs using simple commands, which saves you time and effort.
  • Efficient and Lightweight: Linux systems are known for their efficiency and lightweight nature. PDF tools on Linux often use fewer resources, making them run faster and more smoothly.
  • Security and Privacy: Linux is highly secure and respects user privacy. When you manage PDFs on Linux, you can trust that your documents are safe from unwanted access.
  • Versatile and Flexible: Linux supports a wide range of PDF tools, both graphical and command-line. This versatility lets you choose the tool that best suits your workflow and preferences.

How to Merge PDF Linux?

To merge PDF Linux, you can use several tools like PDFtk, Ghostscript, PDF Arranger, and PDFSam Basic. First, install your preferred tool using your package manager, such as sudo apt install pdftk for PDFtk. Then, use a simple command like pdftk file1.pdf file2.pdf cat output merged.pdf to merge your PDFs.

Alternatively, with a graphical tool like PDF Arranger, open the app, import your files, arrange them, and save the merged document. Each method offers a straightforward way to combine multiple PDF files into one on a Linux system.

Here are the detailed steps for four different methods for PDF merge Linux:

1. pdftk

PDF Toolkit (pdftk) is a versatile command-line utility for manipulating PDF files. It’s perfect for Linux users who prefer the command line or need to automate tasks in scripts. pdftk allows you to merge PDF files, split PDF pages into new documents, encrypt or decrypt files, rotate PDF pages, and much more. Follow these steps to Linux merge PDF pages using pdftk:

  1. Open a Terminal window.
opening-terminal
  1. Update your package list by running the command: 
sudo apt-get update

This command updates your package list to ensure you can install the latest version of pdftk.

updating package list
  1. To install pdftk run the command: 
sudo apt-get install pdftk

After the execution, pdftk will be installed on your system.

installing pdftk on ubuntu
  1. To merge two pdf files, first navigate to the directory containing your PDF files using the cd command.
navigating to directory
  1. pdftk merge PDF files into one, using the command: 
pdftk file1.pdf file2.pdf cat output mergedfile.pdf

Replace file1.pdf and file2.pdf with the names of your PDF files.

merging pdf files using pdftk
  1. To check if the files are merged or not, run the command:
pdftotext file.pdf -

Replace file.pdf with the your filename that you merged.

verifying merging of pdf files

Advanced Options and Examples:

  1. To rotate pages of the pdf file use the command: 
pdftk in.pdf cat 1-endeast output out.pdf

This command adjusts the orientation of all pages in in.pdf by rotating them clockwise and saves the result as out.pdf.

rotating pages of pdf file
  1. The output will be:
output
  1. To split the page of the pdf, use the command:
pdftk in.pdf burst

The command splits each page into a separate file.

splitting pages of pdf file

2. Ghostscript

Ghostscript is a powerful suite for processing PDFs, PostScript, and other file formats. It’s highly useful for merging PDF files, converting between formats, and more. Here is the step-by-step guide to merge PDF Linux command line:

  1. Open your command window and update your package manager.
  2. Install Ghostscript by running the command: 
sudo apt-get install ghostscript

Installs Ghostscript, enabling PDF and document processing capabilities.

installing ghostscript on ubuntu
  1. Navigate to the folder with your PDF files in the Terminal and merge PDF files using the command: 
gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=merged.pdf -dBATCH file1.pdf file2.pdf

Replace file1.pdf and file2.pdf with your actual file names.

merging pdf using ghostscript
  1. The output will be:
verifying merged output

3. PDF Arranger

PDF Arranger is a simple, user-friendly GUI application that lets you merge, split, rotate, and rearrange PDF documents. It’s designed for users who prefer graphical interfaces over command-line tools. Here is how to use this tool to Linux combine PDF:

  1. Open a Terminal.
  2. To install PDF Arranger execute the command:
sudo apt install pdfarranger
  1. Verify the installation by pressing y.
installing pdf arranger on ubuntu
  1. Launch PDF Arranger from your application menu.
launching pdf arranger
  1. Click on the Dropdown Menu and select the Import option.
accessing pdf arranger menu
  1. Select files you want to merge then click on Open.
selecting files to be merged
  1. Select Save As to save your merged document as a new PDF.
saving merged file
  1. Now enter the name with which you want to save the merged file and press the Save button.
naming the final merged file

4. PDFSam Basic

PDFSam Basic is a free, open-source tool for splitting, merging, rotating, and extracting PDF pages. It offers a straightforward GUI for users who need to quickly modify PDF documents without diving into command-line utilities. Follow these steps merge PDF Linux:

  1. Visit the PDFSam Basic official website to download the Linux version.
downloading pdfsam deb package
  1. Extract the downloaded package and run the installer script.
sudo dpkg -i pdfsam-x.x.x.x.deb

Replace pdfsam-x.x.x.x.deb with the actual filename of the downloaded .deb package.

installing pdfsam on ubuntu
  1. Follow the on-screen instructions to complete the installation.
  2. Open PDFSam Basic.
launching pdfsam
  1. Choose the Merge option from the main menu.
choose merge option 1
  1. Now click on the the Add button to start adding the pdf files that you want to merge.
clicking Add button
  1. Add the PDF files you wish to merge and arrange them as needed.
selecting files to upload to pdfsam
  1. Click on Run button to combine them into a single document.
merging pdf files using pdfsam
  1. To check the merged file, click on the Open button.
view merged file

Troubleshooting Common Issues When Merging PDF Files on Linux

Merging PDF files on Linux is generally straightforward, but occasionally you might run into some hiccups. Whether it’s an error message, a corrupted file, or something else entirely, there’s usually a solution at hand. Below, I’ve outlined common issues and their solutions to help you navigate these challenges smoothly:

  • 🛠 PDF Files Not Merging Correctly: Ensure all PDF files are not corrupted or password-protected. If using command-line tools like pdftk or Ghostscript, verify the syntax and order of files in your command. Consult tool documentation for syntax specifics.
  • 📂 “File Not Found” Error: Double-check the file paths to ensure they are correct. When using terminal commands, remember Linux paths are case-sensitive. Use the ls command to list directory contents and verify file names.
  • 🔄 Output File Is Empty or Incomplete: This could result from insufficient permissions or disk space. Check your write permissions in the output directory and ensure there’s enough space for the merged PDF.
  • 🛑 Command Not Found: If you receive this error when trying to use pdftk or Ghostscript, the tool may not be installed properly. Reinstall the tool using your Linux distribution’s package manager and verify its path.
  • 📚 Encrypted PDF Files: Some PDFs are encrypted and cannot be merged without the correct password. Use tools like qpdf to decrypt them first, provided you have the legal right and the password.
  • 📖 Compatibility Problems: Ensure the PDF versions of all files are compatible with your merging tool. Some tools may not support newer PDF features or versions. Convert your PDFs to a compatible version if necessary.
  • 🔄 Rotated or Misaligned Pages: If pages appear rotated or misaligned after merging, check the orientation settings in your tool. Use options to rotate or realign pages as needed, or adjust the source documents before merging.

What Are Some Best PDF Editors For Linux?

For merging multiple PDF files on Linux, there are several robust PDF editors and tools you can use:

  1. LibreOffice Draw – Part of the LibreOffice suite, Draw can import and combine PDFs. While primarily a vector graphics editor, it’s quite handy for basic PDF manipulation.
  2. PDF Arranger – This is a simple, user-friendly tool specifically designed for manipulating PDF documents. You can merge, split, rotate, and rearrange pages with a graphical interface.
  3. Okular – More than just a PDF viewer, Okular offers features to annotate and edit PDF documents, though for merging, it might require a combination with other command-line tools like pdftk or pdfunite.
  4. Master PDF Editor – This is a powerful, multi-functional PDF editor. Although it’s a commercial product, it offers many features such as editing, merging, and signing PDF documents.
  5. qpdf – While primarily a command-line tool, qpdf is very powerful for manipulating PDF files. It can merge PDF files, split PDFs into separate files, encrypt or decrypt, and more.

Each of these tools has its strengths, depending on your specific needs—whether you prefer a graphical interface or a command-line approach for automation.

Linux PDF Merge: Wrapping It Up

In this article, I have explored various methods to merge PDF files Linux, providing step-by-step guides for using tools like PDFtk, Ghostscript, PDF Arranger, and PDFSam Basic. These methods and tools ensure you can handle PDF merging efficiently, whether you prefer command-line or graphical interfaces.

If you found this guide helpful, I think you’ll also enjoy learning about other ways to optimize your workflow on Linux:

Frequently Asked Questions

  1. What Is pdftk?

    pdftk stands for PDF Toolkit, and it’s a versatile command-line tool used for manipulating PDF files on Linux systems. It allows you to perform various operations such as merging multiple PDF files into one, splitting a PDF into separate pages, encrypting or decrypting PDF files, rotating PDF pages, and applying watermarks. The tool is robust and widely used for scripting and automating tasks involving PDF documents, making it a valuable resource for both casual and power users looking to handle PDFs efficiently.

  2. How do I handle large PDF files when merging?

    For managing large PDF files during merging, utilize tools like Ghostscript that include file compression capabilities. This method significantly lowers the file size, making the merging process more efficient and less resource-intensive.

  3. Is it possible to merge PDF files that contain form fields without losing the data?

    Indeed, merging PDFs with form fields without losing data is feasible. Tools such as PDFSam Basic are designed to preserve form data during the merge. However, it’s wise to perform a test merge first to ensure the form data remains intact.

  4. Can I automate the PDF merging process for a folder of PDF files?

    Yes, automating the PDF merging process for multiple files within a folder is achievable through bash scripting combined with command-line utilities like pdftk or Ghostscript. This approach allows for efficient batch processing of PDF files with minimal manual intervention.

  5. How can I merge PDFs and also ensure the merged file is optimized for web viewing?

    To ensure your merged PDF is optimized for web viewing, merge the documents with your chosen tool, then use Ghostscript commands tailored for web optimization. This process compresses the PDF, enhancing its suitability for web use while maintaining a balance in quality.

Ojash

Author

Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.

Akshat

Reviewer

Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Extract Tar Files in Linux? [2 Best Methods]

Next Post

How to Create Home Directory for User Linux [10 Easy Steps]

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next