Tuesday, May 26, 2015

Ghostscript

Ghostscript is awesome. It's available on command line, it comes with Mac OS X by default, and it allows a nice range of PDF manipulations. I'd already written a post where PDF documents are joined together into a single one (See PDF Merge). Now for a slight upgrade, here's a way to grab only certain pages from a document:

gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
       -dFirstPage=22 -dLastPage=36 \
       -sOutputFile=outfile.pdf inputfile.pdf

This script will take pages 22-36 from inputfile.pdf and save them into the new file outfile.pdf. Together with PDF merging, this little technique allows us to mix and match PDF pages into new documents as we best see fit.

My thanks to this site for the great tip!

No comments:

Post a Comment