PDF

Fix PDF "Cross-reference table not found" Error

Error message: Cross-reference table not found

Fix PDF “Cross-reference table not found” Error

A PDF reader has refused your file with the error cross-reference table not found (or the closely related xref not found). This error has a precise technical meaning: the reader read your file, looked for the small index that tells it where everything else is, and couldn’t find it. The content of the file is usually still intact. The map to it is the only thing missing — and rebuilding the map is exactly what repair tools do.

Quick fix

The fastest path is to rebuild the xref with qpdf, a free command-line tool that does this in one command. After installing qpdf:

qpdf --linearize input.pdf output.pdf

--linearize forces qpdf to read the file end-to-end, scan for object boundaries, and write a new file with a freshly-built cross-reference table. For a typical mid-sized PDF this takes well under a second. Open output.pdf in your reader.

If the file recovers, you’ll see qpdf print warnings ending in qpdf: operation succeeded with warnings; resulting file may have some problems with exit code 3. The “warnings” are qpdf telling you what it had to reconstruct; the output file is fine in the large majority of cases. See the complete guide to qpdf for installation and other recipes.

If qpdf reports it can’t recover

If qpdf exits with code 2 and a message like unable to find trailer dictionary while recovering damaged file, the damage is more severe than a missing xref alone. Try in this order:

  1. Re-obtain the file. If the file came from a download, email, or transfer, the most common cause of severe damage is that you don’t have the whole file. A fresh copy often opens without any repair.

  2. Open in Adobe Acrobat. Acrobat is unusually tolerant of structural damage and runs an automatic repair on open. If Acrobat can recover the file, save the result through File > Save As (Acrobat Pro required for save) and you have a clean copy.

  3. Try Ghostscript re-rendering. Ghostscript takes a fundamentally different approach: it re-interprets the file at the rendering layer rather than working from its structure. This sometimes recovers files qpdf cannot. The cost is real — form fields, annotations, digital signatures, bookmarks, and tagged accessibility structure are commonly lost. Use only when you’ve exhausted the structural options. The basic recipe is:

    gs -o repaired.pdf -sDEVICE=pdfwrite input.pdf

A diagnostic-only command

To investigate the file before attempting any repair:

qpdf --check input.pdf

This reads the file and reports what’s wrong without writing anything. If the output ends in Attempting to reconstruct cross-reference table followed by operation succeeded with warnings (exit code 3), the file is recoverable — you just haven’t run the repair yet. If it ends with cannot be processed (exit code 2), the file is severely damaged.

Why this happens

The cross-reference table sits near the end of every PDF and lists the byte offset of every object in the file. The reader uses it to navigate. The xref is found via a pointer at the very end of the file: a line containing the startxref keyword followed by the byte offset of the xref, then %%EOF.

When a reader reports cross-reference table not found, one of these things has happened:

  • The file was truncated — the startxref pointer and the xref it points to are simply not in the file. Common with interrupted downloads, partial transfers, or files written when a disk was full.
  • The startxref pointer is wrong — it points to a location in the file where no xref exists. Often the result of a broken incremental update or a malformed PDF generator.
  • The xref bytes themselves are corrupted — the pointer is correct but what’s at that location no longer parses as a valid xref. Usually transit corruption, bit flips, or a partially-overwritten file.

In all three cases the actual page content, fonts, and images are usually still in the file. They’re just unreachable because nothing tells the reader where to find them. Repair tools work by scanning the raw bytes for object boundary markers (the N 0 obj pattern), recalculating the offsets, and writing a fresh xref pointing to the right places. Once the index is correct, the file opens.

This is also why the same broken file can open in Acrobat and fail in stricter readers like PDF-XChange or some browser plugins: Acrobat performs xref reconstruction silently, while strict readers refuse and surface the error.

When the file genuinely can’t be recovered

Two scenarios actually cannot be repaired by any tool:

  • Severe truncation. If more than the last ten percent of the file is missing, the content itself is gone, not just the index. The xref reconstruction has nothing to find. The only option is a fresh copy.
  • Encrypted-by-malware files. Ransomware-encrypted files look like corruption to repair tools but are actually intact files in a different encrypted form. Repair tools cannot recover them; you need either the decryption key or a backup.

For everything else — the substantial majority of “cross-reference table not found” cases — qpdf or Acrobat will recover the file in seconds.

Preventing this in future

Save downloads to disk before opening them, especially for large files. Browser plugins and email previews can present a half-downloaded file as if it were complete; saving forces the full file to land before any reader touches it.

When PDFs travel through automated pipelines (web export, email gateway, file conversion), occasional corruption is inevitable. Build expectation of repair into the workflow rather than treating each broken file as an emergency.

For PDFs you create yourself, prefer mature PDF generators (Adobe products, qpdf, pikepdf, well-maintained libraries like PDFKit) over experimental ones. PDF specifications are unforgiving, and immature generators routinely produce files that strict readers reject.

The PDF Structure 40 error from PDF-XChange Editor is the same underlying problem in a vendor-specific wrapper. The Expected n 0 obj or expected endobj errors from qpdf indicate object boundary damage rather than xref damage but are repaired by the same tools. For a wider treatment of how PDF structure works and why it fails, see the PDF repair complete guide.

Last verified: April 2026