24 gennaio 2009

Join / Merge pdf files in Linux

Linux does a lot of things out-of-the-box, just like a Mac. Essentially, unlike a Mac, Linux isn't boxed, and viceversa does a lot of things more than a Mac. It just lacks the sheer semplicity of Mac.

To join pdf use GhostScript. I tried successfully on my Ubuntu 8.10 machine.

(citation from

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

Unless you're very familiar with Ghostscript, that string of commands won't mean much to you. Here's a quick breakdown:

  • gs -- starts the Ghostscript program
  • -dBATCH -- once Ghostscript processes the PDF files, it should exit. If you don't include this option, Ghostscript will just keep running
  • -dNOPAUSE -- forces Ghostscript to process each page without pausing for user interaction
  • -q -- stops Ghostscript from displaying messages while it works
  • -sDEVICE=pdfwrite -- tells Ghostscript to use its built-in PDF writer to process the files
  • -sOutputFile=finished.pdf -- tells Ghostscript to save the combined PDF file with the name that you specified
Obviously the operation is not limited to two files. I merged 12 files in a matter of seconds with a single command line. Yes, it supports wildcards.

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf *.pdf

3 commenti:

Mandrulo ha detto...

I know I'm being an asshole, but I have to point out that Mac OS X DOES have the means to join/merge PDFs, natively (at least from 10.4 on). And of course it's MUCH MORE user-friendly than using command lines. You can also choose WHICH pages you want to transfer to the other PDF and WHERE to put them (at the beginning, in the middle, at the end of the other PDF). Cool, huh?
Here it's how:
1. Open two PDFs in Preview. Make sure that the two sidebars are open, and that they show the PDF pages' miniatures.
2. In one PDF, choose the miniatures of the pages you want to transfer.
3. Drag and drop them to the sidebar of the other PDF, in the position you desire.
4. Done.
This was taken from here:

Probably, you can also use Automator and/or Terminal to obtain the same results. But I have no idea whatsoever of how to use these.


pbsl ha detto...

you have a nice site. thanks for sharing this enormous resources. keep it up. anyway, various kinds of ebooks are available here

city ha detto...

thanks for share.