
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).










Previous Post
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!
also check out http://sourceforge.net/projects/pdfshuffler/ if you aren’t very fond of the command-line…
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 :)
828 days ago
[...] Decio Blog e Every Joe. VN:F [1.8.1_1037]por favor, aguarde…Rating: 0.0/10 (0 votes cast)VN:F [1.8.1_1037]Rating: 0 [...]
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…
Thanks, that worked (merging 15 pdfs for easy searching)
THANK YOU!! I was looking for this for ages!
This is exactly the command I was looking for.
Thanks a lot,
Thanks a lot for the information, worked great for me to join to pdf files that I needed urgently…
It is nice , but in the result PDF another font is used not mine. :(
Any hints what is wrong ?
1031 days ago
[...] [via everyjoe.com] [...]
1115 days ago
[...] http://www.everyjoe.com/newlinuxuser/merge-multiple-pdfs-into-one-file/ [...]
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.
http://github.com/bronson/pdfdir
Hope someone else finds it useful.
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…
Great info!! Ghostscript worked for me under Cygwin running on my Windows box!!
You can also do this without installing or paying anything using an online tool:
The url is: http://www.MergePDF.net
1280 days ago
[...] Merge multiple PDFs into one file – Use ghostscript and pdftk to merge multiple pdfs into one. [...]
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 ?
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.
Markus
PS: I merged 10 PDF files
1437 days ago
[...] 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 [...]