2 # Extract PBMs from PDF and create new PDF from them.
4 n_pages=$(pdfinfo "$1" | grep -e '^Pages:' | awk '{ print $NF }')
6 while [ "$i" -le "${n_pages}" ]
8 i_formatted=$( printf "%010d" $i)
9 prefix="pdfimages_export_${i_formatted}"
10 echo "extracting page $i as ${prefix}"
11 pdfimages "$1" -l $i -f $i "${prefix}"
13 source=$(ls -1 "${prefix}"* | head -1)
14 # negate to invert colours, rotate to, well, rotate
15 convert "${source}" -negate -rotate 270 "pdfimages_export_converted_${i_formatted}".pdf
19 pdfunite "pdfimages_export_converted_"* "converted_$1"