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

Method parseObjectAt

src/parser/brute-force-parser.ts:386–413  ·  view source on GitHub ↗

* Parse the object at the given byte offset. * Returns the dictionary if it's a dict, null otherwise. * Collects warnings from the parser.

(offset: number, objNum: number, genNum: number)

Source from the content-addressed store, hash-verified

384 * Collects warnings from the parser.
385 */
386 private parseObjectAt(offset: number, objNum: number, genNum: number): PdfDict | null {
387 this.scanner.moveTo(offset);
388
389 const reader = new TokenReader(this.scanner);
390
391 // Skip "N M obj"
392 reader.nextToken(); // objNum
393 reader.nextToken(); // genNum
394 reader.nextToken(); // "obj" keyword
395
396 const parser = new ObjectParser(reader);
397 parser.recoveryMode = true;
398 parser.onWarning = msg => {
399 this.warnings.push(`Object ${objNum} ${genNum}: ${msg}`);
400 };
401
402 const result = parser.parseObject();
403
404 if (result === null) {
405 return null;
406 }
407
408 if (result.object instanceof PdfDict) {
409 return result.object;
410 }
411
412 return null;
413 }
414
415 /**
416 * Parse the full object (including streams) at the given byte offset.

Callers 2

findRootMethod · 0.95

Calls 4

nextTokenMethod · 0.95
parseObjectMethod · 0.95
pushMethod · 0.80
moveToMethod · 0.65

Tested by

no test coverage detected