Merge multiple PDFs into one file

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).
Related Stories
POSTED IN: How To
8 opinions for Merge multiple PDFs into one file
sbt
Jan 30, 2007 at 9:22 pm
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
Mar 26, 2007 at 6:40 am
Only calling ‘gs’ shouldn’t require ‘PDFtk’. That’s just another tool doing a pdf merge.
mike
Mar 28, 2007 at 1:25 pm
thanks, this helped us in a pinch.
如何合并多个 PDF 文档 | LinuxDig
May 1, 2008 at 2:38 am
[…] New Linux User, […]
ubuntero
May 19, 2008 at 12:28 pm
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
May 24, 2008 at 5:40 am
Thank you very much for the great info!!
It worked perfectly.
how to combine pdf files
May 29, 2008 at 5:40 pm
[…] use of Adobe Professional. However, this can be done in Linux very easily and of course, for free.http://www.newlinuxuser.com/merge-multiple-pdfs-into-one-file/Business PDF Writer, PDF Form Filler, PDF Page Number, PDF Split …Split pdf file into multiple […]
Juntando vários PDFs em um só | Israel Junior
Jun 2, 2008 at 5:23 pm
[…] isso com o Ghostscript. Como a memória anda fraca nesses dias consultei o oráculo Google, que me respondeu: $ gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=saida.pdf -dBATCH entrada1.pdf […]
Have an opinion? Leave a comment: