How to Repair a Corrupted PDF
A corrupted PDF has internal structural damage — the cross-reference table, header, object streams, or trailer are missing or inconsistent, so a reader cannot locate the pages. Repair means rebuilding that structure from whatever objects survive. Sometimes it works; sometimes the damage is too severe and pages are lost. This guide explains the four kinds of corruption, the local tools that can rebuild a damaged file, and an honest fallback when repair is impossible.
The four kinds of PDF corruption
1. Header corruption
The first line of a PDF is %PDF-1.x (where x is the version). If this header is missing or damaged, viewers refuse to open the file because they cannot identify it as a PDF. This is the easiest damage to fix: open the file in a text editor and add the header line %PDF-1.7 at the very top. Save and try opening again.
2. Cross-reference (xref) table corruption
The xref table is the PDF's index — it tells the viewer where each object (page, font, image) lives in the file. If the xref is missing or points to wrong offsets, the viewer cannot find the pages. This is the most common form of corruption, usually caused by a truncated download or a writer that crashed before finishing the file.
Fix: rebuild the xref with ghostscript (gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in.pdf) or Adobe Acrobat Preflight. Both tools scan the file for objects and write a fresh xref. If the objects themselves are intact, this fully repairs the file.
3. Object stream corruption
Modern PDFs pack multiple objects into compressed object streams to save space. If a stream is damaged, the objects inside are unrecoverable — they are gone. Symptoms include a file that opens but shows blank pages or missing fonts. Repair tools can rebuild the xref but cannot resurrect objects that were never written correctly.
Fix: try ghostscript or Acrobat Preflight. If pages are still blank after repair, those pages' objects were lost in the original damage. Restore from backup or re-export from the source application.
4. Trailer corruption
The trailer is the small block at the end of the file that points to the xref and the root catalog. A file without a valid trailer is unreadable, even if every object is intact. This typically happens when a write was interrupted — the file ends abruptly mid-object instead of with %%EOF.
Fix: ghostscript and Acrobat can often rebuild a missing trailer. If the file ends mid-object, you may need to truncate the damaged object first, then rebuild. Theqpdf --check command reports which structural elements are missing.
Local repair tools
Every tool below runs on your machine. None of them upload your document. That matters: a corrupted file may still contain readable sensitive content, and uploading it to a "free online PDF repair" service sends that content to a stranger's server before you know what survived.
1. ghostscript (free, cross-platform, command line)
The most reliable free repair tool. It re-reads the file, rebuilds the xref and trailer, and writes a clean copy. On Windows:
gswin64c -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=out.pdf in.pdf
On macOS and Linux, replace gswin64c with gs. ghostscript cannot repair damaged object streams, but it fixes most xref and trailer damage.
2. Adobe Acrobat Pro (paid, Preflight)
Acrobat Pro's Preflight feature has a "Repair PDF" profile that rebuilds the xref, re-embeds missing fonts, and flattens broken annotations. Open the file, then Tools > Print Production > Preflight, and run the repair profile. Acrobat is the most capable repair tool but is not free.
3. PDF24 Creator (free, Windows)
PDF24 includes a "Repair PDF" tool that wraps ghostscript with a GUI. Open PDF24, choose Repair PDF, drop in the file, and save the result. Useful if you are on Windows and prefer not to use the command line.
4. Recovery Toolbox for PDF (paid, Windows)
A dedicated commercial repair tool that handles severe damage ghostscript cannot fix. It scans the file byte-by-byte for recognizable object signatures and reconstructs what it can. Use this only when the free tools have failed and the file is important enough to justify the license.
Step-by-step: repair with ghostscript
- Install ghostscript. On Windows, download from ghostscript.com. On macOS,
brew install ghostscript. On Linux, use your package manager. - Open a terminal. Navigate to the folder containing the corrupted PDF.
- Run the repair command.
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=repaired.pdf corrupted.pdf - Check the result. Open
repaired.pdfin Acrobat Reader or Preview. If it opens and shows all pages, the repair succeeded. - If pages are still missing, the original object streams were damaged. Restore from backup or re-export from the source application.
Fallback: extract undamaged pages with IXPDF
When full repair fails, you can sometimes recover the undamaged pages. Open Extract Pages, drop in the corrupted file, and try extracting page 1. If it succeeds, try ranges (1–5, 6–10) until you hit the damaged section. IXPDF reads the file locally in your browser — no upload — and writes a new PDF from whatever pages it can parse. Pages in the damaged region will fail; the rest will be recovered.
Common mistakes
- Uploading the corrupted file to an online repair service. The file may still contain readable sensitive content. Use a local tool.
- Overwriting the only copy. Always write the repaired file to a new name. Keep the corrupted original until you have verified the repair.
- Assuming repair will restore lost content. If object streams were damaged, the content is gone. Repair rebuilds the structure; it cannot resurrect missing bytes.
- Trying to repair a password-protected file.Encryption is not corruption. Decrypt first (with the password), then repair if needed.
Try to recover undamaged pages
IXPDF's Extract Pages tool runs locally in your browser. Drop in the corrupted file and try to pull out the pages that survived. Your file never leaves your device.
Open Extract PagesTry it now
Ready to put this into practice?
Run the tool locally in your browser — no upload, no account, no watermarks. Your file never leaves your device.