Merging PDF documents in linux



Recently I had a dillemma of sorts. I had a document that had printed to pdf…. each page to it’s own pdf. I didnt’ have time to spend figuring out how to make the document print to one multi-page pdf and so it seemed like it should be pretty easy to attach multiple pdfs into one big multi-page file. Fortunately it is fairly easy (at the linux command line). There are windows tools to do the same, but today this is a linux tip….


Essentially – ghostscript is probably the way you’re going to want to go. For one reason, most every linux system should have it either installed or available. Here’s the basic approach…. (recommended form a newsforge article.)

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=fulldocument.pdf page1.pdf page2.pdf

Now in my case, it was page1.pdf page2.pdf (you can add multiple files with multiple pages… maybe chapter1.pdf chapter2.pdf chapter3.pdf….)

gs is the main ghostscript executable, -dBATCH tells it to quit once we’ve processed the files, -dNOPAUSE keeps it from waiting for user interaction, -q makes it run without much in the way of messages on the screen (quiet), -sDEVICE=pdfwrite tells ghostscript to use it’s own pdfwriter and of course, -sOutputFile=fulldocument.pdf is the file you want to “lump” everything into…

Thanks to this article for a point in the write direction….

There are other ways to go about it. Many tools are out to make it an easier task to combine pdf’s into one big file, but that got me from point a to b.

   Send article as PDF   

Similar Posts