Combine multiple PDFs into one file in Linux

Merged PDF image
Previously I posted how to merge multiple PDFs into one file in Windows. This is the Linux counterpart tutorial on how to combine multiple PDFs into one file. This process is really easy and quick and is extremely useful.

The first step is to install Ghostscript. You can do this by typing the following command into a terminal:
sudo apt-get install gs

The second step is to install PDFTK. You can do this by typing the following command into a terminal:
sudo apt-get install pdftk

The last step is to actually combine your PDF files into one file. You can do this by copying and pasting the following command into a terminal:

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=firstANDsecond.pdf -dBATCH first.pdf second.pdf third.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 “first.pdf second.pdf third.pdf” to whatever your file names are (separate your file names with a space).
After you run the above command, a new PDF will be created with your individual files merged according to the order you list (i.e., first.pdf followed by second.pdf followed by third.pdf).

Trackbacks & Pings

Comments

  1. My scanner software required an upgrade ($$) in order to be able to put multiple pages into one pdf file. Saved me some cash.
    Thanks

  2. I think you have a rather long command there. According to the pdftk man page:

    Join in1.pdf and in2.pdf into a new PDF, out1.pdf
    pdftk in1.pdf in2.pdf cat output out1.pdf
    or (using handles):
    pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
    or (using wildcards):
    pdftk *.pdf cat output combined.pdf

    Remove ’page 13’ from in1.pdf to create out1.pdf
    pdftk in.pdf cat 1-12 14-end output out1.pdf
    or:
    pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

  3. Thank you.
    I used pdftk *.pdf cat output combined.pdf
    to create a single pdf from 160 individual pages.
    I had to renumber and re-pad the number sequence. I did not see how to do that in Linux so I went to WinDoz and used Ulead which did it nicely.
    Thanks again for the suggestion of pdftk.

  4. But in linux, you don’t need to use ghostcript. pdftk will do the job all by itself.

    pdftk file1.pdf file2.pdf file3.pdf cat output combined.pdf

    or

    pdftk *.pdf cat output wholedir.pdf

    See http://www.accesspdf.com/pdftk/ for the easy way to do this

  5. If you need to merge multiple PDFs there is only one way to do it, which is of course Acrobat Pro.

    pdftk shouldn’t really be considered as an option for anyone, unless one plans on figuring out the vagaries behind “Failed to read *.pdf”

    Dont waste your time

Post a Comment


Your email is never published nor shared. Required fields are marked *



© 2006-2007 Maxim Software Corp.  All rights reserved.