pdftk
is able to cut out a fixed set of pages efficiently. With a bit of scripting glue, this does what I want:
number=$(pdfinfo -- "$file" 2> /dev/null | awk '$1 == "Pages:" {print $2}')
count=$((number / pagesper))
filename=${file%.pdf}
counter=0
while [ "$count" -gt "$counter" ]; do
start=$((counter*pagesper + 1));
end=$((start + pagesper - 1));
counterstring=$(printf %04d "$counter")
pdftk "$file" cat "${start}-${end}" output "${filename}_${counterstring}.pdf"
counter=$((counter + 1))
done
This assumes that you have the number of pages per chunk in $pagesper
and the filename of the source PDF in $file
.
If you have acroread
installed, you can also use
acroread -size a4 -start "$start" -end "$end" -pairs "$file" "${filename}_${counterstring}.ps"
acroread
offers the option -toPostScript
which may be useful.