This command is routinely used on PDFs to extract the images from
scanned documents such that original images are preserved as-is
without conversion or transcoding losses:
$ pdfimages -all sample.pdf guts
HPLIP is a FOSS driver for HP scanners. This command is used to scan a
doc to PDF:
$ hp-scan --mode=gray --adf -oscan.pdf --device="hpaio:/net/hp_$model?ip=$IPaddress&queue=false"
That produces a grayscale PDF of all pages fed into the ADF. The PDF
is always fine as far as I can tell; always renders fine in
evince. But sometimes some pages generate error messages from
pdfimages and result in a blank PNG image. Sample output:
===8<----------------------------------------
$ pdfimages -all extraction_broken.pdf broken
Syntax Error (281): Unknown compression method in flate stream
Syntax Error (2406): Illegal character '>'
Syntax Error (2406): Unknown operator 'E'
Syntax Error (2416): Unknown operator ']'
Syntax Error (2561): Unknown operator '^GPBSNeGNT''
Syntax Error (2566): Illegal character '>'
Syntax Error (2566): Unknown operator ''1o`SP0VoiGpK"`B""o1'
Syntax Error (2641): Illegal character '>'
Syntax Error (2641): Unknown operator 'C'
Syntax Error (2646): Unknown operator 'CMbtB^&@ZZ$24'
Syntax Error (2691): Illegal character '>'
Syntax Error (2691): Unknown operator '@!F0;'
Syntax Error (2691): Too few (0) args to 'c' operator
===8<----------------------------------------
I scanned the same page twice using the same hplip command. The two
PDFs should essentially be quite similar apart from page alignment
differences. But pdfimages cannot extract the image from one PDF yet
it has no problem on the other.
I will attach the extraction_broken.pdf to this bug report. Since the
PDFs are 2mb, I will attach a working sample from the same scanner
after the bug report has a number.