pdfinfo, I can easily count the number of pages in a PDF file, but that includes empty pages, e.g. before a chapter. What if I want the count of all non-empty packages – is there a tool for that?
If by "empty page" you mean: when printed, it wouldn't cause any toner/ink marks on the page, you could use Ghostscript's new
inkcov device which reports the ink coverage for each page. (It may be a bit slow to report final results; that is because it needs to virtually render each page in order to compute the ink coverage):
$> gs -o - -sDEVICE=inkcov sample2.pdf Processing pages 1 through 8. Page 1 0.00000 0.00000 0.00000 0.02231 CMYK OK Page 2 0.02363 0.02363 0.02363 0.02363 CMYK OK Page 3 0.02527 0.02527 0.02527 0.00000 CMYK OK Page 4 0.03322 0.03322 0.03322 0.03322 CMYK OK Page 5 0.00000 0.00000 0.00000 0.03413 CMYK OK Page 6 0.00000 0.00000 0.00000 0.01984 CMYK OK Page 7 0.13274 0.13274 0.13274 0.03355 CMYK OK Page 8 0.00000 0.00000 0.00000 0.00000 CMYK OK
The values are integers in the range from
0..1, where a value of 1 represents a 100% ink coverage (for all pixels on the page). The above result hence means:
Page 8, when rendered, does not use any ink, hence it is "blank".
This does not mean that this page is really empty, when looked at in a PDF viewer. To list but only two examples:
- It could use white text on a white background, and this text could be highlighted and copy'n'pasted when the PDF is displayed on screen. A printout however would not show anything.
- The page could be containing "layers" (or "Optional Content Groups",
/OCGelements), where one layer is set to be displayed on screen, but another (empty) layer is set to be used when printing.