Skip to content

Instantly share code, notes, and snippets.

@tenomoto
Created December 8, 2015 08:37
Show Gist options
  • Save tenomoto/56e1e62419087e322cf9 to your computer and use it in GitHub Desktop.
Save tenomoto/56e1e62419087e322cf9 to your computer and use it in GitHub Desktop.
Extract pages from PDF and save them to separate files
#!/bin/sh
FNAME=$1
shift
for PAGE in $@; do
gs -q -dBATCH -dNOPAUSE -dFirstPage=$PAGE -dLastPage=$PAGE \
-dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode \
-sDEVICE=pdfwrite -sOutputFile=${FNAME%\.pdf}_$PAGE.pdf $FNAME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment