Guides

Find Which PDF Pages Need OCR Before Sending a Document to AI

Check page-level text extraction with PyMuPDF and distinguish selectable text from a scanned image using a two-page fixture.

Key takeaway

Identify pages with empty text extraction and inspect before OCR.

On this page
  1. Run a mixed PDF through a text audit
  2. Decide what each page needs
  3. Keep source pages aligned after OCR

A PDF can contain selectable text on one page and only a scan on the next. If an AI workflow extracts text once for the whole file, a nonempty result can hide missing pages. Check each page before deciding what to OCR. PyMuPDF text extraction recipes

Run a mixed PDF through a text audit

Save the two-page PDF and audit script. Page 1 contains text. Page 2 is a raster rendering of page 1. The pages look alike, but the second has no text layer.

python -m pip install pymupdf==2.1
python audit-pdf-text-pages.py mixed-text-scan-fixture.pdf

On November 12, 2026, PyMuPDF 2.1 returned:

Page 1: text present (38 characters)
Page 2: inspect for OCR (0 characters)

Page 2 contains visible words, so it is the candidate for OCR. The script numbers pages starting at 1 and reports the length after trimming surrounding whitespace. It does not modify the PDF.

Decide what each page needs

Open the pages with zero extracted characters. A blank separator page can be skipped. A page with visible printed words needs OCR if those words are part of your source. An illustration may need a description or visual model instead, depending on the question you intend to ask.

Also sample pages with text present. A page number, footer or existing OCR layer may produce a nonzero count while leaving the body unreadable. Try to locate one expected name or number in the extracted text. If the text layer misreads it, retain the visible page as the source for correction.

Keep source pages aligned after OCR

Track the original page number for every extracted and OCR-derived passage. If you process only pages 2 and 5 in a temporary PDF, save a mapping back to pages 2 and 5 of the original. Otherwise the AI may return a citation that points to the wrong page in the reader’s copy.

Check OCR output against the source before using it in a summary. A table with a readable text layer can still have the wrong reading order or shifted column values. Use a separate cell-level check when a table provides the evidence. PDF table extraction workflow

Sources & references

Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.

How we research and test →

Tools in this article