How to repair a corrupted PDF
In short: To repair a damaged PDF, open repair-pdf and leave safe mode selected: it parses the file structure afresh and keeps the text. Aggressive mode renders the pages to pictures, so the result always opens but has no text left in it.
Cluster
troubleshooting
Recovery paths for broken files, failed runs, and rerun decisions.
Primary tool
Repair PDF
Open the tool from this article and complete the operation in the current locale.
Open toolTable of contents
How to Repair a Damaged PDF
A file that opened yesterday throws an error today. Or it opens in nothing at all, including the program that made it. Some of those files are fixed in a minute, some cannot be fixed at all, and the difference is visible in advance if you know where to look.
Why other tools refuse to accept the file
There is a detail here worth knowing before anything else. When any PDF is uploaded, the check covers more than the file header: the end-of-document marker has to be present too. A file that starts like a PDF and stops halfway is rejected immediately with a message saying the document is truncated or incomplete.
Exactly one tool is exempt from that check, and it is repair-pdf. Its whole reason for existing is handling files that fail the door policy. So the sequence runs backwards from the usual one: a file no other tool will accept is not a reason to look for a different service, it is a pointer to repair.
The same goes for passwords. Repair does not require the file to open, but it does require it not to be encrypted: a document under an open password stops the job with a plain request to lift the protection through unlock-pdf first. A file that merely fails to parse, on the other hand, is accepted for work.
Two modes, and the difference between them is fundamental
There are exactly two modes, and they are not weaker and stronger. They are two different ways of getting a file, and the second sacrifices content to guarantee that the result opens.
| Mode | What it does | What it costs |
|---|---|---|
| Safe | Parses the document structure afresh and writes it out clean | Nothing, when the structure yields to parsing |
| Aggressive | Renders every page to a picture and builds a new PDF out of the pictures | The text: there is none left in the result |
The second mode should be taken literally. It does not try to save the document's objects, it throws them away. Pages are rendered to images at double resolution and a new file is assembled from those images. A document like that always opens, because there is nothing inside it but pictures.
What the measurement on a broken file showed
The subject was a four page document of 4 KB with its cross reference table damaged, the internal index a program uses to find objects inside the file.
| Repair used | Result size | Text in the result |
|---|---|---|
| Safe, rebuild on | 3.6 KB | Present, searchable |
| Safe, rebuild off | 4.1 KB | Present, searchable |
| Aggressive | 626 KB | Gone entirely |
The gap between the first row and the third is a hundred and seventy times over in weight and total in content. Trying to pull text out of the aggressive result returns nothing: there are no letters there, only pixels that look like letters.
The same document, truncated at 98 percent of its length and left without an end marker, came back whole from safe mode: all four pages with their text. That is the measure of how often the second mode is actually needed.
The order of recovery
1. Open repair-pdf and upload the file. The incomplete-document error will not appear here. 2. Leave safe mode selected. It is the default, and it is where to start. 3. Leave the rebuild and recompress switch on. 4. Run the job and download the result. 5. Open the file and try to select the text, not merely look at the page. 6. Only if that came to nothing, go back and repeat in aggressive mode.
Step five matters more than it looks. A document that opens and looks right is not yet repaired: what has to be checked is selection and search, because those are what separate a fixed document from a handsome picture.
What the rebuild switch does
Safe mode carries a separate rebuild and recompress switch, on by default. It controls whether the page streams are written out anew or carried across as they are.
In the measurement above the rebuild gave 3.6 KB against 4.1 KB, about a tenth smaller. On large documents the gap is more noticeable, and the point is less the saving than the cleanliness: a freshly assembled file does not drag along the remains of the old structure, which is what kept some viewers from opening it.
There is one case for turning it off: if something in the document looks wrong after a repair with the rebuild on. A second run without it then shows whether that step is to blame.
In aggressive mode the switch does nothing, since the document is built from scratch there regardless.
What happens before you press anything
The service has a built in safety net that works in every tool, not only in repair. If a file fails to parse on the first open, one automatic repair attempt is made with a different engine: the document is re-saved with junk objects cleaned out, and if it reads after that, processing carries on as though nothing had happened.
The practical consequence is that some slightly broken files fix themselves during any operation and you never find out. Going to repair deliberately makes sense when that automation did not manage and the job stopped with a message about the file being unreadable.
The net helps most often with files out of engineering and drafting programs: those can be formally correct but carry fields so long that an ordinary parser refuses to read them.
What repair cannot do
It does not bring back data that is not there. If the file was truncated during a download and half the pages are physically missing, no mode will invent them: the structure is rebuilt around what survived, and the result comes out shorter than the original.
Checking that is easy. Look at the page count in the result. If there are fewer than there should be, what is missing is lost, and the search from there is for the original or a backup rather than for settings.
It also cannot tell in advance how badly a file is damaged. Whether it will yield is not predictable from the look of the file, so judge the result rather than the input.
Nor does it repair the content of a page. When the streams themselves or the embedded fonts are damaged, the document opens but the text stays unreadable. Aggressive mode is unexpectedly useful in that situation: it fixes whatever the program can still draw and turns it into a stable file. Turning that back into text is a job for recognition through ocr-pdf, at a quality below the original but well above nothing.
One last word on weight. The aggressive result is heavy because it consists of images. If that file has to travel anywhere, run it through compress-pdf; documents made of pictures are exactly where compression works best.
FAQ
More from this cluster
troubleshooting
How to fix sideways PDF scan pages
Rotation in a PDF is a separate page property rather than rotated content. That explains both why viewers disagree and why two 90-degree turns add up to 180.
troubleshooting
Why a PDF fails to upload or process
The file was refused and the message explains nothing. What separates a refusal at upload from one during processing, why the file extension settles nothing, and what "the file is damaged" actually means.
troubleshooting
PDF won't upload to the admission portal: fixes
A university application is a list of requirements, not a folder of files. How to fit a page limit, what to do with translations, and why an admissions office sees more in your file than you sent.
Related tools
Repair PDF
Try to repair a PDF if the file opens with errors, renders incorrectly, or fails during later processing.
Unlock PDF online
Remove restrictions from a PDF if you have the right to work with that file. This tool is for your own documents and permitted work scenarios.
OCR PDF online
OCR PDF keeps the PDF task in one browser flow: upload the source file, check options, run processing, and download the result.
Compress PDF online
Reduce the size of a PDF so it is easier to email, upload or store. Especially useful for scans and documents with images.
What to do next
All tools
PDF tools catalog: merge, compress, split, convert, rotate, protect and unlock PDF files online, all directly in your browser.
FAQ
Answers to common questions about iHatePDF: whether registration is required, how files are processed, where to check limits, and whether it's safe to upload documents.
Contact
Contact iHatePDF about processing errors, choosing a tool, security, business inquiries, and suggestions for new features.