Files
linux-bin/pdfsplit
2023-09-28 22:52:04 -04:00

29 lines
706 B
Bash
Executable File

#!/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}