By · Updated

Repair PDF

Fix a Corrupted or Damaged PDF That Will Not Open and Recover Its Pages

No ratings yet

OneTask is free, with no sign-up, and built by one person.
If this tool saved you time, a coffee helps keep new ones coming.

How the Repair PDF works

Repair PDF files that will not open, open blank, or show "file is damaged" errors. Drop the file in and the tool reads every object it can find, rebuilds the document around the pages, and gives you a clean copy. The file never leaves your browser.

A PDF is not read from top to bottom like a text file. At the very end sits a cross-reference table, a list of byte offsets that tells a reader where each object starts. The reader jumps to the end, reads the table, then jumps straight to the objects it needs. That design makes large files fast to open, but it also means a few wrong bytes near the end can make a perfectly good document look broken. An interrupted download, a sync conflict, an email gateway that trims the last few kilobytes or a script that edits the file without updating the table are enough.

How to repair PDF files

  1. Drop the damaged PDF into the box.
  2. Run the tool. It reads the file, recovers the pages and writes a new PDF.
  3. Download the copy ending in -repaired.pdf and open it to check every page.

The stats show how many pages were recovered and whether they came from the document's page list or from a scan of the file.

What it fixes

Damage Typical cause What the tool does
Wrong offsets in the xref table Scripted edits, text-mode transfer Reads objects in order
Missing table or trailer Truncated download or attachment Rebuilds both from the objects
Junk before %PDF- Servers or mail tools adding a header Drops it
Broken page list Damaged catalog or page tree Scans the file for page objects
Inherited page settings lost Page tree removed or reordered Copies size and rotation

How it works

The tool opens the file with pdf-lib, an open-source PDF library that reads objects in the order they appear in the file rather than trusting the cross-reference table. A file whose table points to the wrong places, or has no table at all, still gives up its objects this way.

If the document's page list is intact, pages are taken from it in the normal order. If the list is missing or broken, the tool scans every object for one marked as a page and puts them in the order they were created, which nearly always matches the original reading order. Each page is then copied into a brand new document together with everything it draws on: fonts, images, drawings and any page size or rotation it inherited from its parents. Objects that nothing points to are left behind, so the repaired file can be noticeably smaller than the damaged one.

The new file gets a fresh cross-reference table and trailer, so any reader can open it. The title, author, subject, keywords and creator are copied over when they can still be read.

Tips and pitfalls

Try the repaired file in more than one reader. Browsers, Preview and Acrobat react differently to damage. If the original opened in one of them but not another, the repaired copy should open in all three.

Check the page order after a scan. When the stats say pages came from scanned objects, the original page list was lost. Pages are ordered by when they were written, which is right for almost every file, but documents that were edited and saved many times can come back slightly out of order. The PDF Page Extractor and PDF Merger can reorder them.

A truncated file loses its tail. If a download stopped half way, the pages and images stored after the cut are simply not in the file. They cannot be recovered, and the matching pages are either missing or show blank areas where an image should be.

Encrypted files cannot be repaired here. A password-protected PDF has its content scrambled, so the objects cannot be copied safely. Unlock it first, then repair the unlocked copy.

Some extras are not carried over. The repaired file holds the pages, so bookmarks, form fields, file attachments and the document's tagged structure for screen readers are left out. If you need a form, fill it in the original if it opens anywhere, or re-export it from the source.

Re-download before you repair. Many damaged PDFs are just incomplete transfers. If the file came from a website or an email, getting it again is the quickest fix and keeps everything intact.

Reading the result

Pages recovered is the number of pages in the new file. Compare it with the page count you expected. Page source says "Page tree" when the original page list was usable and "Scanned objects" when the tool had to find the pages itself. The two sizes show how much unused data was dropped. A note under the result says if junk was removed from the start of the file or if any page could not be copied.

If the tool reports that the file is too damaged to read, the problem is usually that it is not a PDF at all, for example an HTML error page saved with a .pdf name, or that the content was lost before the file reached you.

FAQ

Will repairing a PDF change how the pages look?

No. The page content, fonts and images are copied byte for byte into the new file. Only the file's internal index and page list are rebuilt, so text stays selectable and images keep their original quality.

Why is the repaired PDF smaller than the original?

Damaged and often-edited PDFs carry objects that no page uses any more, such as old revisions and deleted images. The repair copies only what the pages need, so that leftover data is dropped.

Can it recover a PDF that shows only blank pages?

Sometimes. If the pages are blank because the reader could not find their content, rebuilding the index fixes it. If the content was never saved, or was cut off in a partial download, there is nothing left to recover.

Is my PDF uploaded anywhere?

No. The file is read and rebuilt by JavaScript running in your browser tab. Nothing is sent to a server, so private or confidential documents stay on your own computer while they are repaired.

See also: all PDF tools, Images, Audio, Video & Screen, SVG, Simulations & Screensavers, Generative Art, Chart Makers, 3D Model Viewers, Drawing Pads, Mockups & 3D Making, Diagram Makers, 3D Science, Tracker Music.

Related tools