* Parse xref at given byte offset. * Auto-detects table vs stream format.
(offset: number)
| 91 | * Auto-detects table vs stream format. |
| 92 | */ |
| 93 | parseAt(offset: number): XRefData { |
| 94 | this.scanner.moveTo(offset); |
| 95 | |
| 96 | // Peek to detect format |
| 97 | const firstByte = this.scanner.peek(); |
| 98 | |
| 99 | // 'x' = 0x78 starts "xref" |
| 100 | if (firstByte === 0x78) { |
| 101 | return this.parseTable(); |
| 102 | } |
| 103 | |
| 104 | // Digit starts "N M obj" (stream format) |
| 105 | if (firstByte >= DIGIT_0 && firstByte <= DIGIT_9) { |
| 106 | return this.parseStream(); |
| 107 | } |
| 108 | |
| 109 | throw new XRefParseError(`Unknown xref format at offset ${offset}`); |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Detect the XRef format at a given offset without fully parsing. |
no test coverage detected