How to merge pdf in linux

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

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

Читайте также:  Навигация для навигатора windows ce

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.

Источник

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 In Command Line On Linux

We already have covered how to split or extract particular pages from a PDF file in Linux using pdftk utility a while ago. That tutorial described how to extract a page range or a part of a PDF file in Linux. Today, we will see how to merge two or more PDF files using PDFtk and Poppler applications in Linux.

First, we will discuss how to combine PDF files or merge PDF files from commandline using Pdftk tool.

1. Merge PDF Files In Command Line On Linux Using pdftk

PDFtk is free graphical tool that can be used to split or merge PDF files . It is available as free and paid versions. You can use it either in CLI or GUI mode.

PDFtk is available in the default repositories of most Linux distributions. Let us install pdftk.

Install PDFtk in Arch LInux and derivatives:

PDFtk is available in the AUR. You can install it using any AUR helper programs such as Paru or Yay.

Install PDFtk In Debian, Ubuntu and derivatives:

Install PDFtk On CentOS, Fedora, Red Hat:

First, Install EPEL repository:

Then install PDFtk application using command:

Now, let us merge some pdf files and made it a single file.

I have three pdf files named file1.pdf , file2.pdf , and file3.pdf in my current working directory. I want to merge them into a single file called outputfile.pdf .

To merge the above three PDF files into one, run the following command from the Terminal:

Alternatively, you can use wildcards to merge all files that has .pdf extension and merge into one file like below:

Читайте также:  Восстановить windows вчерашнего дня

This command will merge all pdf files in the current directory into a single file.

2. Merge PDF Files In Command Line On Linux Using Poppler

Poppler is a PDF rendering library based on the xpdf-3.0 code base.

To install Poppler on Arch Linux based distributions, run:

On Debian, Ubuntu, Linux Mint:

On RHEL, CentOS, Fedora:

Once Poppler installed, run the following command to merge the pdf files in the current working directory.

The above command will merge file1.pdf, fiel2.pdf and file3.pdf files into a single file called outputfile.pdf.

Conclusion

You know now how to split a pdf file into many parts and how to merge many PDF files into a single file using PDFtk and Poppler tools in Linux. As you can see in this guide, combining or merging PDF files in Linux is not that difficult. You can do this in couple minutes.

Источник

How to merge many PDF files into a single one? [duplicate]

I have 16 pdfs that I want to convert into a single one. I am on Ubuntu 10.10, how can I do it?

5 Answers 5

Now, as shown on example page, use

for merging pdf files into one.

You can also use Ghostscript to merge different PDFs. You can even use it to merge a mix of PDFs, PostScript (PS) and EPS into one single output PDF file:

However, I agree with other answers: for your use case of merging PDF file types only, pdftk may be the best (and certainly fastest) option.

Update:
If processing time is not the main concern, but if the main concern is file size (or a fine-grained control over certain features of the output file), then the Ghostscript way certainly offers more power to you. To highlight a few of the differences:

  • Ghostscript can ‘consolidate’ the fonts of the input files which leads to a smaller file size of the output. It also can re-sample images, or scale all pages to a different size, or achieve a controlled color conversion from RGB to CMYK (or vice versa) should you need this (but that will require more CLI options than outlined in above command).
  • pdftk will just concatenate each file, and will not convert any colors. If each of your 16 input PDFs contains 5 subsetted fonts, the resulting output will contain 80 subsetted fonts. The resulting PDF’s size is (nearly exactly) the sum of the input file bytes.

Источник

Edit PDF in Linux (split, merge, extract, rotate)

The PDF format serves to distribute documents in a universal format that can be viewed correctly in all operating systems. It is one of the most popular formats but a few users know how to edit PDF in Linux. Below you will learn how to merge, split, rotate pages in a PDF file in Linux. I will show how to do it using a very user-friendly graphical program.

INTRODUCTION

PDF formats are indeed very popular. Even web browsers incorporate a PDF reader to make it easier to open PDF documents. The problem is however not with how to open PDFs but rather how to edit them. For example, even doing a simple thing like splitting PDF pages into several files can look impossible for new users. However, there is an application that helps with that task and beyond.

This program is called PDFsam and it is available in three different versions.

  • PDFsam Basic provides the basic editing options of a PDF such as split, merge or rotate. It is usually available in all Linux distributions in the default repositories.
  • PDFsam Enhanced comes with some additional features such as PDF review, OCR, sign etc. Unfortunately, this version is available for Windows only.
  • PDFsam Visual includes some premium options such as visual compositing, reordering, splitting, merging, rotation, and cropping of PDF files. It is available for Linux but requires a paid license.

So, in this tutorial, I will use the free PDFsam basic version.

VIDEO TUTORIAL

Install PDFsam Basic

As I have mentioned earlier, you can install PDFsam form the repository of your Linux distribution and edit PDF in Linux right away. But to have all the latest features and fewer bugs, I recommend installing the latest stable version from the official website.

Читайте также:  Quantum espresso windows установка

First, you need to download PDFsam Basic from its website. In this case, download the corresponding .deb file for distributions such as Debian, Ubuntu, or Linux Mint.

Then, open your file browser and go to the Downloads folder. Next, open a terminal in the Downloads folder with the right mouse click (select the Open in terminal option) and install the package with the dpkg command.

Of course, you can install this deb package using the software manager, but it is more reliable to use the terminal. The terminal output has more information and it will show if any errors occurred during the installation

As you can see in the image above, the installation was without any error. I hope you get the same result.

PDFsam Basic interface

To edit PDF in Linux, open PDFsam from the menu of your distribution and you will see this interface.

It is a nice-looking program with all its functionality presented in this dashboard window:

  • Split a PDF file into more parts.
  • Merge several PDF documents.
  • Mix PDF pages.
  • Rotate PDF pages.
  • Split PDF documents by bookmarks.
  • Extract specific pages from a PDF.
  • Finally, split PDFs based on size.

At the bottom, you can see the premium features that are available in PDFsam Visual. These features require a license as I explained above.

In my personal experience, the Split and Merge options are the most used. So, I will quickly show you those two.

Edit PDF in Linux with PDFsam

Split a PDF file

To split a file in PDFsam Basic, you select the split option on the main window and the following screen will be displayed.

As you can see, the interface is very intuitive. At the top, you have to upload the PDF file to Split by clicking on the Browse button.

Once you have chosen the PDF file you are going to work with, at the top of the screen, you will be able to see how many pages it has. Next, you define the Split settings. You can split by every page or the even pages.

Also, you can split after a specific page or split after a specific number of pages. For example, every 5 pages.

Finally, you define the folder where the new files will be output. You can also add a name prefix to the output files. Then, click on the Run button.

Once the process is complete, open the folder where you chose to output the files and you will see the spitted files with page numbers and defined prefix in their names.

As you can see, it is very simple to split a PDF file using PDFsam. I can also say it is very fast.

Merge a PDF file

The second most used option when editing PDFs in Linux is to merge two or more files.

Here, you add the files to be merged. You can do this by dragging your files from the file browser or by using the Add button.

One thing to keep in mind is that you can move files in this window to define the order in which they are going to be merged. You can do this by selecting the file and clicking on move up or move down buttons in the top bar.

Also, in the options section, you can configure the way the process is going to be done. It usually works well with the default settings.

Finally, click on the Run button and the files will be merged.

After that, you will see the resulting merge file in your file browser.

PDFsam also has other options which are as simple to use as split and merge. Please, try them yourself.

Conclusion

PDF files are useful for distributing documents that are visible on any device on any operating system. PDFsam makes editing PDF in Linux easy, simple and quick.

If you know of other better tools, let me know in the comments.

I believe you will also find useful my post about Firefox smooth scrolling.

Источник

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