Skip to content

Instantly share code, notes, and snippets.

@tnibert
Last active March 3, 2020 03:06
Show Gist options
  • Save tnibert/aac22948e18367af4ad509c01c79c36f to your computer and use it in GitHub Desktop.
Save tnibert/aac22948e18367af4ad509c01c79c36f to your computer and use it in GitHub Desktop.
PDF shell manipulations
# this is a work in progress notepad, will include pdftk and ghostscript stuff
# replace page 13 of doc1.pdf with doc2.pdf
pdftk A=doc1.pdf B=doc2.pdf cat A1-12 B1 A14-end output out1.pdf
# remove the first 4 pages from in.pdf
pdftk A=in.pdf cat A5-end output out.pdf
# use ghostscript to combine PDFs
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dAutoRotatePages=/None -sOutputFile=finished.pdf file1.pdf file2.pdf file3.pdf
# use ghostscript to split a PDF by page
# only works with gs version 9.06+
gs -sDEVICE=pdfwrite -dSAFER -o outname.%d.pdf input.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment