home | tech | misc | code | bookmarks (broken) | contact | README

Ghostscript notes

Using Ghostscript to manipulate PDF files

Join PDF files with just a simple command, according to this page:

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

To generate a file with a subset of its pages, use gs as well:

$ gs -dBATCH -dSAFER -dNOPAUSE -dFirstPage=5 -dLastPage=10 -sDEVICE=pdfwrite -o output.pdf input.pdf

To compress a PDF (resizing the file size):

$ gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dCompatibilityLevel=1.4 -sOutputFile=output.pdf input.pdf

Settings can be /screen, /ebook, /printer and /prepress, ranging from low quality images resolution to better quality. I like to use /ebook. I could turn a 8 MB PDF into a 276 KB file suitable to be sent to e-mail.

Thanks to this page for this tip.