🔧 The Repair Algorithm
1. The XREF Problem
The XREF table works like an index at the back of a book. It tells the PDF viewer exactly which byte address each page starts at. If a file download is interrupted, this table gets mismatched.
2. Linear Scanning
Our repair engine ignores the broken XREF table. Instead, it linearly scans the entire file looking for obj and endobj markers to manually find where the pages are hidden.
3. Structure Normalization
Once the objects are found, we create a brand new XREF table and a new file Trailer. This "Normalizes" the PDF, making it compliant with ISO standards again.