Thursday, November 18, 2010

Merging / putting together pdf files using ghostscript / gs on linux

------------------------- update : 04/16/2011 --------------------
install the pdftk package and use the following command
pdftk *.pdf cat output onelargepdfile.pdf

------------------------------------ original -----------------------------

Have always needed to stitch pdf files one after the other to make a big pdf file.

Searched online and came up with this solution which uses ghostscript / gs

To use Ghostscript to combine PDF files, type something like the following:

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


No comments: