Corrupted PDF Sample — A File That Won't Open, On Purpose
Every PDF tool has an error path, and almost nobody tests it with a realistic broken file. This sample is a valid 6-page document cut off at 55% of its bytes — exactly what an interrupted download, a full disk, or a dropped connection produces. The header says PDF; the ending, cross-reference table and trailer simply never arrive.
What kind of "corrupted" this is
Truncation — the most common real-world corruption. A PDF's table of contents (the xref
table) and its trailer live at the end of the file, so a file cut anywhere loses the
map to everything, even the parts that are present. Strict parsers give up immediately;
forgiving ones (pdf.js among them) attempt a rescue by re-scanning the whole file for object
markers — you'll see it log Indexing all PDF objects — and still fail here,
because the objects themselves end mid-stream. That two-stage failure is realistic and worth
observing in your own stack.
What to test with it
- Error message quality — feed it to any tool on this site, or yours. The user should see "this file appears damaged", not a stack trace, a spinner that never resolves, or a silent empty result.
- Upload validation — servers that sniff only the
%PDF-magic bytes will accept this file happily; whatever processes it later inherits the explosion. Decide which layer should catch it, then verify that layer does. - Batch resilience — put it in the middle of a merge queue between two good files: correct behavior is one per-file error and a completed batch, not a lost batch.
- Timeout behavior — rescue-scanning a broken file takes longer than parsing a good one; on a large corrupted file that can look like a hang. Watch what your UI shows during the attempt.
- Repair-tool honesty — anything claiming to "repair any PDF" meets its match here: the missing 45% of bytes doesn't exist to recover. A truthful repair tool reports partial or no recovery.
Can a truncated PDF be repaired?
Partially, sometimes. Objects that fully arrived before the cut — fonts, early page content — can be re-indexed by a rescue parser, which is how "PDF repair" tools work when they work. But pages whose content streams were cut are gone: bytes that never existed can't be reconstructed. The honest framing is salvage, not repair. If the file mattered, the better path is almost always re-downloading or re-exporting from the source.
FAQ
Is the file dangerous?
No — it's the front half of an ordinary generated document, nothing more. "Corrupted" here means incomplete, not malicious. (Deliberately malicious PDFs are a different test category — fuzzing corpora — and nothing in this collection is one.)
My viewer shows a blank page instead of an error. Bug?
Arguably. Some viewers render whatever they salvage and stay quiet about the rest. Whether "show something, say nothing" beats "refuse loudly" is a UX decision — but it should be a decision, which is what this file forces.
How was it made, exactly?
A valid 6-page document is generated, saved, and its byte array sliced at 55% — see the generator source. The build verifies the result actually fails to parse; a "corrupted" sample that accidentally opens would be worse than none.
Do you have other corruption types — bad xref offsets, garbled streams?
Not yet; truncation covers the most common real-world case. If your test matrix needs a specific corruption mode, open an issue on the repo — most variants are a few lines of byte surgery.