PDFMove
How to Repair a Corrupted PDF? A Step-by-Step Practical Guide
How-To

How to Repair a Corrupted PDF? A Step-by-Step Practical Guide

7 min read

Why do PDFs get corrupted? Understanding this first helps

One day you open a PDF file on your desktop and you're greeted with "File is corrupted or unsupported," "An error occurred while loading the document," or a completely blank window. This happens more often than you'd think, because the PDF format actually has a fairly fragile internal structure.

At the end of a PDF file there's a map called the "xref table," which shows exactly which byte position every object in the file (page, font, image) starts at. Right after that comes a closing block called the "trailer," which tells the PDF reader things like "the document root starts here, here's how many objects there are." If a file gets cut off mid-copy, gets corrupted while being sent as an email attachment, a scanning program leaves the job half-finished, or a disk error occurs, these two sections are usually the ones that take the damage. Even if the content itself remains largely intact, the reader marks the file as "invalid" because it can't find the map.

In this guide, I'll walk through how to repair a corrupted PDF you have on hand step by step, which errors come up most often, and what to watch out for during the repair.

Step 1: Quickly diagnose the source of the problem

Before jumping into the repair, take a few seconds to check whether the file is actually corrupted or facing a different issue.

  • If the file size is 0 KB or unusually small (for example, the original should be 5 MB but it shows as 12 KB), it was likely cut off during download or copying. In this case, repair may not always be possible, because a large portion of the content is physically missing.
  • If the file opens but some pages look blank, the issue might not be the xref — it could be related to an embedded font or image stream.
  • If you're seeing a "password protected" or "permission error" message, that's a completely different issue — the file isn't corrupted, it's locked.

Typical symptoms of genuine structural corruption are: the file doesn't open at all in a PDF reader, the browser shows "preview could not be generated," or the page count is displayed incorrectly when it does open. If you're seeing these symptoms, you're likely dealing with an xref/trailer problem and can move on to the repair steps.

Step 2: Set aside a copy of the original file

Before attempting a repair, always make a backup of the corrupted file. This is a simple but critical step, because some repair attempts (especially if a desktop program's "save and overwrite" option is checked) can further damage the original file. If you still have the original — even in its corrupted state — you retain the option to try a different method again.

Step 3: Upload the file to the PDF Repair tool

Drag and drop your file into the platform's PDF Repair tool, or upload it using the file picker. Once the upload completes, the tool scans the file's internal structure and checks the state of the xref table and trailer block. There's no need to configure any settings at this stage; the system analyzes the file automatically.

For large files (over 100 MB), the scan may take a few seconds — this is normal, since the system examines the entire file down to its bytes and attempts to rebuild the object map.

Step 4: Understand what the repair process does

In broad strokes, the tool does the following behind the scenes:

  1. Rebuilds the xref table. Instead of relying on corrupted or missing xref entries, it scans the file content to determine the true location of every object and constructs a new, consistent xref table.
  2. Fixes the trailer block. If the root object reference is missing or points to the wrong place, it locates the document catalog again and updates the trailer accordingly.
  3. Filters out incomplete objects. Objects that were cut off or left incompletely written during saving are identified and either removed if necessary or recovered in their nearest valid form.
  4. Validates the page tree. It confirms that pages are listed in the correct order and properly linked to one another, and repairs any broken references.

These operations don't change the file's visual content — they only fix the internal references PDF readers need to parse the file correctly.

Step 5: Download and check the result

Once the repair is complete, download the file and make sure to open and review it. Pay particular attention to the following:

  • Does the total page count match the original?
  • Does the page content (text, images, tables) look complete?
  • If there are bookmarks or links, do they work?

If the file was severely damaged (for example, cut off in the middle, with half the data missing), some pages may not be recoverable even after the tool fixes the xref and trailer. In this case, the tool generally gives you whatever it was able to recover; you'll need to carefully review the file to see which pages were affected.

Common mistakes and pitfalls

Pitfall 1: Repeatedly opening and "saving" the file in different programs. Opening a corrupted PDF in various viewers and doing a "save as" before attempting a proper repair usually doesn't fix the problem — and can sometimes make things worse by also damaging the remaining intact portion of the file. Minimize how much you touch the file before the repair.

Pitfall 2: Assuming a PDF extracted from a compressed (zip) file is itself corrupted. Sometimes the issue isn't in the PDF at all, but in the extraction process. Try reopening the zip file with a different tool and extracting the PDF again; if the problem persists, you're dealing with genuine structural corruption.

Pitfall 3: Email attachments downloading incompletely. On slow connections, large PDF attachments can sometimes show as "complete" without fully downloading. Comparing the file size with the sender is one of the fastest checks to do before moving on to a repair.

Pitfall 4: Assuming repair will fix image quality in scanned PDFs. The repair tool fixes structural errors — it doesn't sharpen blurry scans or perform OCR. If the issue is image quality, that's a different process entirely.

Pitfall 5: Mistaking an encrypted PDF for a "corrupted" one and attempting a repair. If a password-protected file won't open, that's not a structural error; try opening it with the correct password first.

What to do after the repair

Once the file opens successfully again, there are a few precautions you can take to avoid running into the same problem in the future: keep cloud backups of important documents, send large files via a file-sharing link instead of email, and avoid shutting down your computer before a download finishes. For critical contracts or official documents, it's good practice to compare the page count and content of the repaired file against the original source (if available) before archiving it.

Conclusion

A corrupted PDF that won't open due to xref and trailer errors is, in most cases, a problem that can be solved without losing the file's content. What matters is going straight to the repair step without unnecessary intervention, and carefully checking the result afterward. Structural repair can't always bring back data that's physically missing, but in most real-world scenarios — partial copies, interrupted transfers, faulty saves — it makes your file usable again.

Frequently Asked Questions

Does the PDF Repair tool change the content of my file?

No. The tool only rebuilds the xref table and trailer block, which form the file's internal map; it doesn't touch the text, images, or page content. The goal is to make sure readers can parse the file correctly.

My file looks very small in size — can it still be repaired?

If the file was cut off mid-transfer (for example, the original was 5 MB but the downloaded file is only a few KB), that means data is physically missing. The repair tool will try to recover the part that exists, but it can't bring back pages that are entirely missing.

What should I do if some pages still look missing or broken after the repair?

This indicates that portion of the file suffered data loss that can't be recovered. If possible, try to find another copy of the file (email, backup, a different device) and repair that instead; xref repair makes existing data accessible again, but it can't regenerate bytes that are completely lost.

Try this out right away with PDF Onar.

Try PDF Onar