* 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)
| 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. |
no test coverage detected