
How to Edit PDFs Without Corrupting the File
A PDF that will not open is usually one of three problems, and only one is real corruption. How to diagnose it, repair what can be saved, and edit safely.
"Corrupted PDF" usually means one of three quite different things, and only one of them is genuine corruption. Working out which you have takes about a minute and determines whether the file is recoverable.
The three cases
The file is fine, the viewer is not. Opens in one application and not another. By far the most common, and not corruption at all.
The file is truncated. An interrupted download or a copy that failed partway. Every PDF ends with an %%EOF marker; without it, parsers give up. Check the file size against the source.
The internal structure is damaged. A broken cross-reference table, usually from a crash mid-save or a tool that wrote the file badly. This is the one that is actually corruption, and it is often repairable.
Diagnosing
Open the file somewhere else first — a different reader, or a browser. If it opens, the original application is the problem. Then compare the file size against wherever it came from; a mismatch means truncation and no repair will help, because the data is not there.
Repairing genuine structural damage
qpdf rebuilds the cross-reference table, which fixes a good proportion of damaged files:
qpdf --replace-input damaged.pdf
Ghostscript re-interprets and rewrites the file, which recovers documents qpdf cannot:
gs -o repaired.pdf -sDEVICE=pdfwrite damaged.pdf
Both work on a copy. Never repair in place on your only version.
Not corrupting one in the first place
Most avoidable damage comes from three habits.
Save As rather than Save. Incremental saves append; a crash mid-append can leave a file whose latest revision is incomplete. Save As writes a clean file each time.
Do not edit files on a network share or cloud-sync folder. Sync clients rewriting a file mid-save is a real cause of damage. Copy locally, edit, copy back.
Finish one operation before starting another. Interrupting an export is the single most common way to produce a truncated file.
Editing safely
Work on a copy. It sounds obvious, and the reason it is worth stating is that most unrecoverable losses are recoverable-in-principle files where no other copy existed. The editor writes a new file on download rather than modifying your original, so the source is untouched regardless.
Frequently asked questions
Can a corrupted PDF be recovered? Structural damage often can, with qpdf or Ghostscript. Truncation cannot — the missing bytes are missing.
Why does my PDF open in Chrome but not Acrobat? Chrome's parser is more tolerant of malformed structure. It is a sign the file is imperfect but readable.
Does editing risk corrupting a file? Not in normal use. Interruptions and sync conflicts do.
Why did my file get bigger after repair? Repair tools rewrite the whole document and may re-encode content. Compress afterwards if size matters.


