18 lines
578 B
Bash
Executable File
18 lines
578 B
Bash
Executable File
#!/bin/zsh
|
|
# Extract a page range from a PDF file
|
|
# 1 original PDF file path
|
|
# 2 first page of desired range
|
|
# 3 last page of desired range (optional)
|
|
source ~/.local/lib/pdf_tools.sh
|
|
|
|
typeset -r numpages=$(pdf_num_pages $1)
|
|
typeset -r digits=$#numpages
|
|
typeset -r -Z${digits} first=$2
|
|
typeset -Z${digits} last=${numpages}
|
|
|
|
if (( $# >= 3 )); then
|
|
(( $3 > ${numpages} )) && echo "The document is only ${numpages} pages long, which is less than $3!" && exit 1
|
|
last=$3
|
|
fi
|
|
pdf_extract_range "$1" $2 $3 "${1%.pdf}_${first}-${last}.pdf" > /dev/null
|