HowDoesAIDoThat?

Questions / practical answer

Why is text missing when I give AI a PDF?

A PDF can show words without storing usable text. Check each page, save what a local extractor reads, add OCR where needed and inspect the result before blaming the model.

By HowDoesAIDoThatSources checked 12 October 2026

Check the document input before changing the model

Missing PDF text can start with extraction: an incomplete text layer, or a scan needing OCR. A PDF can show readable words stored as an image. Text extraction reads stored text; optical character recognition (OCR) recognises words in images. Neither guarantees complete, correctly ordered text.

Some AI applications also process page images. This check diagnoses a text-extraction route; it does not reveal every application's internal input. Start with the original PDF and the passage the answer missed. The instructions below were checked on 12 October 2026; no OCR or AI processing has been executed for this article.

1. Try a page-level text check

In your PDF reader, select one ordinary sentence, copy it and paste into a plain-text editor. Compare it with the page. Repeat on a scanned-looking page, a table and the particular passage you need.

Copying useful text suggests an extractable layer, but does not prove every page is covered. Scans can have an invisible OCR layer containing mistakes. A mixed PDF can combine ordinary text pages, image-only pages and images containing text on otherwise selectable pages.

pypdf's extraction guide explains these distinctions. An empty extraction is a reason to inspect the page, not proof that it is blank or definitely a scan: unusual fonts, drawn letter shapes and parser failures can also interfere.

2. Save what a local extractor actually reads

Use a small document you are entitled to process. Keep the original. Start with a separate working folder and Python; pypdf's installation guide currently specifies Python 3.9 or newer. These Windows commands create an isolated environment without activating it:

python -m venv .venv
.\.venv\Scripts\python.exe -m pip install pypdf

On macOS/Linux, use python3 for creation and .venv/bin/python for subsequent commands. Python's venv documentation explains the platform paths.

Save the following original script as extract_pdf.py:

import sys
from pathlib import Path
from pypdf import PdfReader

source = Path(sys.argv[1])
reader = PdfReader(source)
if reader.is_encrypted:
    raise SystemExit("Use an authorised, unlocked copy.")

parts = []
for number, page in enumerate(reader.pages, start=1):
    text = page.extract_text() or ""
    count = len(text.strip())
    print(f"Page {number}: {count} extracted characters")
    if not text.strip():
        print("No text detected: inspect this page.")
    parts.append(f"--- Page {number} ---\n{text}")

destination = source.with_suffix(".extracted.txt")
with destination.open("x", encoding="utf-8") as output:
    output.write("\n\n".join(parts))
print(f"Saved {destination}")

Run it from that folder, replacing the input filename:

.\.venv\Scripts\python.exe extract_pdf.py "input.pdf"

It writes input.extracted.txt as UTF-8, with markers for every page, including empty extractions. It refuses to overwrite existing outputs: use a differently named input copy for another attempt. The page API documents extract_text(); Python's path API documents file writing.

For an encrypted document, use a permitted unlocked export or obtain the appropriate password and follow the decryption documentation. This script deliberately stops. Technical extractability does not establish permission to reuse the contents.

3. Reopen the text and compare it with the pages

Open the saved .txt outside Python. Find the missing passage and check its page marker. Inspect names, dates, amounts, headings and the start/end of each relevant page. A nonzero character count does not mean the whole page was extracted correctly.

Two-column text can arrive in the wrong order. Tables can lose the relationship between a heading and its values; formulas and footnotes need particular care. pypdf offers extraction_mode="layout" for another representation, but it is not a guarantee of correct reading order or table structure. Preserve each attempt separately and verify against the original.

If parsing errors or implausible text appear, retain the exact error and package version. Try a small authorised export before processing a huge document: decompressed PDF content can require considerable memory.

What our small extraction test showed

On 12 October 2026 we tested two original one-page synthetic PDFs with Python 3.12.14 and pypdf 6.10.0. Their rendered pages matched pixel for pixel.

  • Text-layer PDF: 222 raw characters extracted, including HDAI-DEMO-014 and GBP 42.00.
  • Image-only PDF: zero characters extracted.

We also ran the script above and reopened its saved files: the digital sample retained the reference and amount; the image-only sample contained only its page marker.

This demonstrates one narrow extraction difference. It is not an OCR, complex-layout or document-AI benchmark.

4. Add OCR only where the text check needs it

For image-only pages, an optional free local route is OCRmyPDF. Follow its current platform installation instructions, including external dependencies and language packs; installing pypdf alone does not install OCR. Once OCRmyPDF is available, check its version and, for an English document, run:

ocrmypdf --version
ocrmypdf --mode skip -l eng --output-type pdf input.pdf searchable.pdf

In version 17 and later, skip mode skips pages with existing text. Keep searchable.pdf separate from the original, reopen it and rerun the extraction script on it. Check the newly recognised words against the images.

Skip mode can miss an image body on a page that already has selectable text, such as a footer. The documented redo mode can handle additional image text while retaining visible text; review that route on a copy if appropriate. Do not blindly force OCR over the entire document: force mode rasterises existing content and can discard structure.

Also avoid treating an OCR .txt sidecar as a complete mixed-document export. The OCRmyPDF cookbook warns that it omits text from pages that already had text. Extract from the resulting PDF to check both types together. Language choice, scan quality and skipped pages still affect completeness.

5. Give AI checked material and keep the source

If the passage is absent or garbled in your extract, fix that input first. If it is present and correct, investigate the application's ingestion, retrieval and context-window limits before concluding the PDF parser failed. A fresh question with the relevant checked passage can help isolate the problem; verify any answer against its source page.

Keep the original PDF, extraction, OCR copy where applicable, script and version notes together. Local extraction avoids uploading this step to a provider. A paid document service may simplify OCR or layout handling, but check its actual export, accuracy and data-handling terms. Private files and their extracted text need the same care; payment does not guarantee that every line survived.

Sources

Primary references checked 12 October 2026. This explanation is not a benchmark of a particular model or computer.