Place Holder Projects Code
Bash MySQL JavaScript MySQL Quick Reference
Notes Documents Return of the Fed Login

Extract specific section of a PDF with Ghostscript

It may sometimes be helpful to be able to quickly split a single PDF, and we can do this by selecting and saving specific portions of a larger PDF.  We can use Ghostscript.

gs -dBATCH -dNOPAUSE -q -dPDFSETTINGS=/prepress -sOutputFile=extracted.pdf -dFirstPage=1 -dLastPage=2 -sDEVICE=pdfwrite <input_file.pdf>

We also take advantage of the dPDFSETTINGS=/prepress optimization which significantly reduces the size of the output file.

The first page in the document is 1, not 0.