pdftoolskit.org
PDF (Portable Document Format) utilities, in the browser
Say hi →

Corrupted PDF Sample — A File That Won't Open, On Purpose

truncated at 55% · xref and trailer gone · guaranteed unreadable · CC0

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

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.