| 58 | private readonly n: number; |
| 59 | |
| 60 | constructor( |
| 61 | private stream: PdfStream, |
| 62 | private options: ObjectStreamParserOptions = {}, |
| 63 | ) { |
| 64 | // Validate stream type |
| 65 | const type = stream.getName("Type"); |
| 66 | |
| 67 | if (type?.value !== "ObjStm") { |
| 68 | throw new ObjectParseError(`Expected /Type /ObjStm, got ${type?.value ?? "none"}`); |
| 69 | } |
| 70 | |
| 71 | // Read required entries |
| 72 | const n = stream.getNumber("N"); |
| 73 | const first = stream.getNumber("First"); |
| 74 | |
| 75 | if (n === undefined) { |
| 76 | throw new ObjectParseError("Object stream missing required /N entry"); |
| 77 | } |
| 78 | |
| 79 | if (first === undefined) { |
| 80 | throw new ObjectParseError("Object stream missing required /First entry"); |
| 81 | } |
| 82 | |
| 83 | this.n = n.value; |
| 84 | this.first = first.value; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Decompress and parse the stream index. |