ambevar-dotfiles/.scripts/pdfextract

17 lines
313 B
Bash
Executable File

#!/bin/sh
if [ $# -ne 4 ]; then
cat<<EOF
Usage: ${0##*/} PDFFILE FIRSTPAGE LASTPAGE DESTFILE
Extract a range of pages from a PDF.
EOF
exit
fi
if [ ! -f "$1" ]; then
echo "$1 is not a valid file."
fi
gs -sDEVICE=pdfwrite -dNOPAUSE -dSAFER -dSAFER -dFirstPage=$2 -dBATCH -dLastPage=$3 -sOutputFile="$4" "$1"