Skip to content

Repair PDF: fix a corrupted or damaged PDF file

"There was an error opening this document. The file is damaged and could not be repaired." When a PDF that arrived by e-mail or WhatsApp, or downloaded from a portal, refuses to open, the pages are often still inside it. This tool rebuilds the file around them and tells you, page by page, what it fixed and what could not be saved.

Quick answer

To repair a PDF, drop the damaged file here. The tool scans every object in the file, rebuilds the cross-reference table, trailer and page list, keeps the pages of a download that was cut off, corrects wrong stream lengths and removes junk saved in front of the file, then writes a clean PDF with text that stays searchable. If the structure is beyond saving, the pages that can still be drawn are saved as pictures instead, and you are told. Password-protected files must be unlocked first.

Files never leave your device

Editor: Abuzar, founder of NeedMyToolsHow we check facts

or drop them here. They are repaired on your device and never uploaded.

Your PDF is read and rebuilt inside this browser tab with pdf-lib and pdf.js. Nothing is uploaded.

How to use the Repair PDF

  1. Tap "Choose damaged PDF files" or drop one or more files on the box.
  2. Wait a moment while each file is checked and rebuilt. Read the report: what was fixed, and what was lost.
  3. Press "Download repaired PDF". If pages were lost, you can also try the image method and keep whichever copy is better.

Why a PDF gets damaged

A PDF is not read from top to bottom like a text file. At its end sits an index, the cross-reference table, that gives the exact byte position of every object (pages, fonts, pictures), followed by a trailer that names the first object to read and a startxref line that says where the index starts, then the %%EOF marker. The PDF standard, ISO 32000-1, describes this layout in section 7.5. So the damage that matters most is usually at the end: a download that stopped early, an attachment cut by a mail server, a USB stick pulled out during copying, or an app that added data to the file without updating the index. A single wrong number in the index can make a strict reader refuse a file whose pages are all intact.

What this tool repairs, and how

Instead of trusting the index, the repair reads the file from the first byte to the last and collects every object it can parse, the way a careful reader recovers a book with a torn table of contents. Bytes saved in front of %PDF (an e-mail or web header, for example) are dropped, and a missing or damaged %PDF header line is written again. When the file stops in the middle of an object, the cut part is set aside, and if it is a compressed object stream the objects that arrived whole are kept. Streams whose declared length is wrong are measured again from the endstream keyword. Objects that cannot be read at all are removed; the standard says a reference to a missing object is read as an empty value, so the rest of the file still works. The document catalog and title information are found again if their pointers were lost, and a broken page list is rebuilt from the page objects that survived, keeping their order and their inherited size and resources. Page drawing instructions that were damaged are cut back to the last complete line. Finally a new file is written with a fresh index, trailer and %%EOF, and checked by opening it again before you download it.

The report: what was fixed and what was lost

Each file gets its own report. "What was fixed" lists the faults found, such as how many index entries pointed to the wrong place or how many bytes of junk were removed. "What was lost" is just as plain: how many of the pages the file says it has could not be recovered, which pages came back blank or only partly drawn, and how many fonts or pictures were missing. If a file shows no damage at all, we say so and do not pretend to have fixed something: the problem may be the app you used to open it, or an older copy. Every repaired file in our tests is opened again by two independent PDF readers, Poppler and pypdf in strict mode, and its text is extracted to make sure the words, including Arabic, are still there.

The image method, used only as a last resort

Sometimes the structure is too far gone to rebuild, yet a viewer can still draw some pages. Then the tool asks pdf.js, the PDF engine used by Firefox, to draw every page it can at 150 dpi and puts each picture on a page of the same size in a new PDF. This is labelled clearly, because it has a price: the text becomes part of a picture, so it can no longer be selected, searched or copied, links and form fields are gone, and the file may be larger. When a structural repair lost pages or content, you can try the image method as well and keep whichever copy is better. If you need searchable text again afterwards, run the image version through OCR.

What cannot be repaired

No tool can bring back bytes that are not in the file. If a download stopped at 40%, the pages stored in the missing 60% are gone, and the report tells you how many. A file that was overwritten with zeros, or a Word or image file renamed to .pdf, has nothing to rebuild. Password-protected PDFs are encrypted, so their objects cannot be checked or rewritten without the password: unlock the file first if you know the password, then repair the unlocked copy. The best fix for a broken download is often a fresh copy from the sender or the portal; repair is for when no other copy exists.

Privacy and limits

The repair runs entirely in your browser with pdf-lib and pdf.js; the file is never uploaded, which matters for contracts, bank statements and ID copies. Files up to 200 MB are accepted. In our tests on an ordinary computer a 5-page file is repaired in well under a second and a 200-page file in about a second. You can drop several files at once and download each one separately.

Frequently asked questions

How do I repair a PDF file that will not open?

Drop it on this page. The tool rebuilds the file's index, trailer and page list from the objects it finds, keeps every complete page, and gives you a repaired PDF to download with a list of what was fixed and what was lost. It is free and the file stays on your device.

Can a PDF that only partly downloaded be recovered?

Partly. The pages that arrived complete are kept and the report tells you how many pages of the original are missing. The part that never arrived cannot be rebuilt by any tool, so download the file again if you can.

Will the repaired PDF still have searchable text?

Yes, when the structure can be rebuilt: text, fonts, links and pictures are kept as they were. Only the image method, used when nothing else works, turns pages into pictures, and the report says so.

Can I repair a password-protected PDF?

Not directly. Its contents are encrypted, so they cannot be rebuilt without the password. If you know the password, remove it with Unlock PDF first and then repair the unlocked copy.

Why does my PDF reader say the file is damaged when this tool finds nothing wrong?

The file itself may be fine and the problem may be elsewhere: an outdated reader, a preview app that does not support the PDF's features, or an older, broken copy of the file. Try another reader, or download the re-saved copy this tool gives you.