29 lines
706 B
Plaintext
29 lines
706 B
Plaintext
|
|
#!/bin/bash
|
||
|
|
if [ "$1" == "-h" ] ; then
|
||
|
|
echo "
|
||
|
|
pdfsplit - extract a range of pdf pages with ghostscript
|
||
|
|
|
||
|
|
usage:
|
||
|
|
pdfsplit firstPage lastPage inputFile.pdf
|
||
|
|
|
||
|
|
output file will be named inputfile_pXX-pYY.pdf
|
||
|
|
|
||
|
|
depends:
|
||
|
|
gs - ghostscript
|
||
|
|
|
||
|
|
"
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
|
||
|
|
# the following is from a stackoverflow answer
|
||
|
|
# 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
|
||
|
|
gs -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -dSAFER \
|
||
|
|
-dFirstPage=${1} \
|
||
|
|
-dLastPage=${2} \
|
||
|
|
-sOutputFile=${3%.pdf}_p${1}-p${2}.pdf \
|
||
|
|
${3}
|
||
|
|
|