How to Repair a Corrupted PDF File
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.
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.
Author: ihatepdf team
Other tools say the file is truncated. What now?
Go to “Repair PDF”. Every PDF upload is checked for the end-of-document marker, and a file without one is rejected on the spot. Repair is the only tool exempt from that check, because those are exactly the files it fixes.
How does aggressive mode differ from safe mode?
Safe mode parses the document structure afresh and keeps the text. Aggressive mode renders every page to an image and builds a new PDF from those: it always opens, but no text remains inside, so nothing can be selected or found by search.
Can any damaged PDF be repaired?
No. If part of the data is physically missing there is nowhere to bring it back from; the structure is rebuilt around the content that survived. Check the result for warnings about blank pages or missing pictures, and compare its page count and content with what you expect.
The file is password protected and will not open. Will repair help?
No. An encrypted document stops the job with a request to lift the protection through “Unlock PDF” first. Repair does not require the file to open, but it does require it not to be encrypted.
How long are files stored?
Files are used only for the selected operation and are automatically deleted after processing is finished. We do not use uploaded documents to train AI models.