Skip to content
Server-sideDeleted in 30 minutes

Repair a Damaged PDF

A PDF that will not open is usually not destroyed — its index is wrong, and readers give up at the first bad offset even though the pages are still there. This rebuilds that index by scanning the file for the objects themselves, and tells you in plain words what was broken rather than handing back a silent download.

Use this without the search next time. Prathom Workbench puts Prathom's tools in your toolbar.

Add to Chrome — free

What it does

  • Says what was wrong, not just that something was
  • Rebuilds the cross-reference table by scanning for objects
  • Recovers stream lengths the file failed to declare
  • Tells you honestly when the file was never damaged

How to use Repair PDF

  1. 1

    Add the file

    Drop the PDF in, damaged or not. Nothing checks it is valid first — that check is exactly what would refuse the files this page exists for.

  2. 2

    Read what was wrong

    The report names each kind of damage found and what was done about it, in sentences rather than error codes.

  3. 3

    Download the rebuilt copy

    The result is a clean rewrite containing everything that could be read. Check it opens and that the pages you need are there.

How it works

qpdf ignores the file's own index and scans it for object headers, which announce themselves and can be found without being pointed at. A new cross-reference table is built from what is genuinely present, stream lengths that were never declared are measured, and references to objects that are not in the file are dropped.

Most "corrupt" PDFs are not damaged where you think

A PDF ends with a cross-reference table: a list of byte offsets saying where every object in the file begins. A reader opens the file by seeking to the end, reading that table, and jumping to whichever object it needs.

Which means a single wrong number at the end of the file makes the whole document unopenable, while every page in it sits there intact. This is by far the most common way a PDF "breaks" — an interrupted download or upload, a file copied off failing storage, a program that crashed mid-save, an editor that wrote a table it got wrong.

The repair is to ignore the index and scan the file for the objects directly. They announce themselves; they can be found without being pointed at. A new table is built from what is actually there.

You are told what was wrong

Most repair tools give you a download and nothing else, which leaves you unable to tell whether anything was fixed, whether the file is now trustworthy, or whether you have just re-downloaded your problem.

The report here names each kind of damage found:

  • the cross-reference table was missing or wrong, and was rebuilt
  • n content streams did not declare their length, and the lengths were recovered
  • the file referred to objects that are not in it, and those references were removed

That last one matters, because it is the only case where something is genuinely gone. A page may have lost an image or an annotation — but it was already lost; the repair only stopped the file pretending otherwise.

When nothing is wrong

Sometimes the answer is that the document is fine.

That is a real result and it is reported as one, because you came here after something else refused the file, and "the file is sound, the problem is elsewhere" narrows the search. The usual culprits are an old reader against a newer PDF version, a password (/unlock-pdf), a missing font, or an application policy.

The clean rewrite is still offered in that case. Strict readers sometimes accept a freshly written file where they refuse an original that is technically legal but unusual.

Examples

An interrupted download

broken.pdf
broken-repaired.pdf

A transfer that stops partway leaves the index pointing past the end of the file. Everything that arrived is still readable; the pointer is not.

A file another program calls corrupt

report.pdf
report is structurally sound

Sometimes nothing is wrong with the file and the program refusing it wants something else — an older PDF version, a font, a permission. Being told that is more useful than a repair that changes nothing.

Frequently asked questions

What does "repair" actually change?

Three things, usually. The cross-reference table — the index at the end of the file that says where each object lives — is rebuilt by scanning the document for the objects themselves. Content streams that did not declare their length get the correct length measured and written in. References to objects that are not in the file are dropped. The page content itself is copied across unchanged.

Can it recover a page that is genuinely missing?

No, and nothing can. If the bytes for a page never arrived or were overwritten, there is nothing to rebuild from — repair recovers structure, not content. What it does is stop a readable document being rejected because its index is wrong, which is the far more common failure.

It says my file is fine. What now?

Then the problem is the program refusing it, not the document. Common causes: the reader is old and the file uses a newer PDF version; the file is password protected (/unlock-pdf); a font it wants is missing; or a viewer is applying a policy. The clean rewrite offered here is still worth trying — some strict readers accept it where they refuse the original.

Why does it not check the file is a valid PDF first?

Because that check would refuse every file this page exists for. Every other tool here validates the upload before touching it; this one has to accept exactly what that validation rejects, or the repair tool would tell people their damaged PDF was damaged and stop.

What if it cannot be rebuilt at all?

You are told plainly, rather than given a file that opens to nothing. That happens when there is not enough readable structure left to find pages in — a file truncated near the start, or one that is not really a PDF. If you have an older copy or the source document it was made from, that is the better starting point.