Linux merge pdf files

HowTo: Merge PDF Files – Linux Command Line

Sometimes it is required to merge several PDF files into a one PDF file.

In Linux we can easily join multiple PDF files using the command line utility called convert that is a part of ImageMagick software suite.

From this article you will learn how to merge entire PDF files into one PDF file or how to join specific PDF pages only into a single PDF file.

Cool Tip: Merge PDF files in Linux using the ghostscript command! Read more →

First of all it is required to install the ImageMagick suite that provides the convert utility:

Convert Multiple PDF Files Into One

Merge two PDF files FILE1.pdf and FILE2.pdf into the new OUTPUT.pdf file:

Merge Specific Pages Into One PDF File

Note: The count of the pages starts from zero.

For this we will pass our filenames with the required page numbers in the square brackets to the convert command.

Merge the second page from the first file FILE1.pdf with the first and the sixth pages from the second file FILE2.pdf and save the result to the new OUTPUT.pdf file:

Join Ranges of Pages Into Single PDF File

And of course it is possible to join some ranges of pages.

Cool Tip: Plan to send this PDF somewhere or just keep? How about to protect it with a password? This is really easy for ones who merge PDF files from the command line! Read more →

Источник

How to Merge PDF Files on Linux

Sometimes, you may have 2 or more PDF files that you need to combine or merge into one so that you can have everything in one place. This will minimize time wasted trying to look for your PDF files which may be in different folders and other directories.

Recently I have tested a few tools to merge pdf files on Linux that I will introduce to you today. I have tested all the tools on the Ubuntu 18.04 version.

1) Using pdfunite

Pdfunite is a handy tool that can be used for merging to or more PDF documents. It is part of poppler-utils package, so when you install poppler utils, you end up with pdfunite.

To install pdfunite, we’ll install the poppler-utils package as shown

Sample Output

Next. update the system

In the downloads folder, I have 2 PDF documents

We are going to merge them using pdfunite command.

To merge the PDF documents, the syntax will be as shown

Using our files as shown earlier, the command will be

You will get the following warning in the output, but don’t worry. The files have already been merged.

As you can see, the output file merged_output.pdf has been created

Note: Files to be merged need to be in the same directory where pdfunife is executed

2) Using pdftk tool

Pdftk is yet another tool that can be used to merge PDF documents in Ubuntu 18.04. To install pdftk on terminal in Ubuntu 18.04, first add the pdftk repository

Читайте также:  Неудачное обновление windows 10 как откатить

Output

Next, update your Ubuntu System

After successfully updating your system, install the pdftk tool as shown below

After the installation of pdftk is complete, you can now invoke the pdftk command to merge files. The syntax is as shown

using our earlier files, the command will be as shown

3) Using Convert tool

To use the convert command, first install it on terminal using the command below

Output

Upon successful installation, you can now merge your documents.

The syntax for merging 2 PDF files is as shown

Using our files , the command will be

Output

To Merge specific PDF pages into a single PDF file, you’ll need to pass our files with specific page numbers in square brackets to the convert command. For example to merge the 5th page from the first document with 7th and 10th pages in the second document, the syntax will be

Using our files , the command will be

Output

And Yes, it’s very possible to join page ranges.

For Example, you can join the first 5 pages from first file with first 10 pages from the other file. The syntax for this case will be

Using our files , the command will be

4) Using Ghostscript

We can also use ghostscript (gs) to merge PDf documents in Ubuntu 18.04
apt install ghostscript

Example of using ghostscript to merge 2 PDF documents

In the above example, let’s expound further on the attributes

Using our documents earlier, the command will be

Sample Output

5) Using pdfsam

Pdfsam is a simple, intuitive and easy to use GUI tool that is used to merge, split, rotate, edit and sign PDF documents. In this example, we are going to use the tool to merge PDF documents in Ubuntu 18.04. But first, let’s install it

After successful installation, define the JAVA_HOME variable in /etc/environment path using your favorite editor.

Append the following line.

reload the file

Next, download the Debian package file from pdfsam’s official site

Once downloaded, install the deb file using the dpkg command as shown.

Sample Output

To start pdfsam, run

To merge documents, click on ‘Merge’ and drag and drop the files to be merged in the section provided.

Feel free to specify other attributes in the ‘Merge Settings‘ section and once done click on the ‘Run‘ icon located at the bottom. Once done, you’ll hear a ‘ding’ sound notifying you that the merging process is complete.

As seen in the above examples, merging PDF files on Linux is very easy and straight forward on the terminal. Give it a try and let us know how it went. Your Feedback is much welcome in our comment section. Thank you and feel free to share this tutorial on your social handles.

Источник

How to Combine PDF Files on Windows and Linux

You have probably received PDF files before and may have many PDF documents stored in your computer. Deleting them is not an option, and backing them up may take up a lot of storage space. One solution is to combine/merge multiple PDF files into a single PDF so that it is easier to manage, access, and back up. PDFtk Server is a command line tool that allows you to easily combine multiple PDF files into one.

How PDFtk Works

PDFtk stands for “PDF Toolkit.” PDFtk Server allows you to merge PDF documents, split PDF pages into new documents, rotate PDF pages, decrypt and encrypt, update metadata, apply watermarks, and much more. It is free, open source software available for Windows, Linux, and macOS. Best of all, it does not require Acrobat or any other Adobe products to work.

Note: there is also a PDFtk Free, applicable only for Windows. It’s a graphical interface that allows you to add multiple PDF files and merge them into one.

Читайте также:  Как ставить windows с образа

How to Install PDFtk on Linux

For Linux (using Ubuntu), you can install it with the command:

PDFtk is also available in most repositories, so you can easily install it from your package manager/software center.

Using PDFtk to Combine Multiple PDFs

1. Once you have PDFtk installed, you will need to run it from the command line, so start the terminal.

2. Change to the directory containing your PDF files:

3. Decide in which order you want the PDF files to appear in the final document. You will use that order when typing the command line string.

4. Type the following string, listing your PDF files in the order you want them to appear:

That is all it takes. Be sure to check the new PDF file to be sure all of the new pages display correctly. The merging process is seamless, painless, and should work on any regular PDF files you have.

To combine multiple documents in a directory without listing each one, use wildcards (*):

How to Split, Encrypt, and Decrypt PDFs Using PDFtk

As an added bonus, PDFtk can perform many other tasks. For example, to split a PDF file’s pages into multiple documents, run the following command:

This will split the document into single pages that you can then manipulate as you see fit.

With PDFtk, you can even merge certain pages from multiple documents into one new document. Just enter the following command:

In this case, “A” and “B” are used as “handles” for the names of your documents. You can use as many as you need.

To encrypt your new PDF file, use the following command:

where “foopass” is the password you use to encrypt the file. Change to a more secure password for your own usage.

On the other hand, if you have an encrypted PDF file, you can also decrypt it with PDFtk:

This only touches the surface of the many functions of PDF manipulation available with pdftk. You can use pdftk —help or access their online examples to get a good overview of the command.

If you are not using Linux, make sure you check out how to extract pages from PDF in macOS and save as PDF files in Windows 10.

Using PDFtk Free on Windows

While you can use the command line version of PDFtk on Windows, PDFtk Free offers an easier-to-use graphical interface. The great part is that both PDFtk Server and PDFtk Free come together in a single installation, so you get both. Feel free to use either option. The following instructions, though, apply to PDFtk Free.

The free version doesn’t have quite as many features but does still merge PDFs together. The premium upgrade is just $3.99 if you want to switch.

Press “Add PDF” to add the PDF files you want to merge. Files are added to the list in the order you select them, but you don’t need to worry about the order right now.

Once added, simply drag and drop the files to create the order you want. You can also double-click the “Pages to Copy” field to select any pages you want to copy in your merged PDF. Use the “Copy Selection” and “Remove Selection” buttons to copy a selection to add it twice or remove a selection.

When you’re ready, press “Create PDF” at the bottom of the window. You can also choose to open the newly created PDF or show the location of the PDF in the “Afterwards” drop-down menu.

Using PDF Arranger to Merge PDF Files on Linux and Windows

If you find PDFtk too complicated for you, another application you can use to merge PDF files is PDF Arranger.

Читайте также:  Ошибка 0x00000019 windows как исправить

PDF Arranger is a fork of the old pdfshuffler and it is a small python-gtk application which allows the user to merge or split PDF documents and rotate, crop and rearrange their pages using a simple graphical interface.

You can install PDF Arranger from the Software Center or your package manager. For Windows, you can download the msi installer here.

1. Once installed, open PDF Arranger.

2. Click the “Open a file” icon. Select the PDF files you want to combine.

3. From here, you can drag to arrange the PDF pages. You can also delete pages from the file or even rotate and crop.

4. Once you are done, save it to a new file.

Beyond Merging PDFs

Merging PDFs is great and all, but there’s so much more PDFtk is capable of. Naturally, PDFtk Free is limited, but one thing you can still do in both PDFtk Server and PDFtk Free is split PDFs.

1. For PDFtk Free, select the PDF you want to split.

2. Double-click the “Pages to Copy” field.

3. Select the page numbers or range for the first section you want to split. You can save the split portion using a new name to avoid replacing the original PDF.

4. Repeat the process to split the file into multiple parts.

For Linux, you’ll need to remove pages from the output file. You can remove as many pages as you need. Use the following as an example:

Other things you can do with PDFtk Free include:

  • Rotate (premium only)
  • Add stamps or watermarks (premium only)
  • Encrypt documents (premium only)

Other things you can do with PDFtk Server (both Linux and Windows) include:

  • Rotate pages
  • Encrypt and decrypt pages
  • Fill out PDF forms
  • Add stamps and watermarks
  • Repair corrupted files (not always possible butdoes recover the file if possible)
  • Add PDF bookmarks and metadata
  • Break a PDF into single pages
  • Unpack attachments
  • Attach files to PDF documents

As you can see, this seemingly simple tool can do so much more than merge PDF files. Once you get the hang of the commands, it’s a great all-in-one PDF utility.

Frequently Asked Questions

1. How can I make using the command-line version of PDFtk easier on Windows?

The most difficult part is typing the entire file path name. Open the GUI version, add your files to it, then drag and drop them into the command prompt one at a time to copy the file path over.

2. What PDFtk commands are available?

While command-line examples have been linked above, the PDFtk Server Manual gives you a more comprehensive look at the various commands to work with all the features available.

3. Is PDFtk Really Free?

Yes, but there are premium options available. You can buy PDFtk Pro for the full GUI version, but that’s not necessary to merge or split PDFs.

Also, if you need commercial support for use in a business, you can purchase a one-year service agreement for $79/year.

Wrapping Up

If you’re tired of trying to organize related PDFs in folders, just use PDFtk to merge PDF files. There’s ample documentation and tutorials at PDF Labs to help you learn how the command line tools work. Alternatively, you can also use PDF Arranger if you prefer to deal with a graphical interface. You can also learn how to combine scanned documents on macOS and convert a PDF to a Microsoft Word document.

Crystal Crowder has spent over 15 years working in the tech industry, first as an IT technician and then as a writer. She works to help teach others how to get the most from their devices, systems, and apps. She stays on top of the latest trends and is always finding solutions to common tech problems.

Источник

Оцените статью