Cross-Reference Table (xref)
The internal index inside a PDF file that maps object numbers to their byte positions — the most common point of PDF corruption.
Last updated
What Is a PDF Cross-Reference Table?
The cross-reference table (xref) is an internal index inside every PDF file. It maps each object number to its exact byte offset within the file, allowing a PDF viewer to jump directly to any object (a page, an image, a font) without scanning the entire file.
Structure
In a traditional PDF, the xref appears near the end of the file:
xref
0 6
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000266 00000 n
0000000496 00000 n
Each line after the header records a byte offset (0000000009) and status (n = in use, f = free/deleted).
The trailer section follows the xref and tells the viewer the byte offset of the xref itself:
startxref
553
%%EOF
Why xref Corruption Is So Common
The xref table is written at the end of the PDF creation process. If the application writing the file crashes, loses network connection, or runs out of disk space before completing, the xref is the first section to be lost. The file body (pages, images) is often intact — only the directory is missing.
What Happens With a Broken xref
A PDF viewer reads the trailer to find the xref, then uses the xref to find all objects. Without a valid xref:
- Strict viewers (Adobe Reader) refuse to open the file
- Lenient viewers (Chrome, Preview) attempt object scanning — scanning linearly through the file to reconstruct the object list
- The file "opens in Chrome but not Adobe Reader" is a classic broken-xref symptom
How Repair Works
A PDF repair tool scans the file body, identifies all objects by their header patterns (n 0 obj), rebuilds the object table, and writes a new valid xref and trailer — restoring full compatibility with strict viewers.