Merge multiple PDFs into one file

Posted in Technology
Sat, Jan 27 - 8:49 am EDT | 10 years ago by
Comments: 31
Be Sociable, Share!
    Use Arrow Keys (← →) to Browse

    Merged PDFs
    For years I never knew how to combine multiple PDFs into one PDF file without the use of Adobe Professional. However, this can be done and can be done in Linux very very easily and of course, for free.

    This process requires you to install two packages: Ghostscript and PDFtk. These packages are widely available in the repositories of your distro of choice. If you are going to install them using apt, use the following commands:

    apt-get install gs

    apt-get install pdftk

    Alternatively, if you would rather download the packages and install them yourself, here are the links to the download pages:

    Link: Ghostscript download
    Link: PDFtk download

    Now, open a terminal and copy and paste the following command:

    gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf

    Change the name of first.pdf and second.pdf to the PDF files that you would like to merge, and change the name of firstANDsecond.pdf to the name you would like to name your merged pdf file. If you haven’t changed directories, the merged document will be created in your home directory.

    This command allows you to merge more than just two documents. If you would like to merge three or more PDF files, continue to append the file names to the above command (separated by a space).

    Use Arrow Keys (← →) to Browse

    Be Sociable, Share!

      Related Posts

      • sbt

        pdfcreator is a pseudo printer that has a “wait” button. after collecting various files into the list, merge from the list of files “printed” from various apps.

      • db

        Only calling ‘gs’ shouldn’t require ‘PDFtk’. That’s just another tool doing a pdf merge.

      • mike

        thanks, this helped us in a pinch.

      • Pingback: 如何合并多个 PDF 文档 | LinuxDig

      • ubuntero

        and only calling pdftk woudln’t require gs.
        IMO pdftk is easier to use because it was it was created for.
        actually. why do you ask people to install pdftk if you are not telling them how to use it?

        pdftk first.pdf second.pdf cat output firstANDsecond.pdf

      • Vivek Thomas

        Thank you very much for the great info!!

        It worked perfectly.

      • Pingback: how to combine pdf files

      • Pingback: Juntando vários PDFs em um só | Israel Junior

      • Markus

        To me the gs command was the better option, it produces a smaller PDF in the end, however it took much longer (but this was only a one time operation, so I like the smaller file size better):
        gs 8MB and 5 min
        PDFtk 12MB and 20 sec.
        PS: I merged 10 PDF files

      • Felipe Web User

        There are only minor issues while using gs to merge the pdf files:

        I am having trouble with the unicode characters, whenever I open the resulting (merged) pdf file, I do get :

        Error: Illegal entry in bfrange block in ToUnicode CMap

        repeated an infinite number of times, until the pdf file is closed.

        Anyone experiencing this.? How to fix it ?

      • Pingback: b.l.o.g. » Blog Archive » Bookmarks for November 6th

      • Gunnsteinn Hall

        You can also do this without installing or paying anything using an online tool:

        The url is:

      • Tom

        Great info!! Ghostscript worked for me under Cygwin running on my Windows box!!

      • yanger

        this kinda doesn’t work on pdf grayscale images… when i merged a few images together, the images got “inversed” black on white, white on black.. odd…

      • bronson

        I wrote a shell script that uses this technique to merge a directory tree full of PDFs with bookmarks to the joined files. I use it to assemble 900 chapters into one 6000 page book.

        Hope someone else finds it useful.

      • Pingback: Merge PDFs no Linux « Lembra’s Blog

      • Clair Ching

        That’s great! Thanks for sharing the script, @bronson!

      • Pingback: Mehrere .pdf-Dateien unter Linux zusammenfügen « 23Quadrat

      • VS

        It is nice , but in the result PDF another font is used not mine. :(
        Any hints what is wrong ?

      • Andy

        @VS That usually happens if you don’t embed or outline your fonts. It looks for a local version of the font, and after not finding it, substitutes.

      • Moises

        Thanks a lot for the information, worked great for me to join to pdf files that I needed urgently…

      • omabil

        This is exactly the command I was looking for.
        Thanks a lot,

      • Alex

        THANK YOU!! I was looking for this for ages!

      • Solartraveler

        Thanks, that worked (merging 15 pdfs for easy searching)

      • Lee

        gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combined.pdf -dBATCH *.PDF

        works fine to save typing all those file names – just cd to the right folder first and then away you go…

      • Pingback: Juntando PDF no Linux - Manoel Campos Blog

      • Poorna

        In case u have hundred individual files named as in1, in2, in3,…..in100 then use this command

        gs -q -sPAPERSIZE=letter -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in[1-100].pdf

        IT WORKS :)

      • exactt

        also check out if you aren’t very fond of the command-line…

      • Robert

        Well I used gs and pdftk to merge 91 pdf-files. Went well, too. Problem is every odd page is only half the size of the even numbered pages allthough the originals only differ very little in size ._.

        help please!

      • Paul

        I am not very good when it comes to these things. I just stick to other free tools I can find. Like PDFen. Just a site ( ) that I use to merge everything, from pdf to outlook mail to open document files.

      • Clair Ching

        That is odd, indeed!

      Be Sociable, Share!