pypdf Can't Read Scanned PDFs, and No Setting Will Fix It
Short or empty text is merely a signal for further verification and should not be directly equated with a scanned document. Below, we record page by page whethe
If pypdf returns blank strings or gibberish from a PDF that looks readable on screen, the cause is usually the file rather than your settings. This guide is for anyone preparing PDFs for processing or translation who has hit this problem and needs a way to diagnose it.
pypdf reads the text instructions stored inside a PDF. It does not perform OCR. A scanned page stores pictures of letters, so no extraction setting can recover characters that the file never contains. You will learn how to tell native, scanned and double-layer PDFs apart, how to build test files, and when a document should go to manual review.
Treat a short or empty result as a reason to check further, not as proof that a file is scanned. The steps below show you how to check your own files.
Why does pypdf return blank text? The short answer
The PDF usually has no readable text layer, so you need an OCR workflow rather than a different extraction setting.
| Your situation | What to do | Why |
|---|---|---|
| PDF returns blank or gibberish text | Check whether the file has a real text layer; if not, switch to OCR | pypdf reads text objects and does not perform OCR |
| Text is short but present | Keep the extracted text and verify it | Short text is a signal to verify, not a reason to force OCR |
| Extraction raises an error | Record the exception phase | A failure should not be treated as a blank page |
| Scanned PDF with a hidden OCR layer | Route to manual review or visual comparison if the layer is partial or misaligned | The text layer can be incomplete even when it exists |
| Document is being prepared for translation | Keep the originals, then recheck page order, hyperlinks and content | Translation does not replace these checks |
Understand what pypdf actually reads
Short or empty text is a signal, not a verdict
- Record, page by page, whether text was extracted.
- Blank pages, image-only pages and pages with encoding anomalies each need a different follow-up assessment.
- pypdf's text extraction is not OCR.
Why parameter changes rarely fix blank text
When extract_text() returns only blank strings or sporadic gibberish, the first instinct is often to check the parameters. Did you miss extraction_mode="layout"? Do you need to specify a rotation angle? In many engineering cases, neither helps. The problem comes from using the wrong tool for the file, not from a setting you overlooked.
pypdf is essentially a parser for PDF content streams, reading the text object instructions embedded in the file. If the PDF is fundamentally an image, no extraction mode can decode character encodings that do not exist.
Native, scanned and double-layer PDFs
Understanding this issue starts with the design intent of the PDF format. PDF was created for precise printing and visual presentation, not for structured data storage.
Native digital PDFs
- These contain font resources, encoding mapping tables and absolutely positioned text-rendering instructions.
- pypdf reconstructs text by parsing these low-level instructions.
- The method is deterministic: it avoids confusing visually similar characters such as
0andO, preserves special symbols and ligatures, and is unaffected by image noise.
Scanned PDFs
- A scanned PDF is a container for images.
- The visible text exists only as a pixel grid, not as a text object that
extract_text()can read.
Double-layer PDFs
- Some scanned documents are processed by OCR software and given a hidden text layer, often called a "double-layer PDF".
- pypdf can extract only the content of that layer.
- If the OCR quality is poor, the text layer is missing, the encoding is corrupted or the layer is badly misaligned with the image, the results will be incomplete or entirely empty.
- In these cases, tuning pypdf parameters is pointless. Switch to an optical character recognition (OCR) workflow.
Decide based on a programmatic check of whether a valid text layer is actually present, not on whether the page looks like it contains text.
Build a verifiable test baseline
To distinguish these cases in code, create a set of synthetic test files. The code below is a logical demonstration. Run it in an environment with locked dependencies. It is not an empirical report on specific production files.
- Normal digital PDF: Export a document containing the text "Invoice #2024-001" from Word or LaTeX.
- Pure scanned PDF: Scan any paper document to JPEG, then wrap it in a single-page PDF with no text layer.
- Boundary case: Create a "pseudo-OCR" PDF with a hidden text layer whose content is an empty string or only whitespace. This simulates a double-layer document that fails recognition.
Run the text-layer check
The example below builds detection logic in memory. It requires pypdf>=3.0.0, so install that version in an isolated virtual environment. The script contains no real file paths. Replace the placeholder paths with your synthetic test files.
from io import BytesIO
import pymupdf
from pypdf import PdfReader
with pymupdf.open() as doc:
page = doc.new_page()
page.insert_text((50, 50), "Hi")
doc.new_page()
raw = doc.tobytes()
reader = PdfReader(BytesIO(raw))
records = []
for index, page in enumerate(reader.pages):
text = page.extract_text() or ""
records.append({"page": index + 1, "text": text,
"status": "text_present" if text.strip() else "review_empty_text"})
assert len(records) == 2
assert records[0]["status"] == "text_present"
assert records[0]["text"].strip() == "Hi"
assert records[1]["status"] == "review_empty_text"
The check only answers one question: is a text layer present or absent? End-to-end performance depends on other real-world factors too.
Decide what to accept and what to send for review
The table below lists common observations, the handling decision for each, and what you should not infer from them. It shows where automation can run unattended and where a person needs to step in.
| observation | What should be done | should not infer |
|---|---|---|
| short text | still retains the text | is not forced to perform OCR if it falls below the threshold |
| empty text | checks the page layout and content type | is not directly classified as a scanned document |
| parsing failed | records the exception phase | does not masquerade as a blank page |
Pay special attention to documents that contain both a text layer and an image layer:
- Do not take the integrity of the text layer at face value.
- Some scanners produce double-layer PDFs in which the text covers only part of the content, or the coordinates are badly misaligned with the image.
- Send such cases to manual review, or check them with a visual comparison algorithm.
- Automation can help you triage documents, but it cannot guarantee semantic accuracy.
📊 At a glance
| PDF type | What pypdf extracts | What to do |
|---|---|---|
| Native digital PDF | Text rebuilt from font resources and encoding tables, deterministically | Use pypdf extraction |
| Scanned PDF (image only) | No text object to read; blank or no output | Switch to an OCR workflow |
| Double-layer PDF | Only the hidden text layer, and only as good as the original OCR | Verify the layer; send partial or misaligned layers to manual review |
🎯 Which approach fits you?
If you have a native digital PDF
Use pypdf's text extraction. Its parsing of text instructions is deterministic, so it handles special symbols and ligatures without image noise.
If you have a scanned PDF with no text layer
Pure scans contain no text object for pypdf to read. Move to an OCR workflow rather than tuning parameters.
If you have a double-layer PDF
Test the text layer first. If it is empty, incomplete or misaligned with the image, route the file to manual review or visual comparison.
If you are preparing files for translation
Split, encrypt or attach files as needed before translating, keep the originals, and recheck page order, hyperlinks and content afterwards.
Translating documents with this checklist
File splitting, encryption and attachment handling are part of delivery preparation, and translation cannot replace these checks. Keep the original documents and your processing checklist, then reassess the translated manuscript's page order, hyperlinks and content integrity.
OmniDoc translates PDF, Word, PowerPoint and Excel files: scanned pages are recognized first, table cells are translated one by one so tables keep their rows and columns, and a PDF comes back as both a bilingual and a translation-only file. Paid translation adds a glossary and context translation.
Further reading
- Extract Text from a PDF: the pypdf official text extraction documentation.
- The "OCR vs. Text Extraction" section of the same pypdf documentation explains the difference between OCR and text extraction.
❓ FAQ
1. Why does pypdf return blank text from my PDF?
The file most likely holds an image of the page with no text object for pypdf to read. pypdf does not perform OCR.
2. Will changing extraction_mode="layout" fix it?
Rarely. Parameter tuning cannot decode character data that is not in the file.
3. Does short text mean the file is scanned?
No. Short or empty text is a signal for further verification, and blank pages, image-only pages and encoding problems each need different follow-up.
4. Can I rely on the automated check for final accuracy?
No. The check only tests whether a text layer is present or absent. Automation can help you triage documents, but it cannot guarantee semantic accuracy.
📝 Summary
pypdf reads the text stored in a PDF and does not perform OCR, so a scanned page with no text layer will not yield text however you set the extraction. Check each file for a real text layer, send partial or misaligned layers to review, and keep the originals.
Try it now: upload a document and get it translated with the layout intact


