Skip to content

Instantly share code, notes, and snippets.

@karthikraman
Last active August 29, 2015 14:22
Show Gist options
  • Save karthikraman/80b96276ba8b85cbd4d4 to your computer and use it in GitHub Desktop.
Save karthikraman/80b96276ba8b85cbd4d4 to your computer and use it in GitHub Desktop.
Bash: PDF page extractor
#Courtesy: http://www.linuxjournal.com/content/tech-tip-extract-pages-pdf
#Add this to your .bashrc
function pdfpextr()
{
# this function uses 3 arguments:
# $1 is the first page of the range to extract
# $2 is the last page of the range to extract
# $3 is the input file
# output file will be named "inputfile_pXX-pYY.pdf"
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
-dFirstPage=${2} \
-dLastPage=${3} \
-sOutputFile=${1%.pdf}_p${2}-p${3}.pdf \
${1}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment