Test files › Documents › empty-zero-pages.pdf
Empty PDF with zero pages
Structurally valid PDF whose /Pages node declares /Count 0 and an empty /Kids array.
↓ Download empty-zero-pages.pdf| Filename | empty-zero-pages.pdf |
| Format | |
| Size | 430 bytes (430 bytes) |
| MIME type | application/pdf |
| SHA-256 | c9ff80b477c10ff11270c788b35152f7d5f7147c288d7c1d051dd19bca1b8253 |
What this file catchesRenderers and page-splitters that assume at least one page exists and divide by page count.
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("empty-zero-pages.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: 0, content streams that draw text: 0
no pages: most readers show an error or a blank document
Related guides and tools
Download & verify
curl -fsSL -o "empty-zero-pages.pdf" "https://files.hexaqa.com/pdf/empty-zero-pages.pdf"
curl -fsSL "https://files.hexaqa.com/pdf/empty-zero-pages.pdf" | sha256sum
# expect: c9ff80b477c10ff11270c788b35152f7d5f7147c288d7c1d051dd19bca1b8253