How to repair a PDF
- Choose the PDF that won’t open, or drop it on the box. The check starts at once.
- Read what the check found: each problem in the file is named in plain words, such as a file that was cut off or an index that points to the wrong places.
- Look at the previews of the first pages to see that they came back as they should, and at how many pages were recovered.
- Press Download repaired PDF. The copy is saved with -repaired added to its name.
Why PDFs get damaged
A PDF is a set of numbered parts (pages, fonts, pictures and page contents) followed by an index, called the cross-reference table, that gives the exact position of each part in the file. At the very end, a pointer says where that index starts. A reader jumps to the pointer, reads the index, and then goes straight to whatever it needs. That makes PDFs quick to open, but it also means one wrong number can stop a file from opening at all.
- An unfinished download or copy leaves the file without its end, so the pointer and the index are missing, and so is everything after the place where the copy stopped.
- Extra data at the start, often added by an email program, a web form or a download script, moves every part of the file, so all the positions in the index are wrong.
- Editing a PDF with a tool that doesn’t update the index, including fixing a word in a text editor, shifts the parts after the change.
- A program that saves PDFs badly can state the wrong length for page contents or pictures, or leave the list of pages pointing at parts that aren’t there.
- Transferring a file as text instead of as binary, as some old FTP programs and scripts do, changes line endings inside pictures and compressed page contents. This kind of damage can only be partly fixed, because the bytes inside those parts were changed.
How the repair works
First the file is checked the way a careful reader would: whether it starts with a PDF header or has other data before it, whether its end is there, whether the pointer leads to the index, whether each entry in the index points at its part, whether each stream of data is as long as it says, and whether parts that are referred to are actually in the file. Each problem found is listed, with how many times it occurs.
Then the file is read again from start to finish, collecting every numbered part it holds without using the old index. Packed parts (object streams, which many programs have used since PDF 1.5 brought them in 2003) are unpacked as well. When a stated length is wrong, the end of the data is found by its end marker instead. The pages are then gathered from the file’s list of pages; if that list is missing or broken, every page found in the file is used, in order, and each keeps the size, fonts and resources it was given by the list above it. Finally a new file is written with a new, correct index.
The repaired copy is opened again with PDF.js, the PDF reader built into Firefox, before you can save it. The page count and the previews you see come from that copy, not from the damaged file, so what you see is what other readers will open.
When pages can only be saved as pictures
If too little of the file’s structure is left to rebuild it, but PDF.js can still draw its pages, the tool offers Save pages as pictures. Each page is drawn at 150 dots per inch and put into a new PDF as a picture, at its original size. This keeps how the pages look, which is often enough to print or read a document, but the text becomes part of the picture. To make it searchable and copyable again, run the new copy through OCR PDF.
If the repair doesn’t help
- Get a fresh copy. If the file was downloaded or emailed, download it again or ask the sender to send it again, ideally as an attachment rather than a link that expired.
- Check the file size. A file of 0 bytes, or much smaller than it should be, was never fully saved. Nothing can bring back data that isn’t in the file.
- Look for a backup or an earlier version in your cloud storage or your computer’s file history, which often keep older copies of files.
- Open it in another reader. Readers differ in how much damage they put up with; if one shows the pages, print them to a new PDF from there.
- Repair first, then edit. If another PDF tool on this site, such as Merge PDF or Compress PDF, says a file couldn’t be read, repair it here and use the repaired copy there. The next-step buttons under the result open it in those tools without downloading it again.
- Check that it is really a PDF. A Word document or a web page renamed to .pdf won’t open as a PDF. The tool tells you when no PDF header is found.
Private by design
Damaged files are often important ones: contracts, statements, theses and scans that you can’t easily replace. This tool never uploads them. Your browser reads the file, rebuilds it and shows the previews on your device, and nothing about it is saved or sent anywhere.
PDFs are rebuilt with pdf-lib by Andrew Dillon (MIT license), which uses UPNG, standard fonts data and pako. Pages are checked and drawn with PDF.js by Mozilla (Apache 2.0 license), with its character maps from Adobe, the Foxit and Liberation fonts, color profiles, and image decoders built from PDFium’s JBIG2 (build), OpenJPEG (build) and qcms (build).
Frequently asked questions
Why won’t my PDF open?
Most often the file is incomplete or its internal index is wrong. A PDF ends with a list that says where each part of the file is; when a download stops early, an email program adds text to the start, or a program saves the file badly, that list no longer matches and readers give up with messages such as “the file is damaged and could not be repaired”. This tool finds the parts without trusting the list and builds a new, correct one.
Is my PDF uploaded?
No. Your browser checks and rebuilds the PDF on your own device, so nothing is sent to this website or anyone else. Many other repair sites upload your file to their servers first.
Can every damaged PDF be repaired?
No. A file that was cut off loses whatever came after the cut, and those pages can’t be brought back; the tool tells you how many pages were recovered out of how many the file lists. A file that is mostly zeros or random data, or that is really another kind of file, can’t be rebuilt either. When the structure is too damaged to rebuild but the pages can still be drawn, the tool can save them as pictures.
Will the repaired PDF look the same?
Yes, when the pages are recovered. The text, fonts, pictures, links and form fields are copied as they are, not redrawn, so the text stays sharp and searchable. Only the file’s internal index and list of pages are written again. Check the page previews before you save.
What does “Save pages as pictures” do?
It is a last resort for files whose structure can’t be rebuilt. Each page is drawn the way a PDF reader would draw it and saved as a picture in a new PDF, at 150 dots per inch. The pages look the same, but their text can’t be selected or searched until you run OCR PDF on the new copy.
Can it repair a PDF with a password?
No. The contents of a protected PDF are encrypted, and rebuilding them without the password would only produce unreadable pages. If the file still opens with its password, remove the protection with Unlock PDF first, then repair the unlocked copy if it needs it.
My PDF opens here but not in another app. What now?
If the check finds no damage, the file’s structure is sound and the problem is more likely the other app, an old version of it, or a feature it doesn’t support. Downloading the clean copy that this tool writes can still help, because its index and its list of pages are written fresh.