Developers and QA teams often need a broken PDF to test viewers, converters and upload forms. Here is how a PDF is built, and the quickest ways to damage one on purpose.
How a PDF is structured
A PDF has four parts:
- Header: starts with
%PDF-1.x. - Body: objects such as pages, fonts and images.
- Cross-reference (xref) table: an index telling readers where each object is.
- Trailer: points to the xref table and ends with
%%EOF.
Damage any of these and many readers will complain or refuse to open the file.
Method 1: Free online PDF corrupter
- Go to CorruptAnyFile.
- Upload your PDF.
- Click Corrupt My File.
- Download the result, which is the same size but will not open.
The tool targets the PDF header and structure instead of random bytes, so the result is consistent. Avoid uploading confidential PDFs.
Method 2: Damage the header
Open a copy in a hex editor and change 25 50 44 46 (%PDF) to 00 00 00 00. Many viewers will report that the file is not a valid PDF.
Method 3: Truncate the file
head -c 1500 sample.pdf > broken.pdf
This removes the xref table and trailer. Some readers try to rebuild the file, so results differ between viewers. That is useful for testing, because it shows how each reader copes.
Method 4: Break the xref table
Search for the text xref in a text-capable editor and alter the offsets or delete a few lines. Readers that trust the index will fail, while forgiving ones may repair it silently.
What to expect in different readers
| Reader | Typical reaction |
|---|---|
| Adobe Acrobat | Error or offers to repair |
| Browser (Chrome, Edge) | Fails to load or shows blank |
| Preview (Mac) | Often refuses to open |
| Server libraries | Throw exceptions |
Testing several readers shows whether your app depends on a lenient one.
Why test with corrupted PDFs?
- Check that your upload form rejects bad files.
- Verify that PDF-to-text or PDF-to-image converters fail safely.
- Test PDF repair tools. See how to fix a corrupted file.
Other formats
Word documents, Excel files and images work differently. Or read our general guide on how to corrupt a file.
FAQ
How do I corrupt a PDF online? Upload it to CorruptAnyFile and click Corrupt My File.
Will Adobe Reader open it? A properly corrupted PDF will fail or offer repair.
Can I corrupt a PDF with a text editor? Yes, by editing the header or xref table, but use a hex editor for binary data.
Is it legal? Corrupting your own files is fine. Do not use broken files to deceive others.