New Tool Radar

AI PDF

How to Check a Scanned PDF Page Count Matches the Scan Batch Before OCR

Compare the page count of a scanned PDF with the number of pages in the scan batch to find missing pages.

Schematic with three steps: Read the PDF page count; Compare with the batch count; Find the missing pages.

A scan batch can silently lose a page: a double feed in the scanner, a page skipped by the operator, or a file saved before the last page finished. Comparing the PDF page count with the number of pages you scanned catches the loss before OCR, when it is still cheap to rescan the missing page.

What you need

  • pdfinfo installed, which comes with poppler-utils
  • The scanned PDF
  • A count of the pages in the scan batch, from the scanner log or the stack itself

Step 1: Read the PDF page count

Run pdfinfo file.pdf and note the Pages value. The pdfinfo tool prints the page count among the document properties.

Step 2: Compare with the batch count

Compare the Pages value with the number of pages you scanned. If they match, the batch is complete; if not, work out which pages are missing.

Step 3: Find the missing pages

Extract the text with pdftotext and check the page numbers or the document flow. A gap in the numbering, or a jump in the text, shows where the missing page belongs.

Worked example: synthetic page-count check on a 12-page scan batch

The table below is a synthetic example. It shows the expected result of comparing counts; no scan was checked.

Check Expected Found
Pages scanned 12 12
Pages in PDF 12 11
Missing page None Page 7, between pages 6 and 8
Action Proceed to OCR Rescan page 7 first

Expected result (UNTESTED). the batch scanned 12 pages but the PDF has only 11, and the text jumps from page 6 to page 8, so page 7 was lost in the scan. Rescan page 7 and rebuild the PDF before running OCR. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • A matching page count does not prove the pages are in the right order; check the flow as well.
  • Blank pages count as pages, so a blank page in the batch still shows up in the PDF count.
  • pdfinfo reads the PDF header, so a corrupted file may report a count that does not match its contents.

Sources

See all