Test files › Documents › valid-500pages.pdf
Large 500-page PDF file
Well-formed PDF with 500 numbered pages.
↓ Download valid-500pages.pdf| Filename | valid-500pages.pdf |
| Format | |
| Size | 258 KB (264,642 bytes) |
| MIME type | application/pdf |
| SHA-256 | a950f538dcb5480d277dd180a38ee00dfd827a6f1e2b1d34c72fd3ce0a618a25 |
What this file catchesViewers that render every page eagerly instead of lazily, thumbnail jobs that time out, and page-count parsers that stop at the first /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("valid-500pages.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: 500, content streams that draw text: 500
Related guides and tools
Download & verify
curl -fsSL -o "valid-500pages.pdf" "https://files.hexaqa.com/pdf/valid-500pages.pdf"
curl -fsSL "https://files.hexaqa.com/pdf/valid-500pages.pdf" | sha256sum
# expect: a950f538dcb5480d277dd180a38ee00dfd827a6f1e2b1d34c72fd3ce0a618a25