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: 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 →

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

$ sudo apt-get install imagemagick

Convert Multiple PDF Files Into One

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

$ convert FILE1.pdf FILE2.pdf OUTPUT.pdf

Merge Specific Pages Into One PDF File

Note: The count of the pages starts from zero.

It is also possible to convert specific PDF pages into a single PDF file.

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:

$ convert FILE1.pdf[1] FILE2.pdf[0,5] OUTPUT.pdf

Join Ranges of Pages Into Single PDF File

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

Cool Tip: Are you real Linux Geek? Download YouTube videos from the command line! Read more →

Join the first ten pages from first file FILE1.pdf with the first five pages from the second file FILE2.pdf and save the result to the new OUTPUT.pdf file:

$ convert FILE1.pdf[0-9] FILE2.pdf[0-4] OUTPUT.pdf

2 Replies to “HowTo: Merge PDF Files – Linux Command Line”

  1. $ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
    1. Ghostscript гораздо качественней преобразовывает файлы — без сжатия и артефактов в изображениях

Leave a Reply