Suppose you are printing a book or some compilation of several shorter documents. You would do a duplex print (printing on both sides) but you don’t generally want the backside of the last page of a chapter/section/episode to contain the first page of the next piece.
In LaTeX we would add a \cleardoublepage
or \cleartooddpage
before every section. The compiler then only adds a blank page on an as-needed basis. It works as expected and prints correctly. But it’s a waste of money because the print shop counts blank pages as any other page.
My hack is this:
\newcommand{\tinyblankifeven}{{\KOMAoptions{paper=a8}\recalctypearea\thispagestyle{empty}\cleartooddpage}}
That inserts an A8 formatted blank page whenever a blank is added. That then serves as a marker for this shell script:
make_batches_pdf()
{
local -r src=$1
local start=1
local batch=1
while read pg
do
fn_dest=${src%.pdf}_b$(printf '%0.2d' $batch).pdf
batch=$((batch+1))
if [[ $start -eq $((pg-1)) ]]
then
printf '%s\n' "$start → $dest"
pdftk "$src" cat "$start" output "$dest"
else
printf '%s\n' "$start-$((pg-1)) → $dest"
pdftk "$src" cat "$start-$((pg-1))" output "$dest"
fi
start=$((pg+1))
done < <(pdfinfo -f 1 -l 999 "$src" | awk '/147.402/{print $2}')
dest=${src%.pdf}_b$(printf '%0.2d' $batch).pdf
printf '%s\n' "$start-end → $dest"
pdftk "$src" cat "$start"-end output "$dest"
}
If there are 20 blank A8 pages, that script would produce 21 PDF files numbered sequentially with no blank pages. Then a USB stick can be mounted directly on the printer and the printer’s UI let’s me select many files at once. In that case it would save me $2 per book.
There are a couple snags though:
- If I need to print from a PC in order to use more advanced printing options, It’s labor intensive because the print shop’s windows software cannot print many files in one shot – at least as far as I know… I have to open each file in Acrobat.
- If I need multiple copies, it’s labor intensive because the collation options never account for the case that the batch of files should be together. E.g. I get 3 copies of file 1 followed by 3 copies of file 2, etc.
It would be nice if there were a printer control signal that could be inserted into the PDF in place of blank pages. Anyone know if anything like that exists in the PDF spec?