MCPcopy Create free account
hub / github.com/LibPDF-js/core / parseAt

Method parseAt

src/parser/xref-parser.ts:93–110  ·  view source on GitHub ↗

* Parse xref at given byte offset. * Auto-detects table vs stream format.

(offset: number)

Source from the content-addressed store, hash-verified

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.

Callers 2

parseXRefChainMethod · 0.80

Calls 4

parseTableMethod · 0.95
parseStreamMethod · 0.95
moveToMethod · 0.65
peekMethod · 0.45

Tested by

no test coverage detected