Test files › Documents › corrupt-xref.pdf
Corrupt PDF with a broken xref table
Valid PDF body with a deliberately wrong startxref offset, so the cross-reference table cannot be located.
↓ Download corrupt-xref.pdf| Filename | corrupt-xref.pdf |
| Format | |
| Size | 720 bytes (720 bytes) |
| MIME type | application/pdf |
| SHA-256 | bd5efc3d6ec6afa54aec7d16a763577239ce2e1fda8636bea12497b4d9046f32 |
What this file catchesParsers that crash or hang instead of falling back to a full-file object scan. Most real-world "damaged PDF" reports look exactly like this.
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
A cheap structural check before handing the file to a PDF library, which will often repair these silently. Use it to reject or flag uploads, not to validate PDFs fully.
import re
with open("corrupt-xref.pdf", "rb") as f:
data = f.read()
problems = []
if not data.startswith(b"%PDF-"):
problems.append("no %PDF- header")
tail = data[-1024:]
if b"%%EOF" not in tail:
problems.append("no %%EOF marker: the file is truncated")
m = re.search(rb"startxref\s+(\d+)\s+%%EOF", tail)
if m:
offset = int(m.group(1))
at = data[offset:offset + 20]
if offset >= len(data) or not (at.startswith(b"xref") or re.match(rb"\d+ \d+ obj", at)):
problems.append(f"startxref points at byte {offset}, where there is no cross-reference table")
print("; ".join(problems) or "structure looks intact")Run against this file, it prints: startxref points at byte 999999, where there is no cross-reference table
Related guides and tools
Download & verify
curl -fsSL -o "corrupt-xref.pdf" "https://files.hexaqa.com/pdf/corrupt-xref.pdf"
curl -fsSL "https://files.hexaqa.com/pdf/corrupt-xref.pdf" | sha256sum
# expect: bd5efc3d6ec6afa54aec7d16a763577239ce2e1fda8636bea12497b4d9046f32