Combine multiple PDFs into one file in Ubuntu Linux

Sponsored Link
It is very useful to combine multiple PDF documents into one file. This is useful especially if you accumulate many PDFs (newsletters, bills, etc.) over time.

Preparing Your system

sudo apt-get install gs pdftk

Now we will see one example how to combine pdf files let us assume we have 1.pdf,2.pdf,3.pdf files and now we need to cobmine this files using the following command

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 1.pdf 2.pdf 3.pdf

In the above command after “-sOUTPUTFILE=” type whatever name you want for the merged file (don’t forget to append .pdf to the end of the file name). Rename “1.pdf 2.pdf 3.pdf” to whatever your file names are (separate your file names with a space).

After you run the above command, a new PDF file called combinedpdf.pdf will be created with your individual files merged according to the order you list.

If you want to know more options available for gs command check man page

You may also like...

9 Responses

  1. tami says:

    Thank you for the useful and well-written Howto! This is exactly what I was looking for lately. Have a wonderful year (full of new, fantastic ideas) – best friendly regards – tami (running actually pure Debian 😉

  2. James says:

    Actually, with pdftk installed, you need only enter the command:

    pdftk 1.pdf 2.pdf cat output combined.pdf

    and pdftk does all the magic.

  3. UCLALinux says:

    if you replace “-dBATCH 1.pdf 2.pdf 3.pdf” with “-dBATCH `ls`” it will combine all the PDF’s in a file into one file for you.

  4. Vasile Braileanu says:

    This will combine all pdf’s in current directory.
    pdftk `ls *.pdf` cat output combined.pdf

    Many thanks for posting this.

  5. Vlad says:

    You don’t need to install pdftk. gs is enough.

  6. Mike says:

    Thanks for this post and all the comments. I’m using Ubuntu Lucid, and used Synaptic Package Manager, and found the following:

    * Apparently, “gs” is now spelled out as “ghostscript”, and gs is now a “transitional” package.

    * The pdftk package is in the repository, so I just clicked to select for installation.

    * There’s now a program called “PDF Chain”, which came up in my repository search. The description said, “PDF Chain is a Graphical User Interface for the PDF Tool Kit, released under the terms of the GNU Public License verion 3.” So I installed this as well. It ended up under “Applications -> Office”. I opened it, clicked the “plus” button, selected my pdf files from the file browser, then entered the output file name. It worked perfectly. It’s totally awesome, especially given that it’s v0.123 “alpha”. Their site is http://pdfchain.sourceforge.net/.

    Regards,
    Mike

  7. fiona says:

    Thank you for sharing the nifty trick!It’s good and relatively simple.
    But I am a programming command idiocy, I just use a tool to combine two PDF files into one. I just import my files then select an existing merge method, that’s all.

  8. Tapas Mishra says:

    There is a simple program known as pdfedit for the same.With GUI it is a lot easier.

  9. Martin says:

    Thanks. I love working with linux. Its tools are a Swiss Army Knife when it comes to batch document processing…

Leave a Reply

Your email address will not be published.