Test files › Documents › no-text-layer.pdf

Sample PDF file (no text layer)

PDF whose only page draws vector rectangles and contains zero text operators.

↓ Download no-text-layer.pdf
Filenameno-text-layer.pdf
FormatPDF
Size1.7 KB (1,698 bytes)
MIME typeapplication/pdf
SHA-256b061ce1d9945d157fe3cd86249309776b9d438fbc55f16f5b56a041971d91224
What this file catchesText-extraction pipelines that silently return an empty string instead of flagging that OCR is required. Also an accessibility failure case: no reading order for screen readers.

Handle it in code

Each snippet below was run against this exact file with Python 3.14.4 and Node 24.15.0 when this page was built, and the output shown is what it printed.

Python

Quick triage without a PDF library: count page objects and look for the text-drawing operators (Tj, TJ) in the content streams, inflating Flate streams with zlib. Use it to route files, for example image-only scans to OCR. PDFs that pack objects into compressed object streams need a real parser such as pypdf.

import re
import zlib

with open("no-text-layer.pdf", "rb") as f:
    data = f.read()
pages = len(re.findall(rb"/Type\s*/Page\b", data))
drawing = 0
for m in re.finditer(rb"(?<!end)stream\r?\n", data):
    raw = data[m.end():data.find(b"endstream", m.end())]
    try:
        raw = zlib.decompressobj().decompress(raw)
    except zlib.error:
        pass  # not Flate-compressed
    if re.search(rb"\bT[Jj]\b", raw):
        drawing += 1
print(f"page objects: {pages}, content streams that draw text: {drawing}")
if pages == 0:
    print("no pages: most readers show an error or a blank document")
elif drawing == 0:
    print("no text layer: extraction returns nothing, so this needs OCR")

Run against this file, it prints: page objects: 1, content streams that draw text: 0 no text layer: extraction returns nothing, so this needs OCR

Related guides and tools

Sample PDF fileFile signaturesPDF extraction traps (RAG)Check a file's real typeVerify its SHA-256

Download & verify

curl -fsSL -o "no-text-layer.pdf" "https://files.hexaqa.com/pdf/no-text-layer.pdf"
curl -fsSL "https://files.hexaqa.com/pdf/no-text-layer.pdf" | sha256sum # expect: b061ce1d9945d157fe3cd86249309776b9d438fbc55f16f5b56a041971d91224

More documents test files

corrupt-xref.pdfempty-zero-pages.pdftruncated.pdfvalid-1page.pdfvalid-500pages.pdflatin1.txtline-endings-crlf.txtline-endings-lf.txt

← All Documents files