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

Method constructor

src/parser/object-stream-parser.ts:60–85  ·  view source on GitHub ↗
(
    private stream: PdfStream,
    private options: ObjectStreamParserOptions = {},
  )

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 2

getNameMethod · 0.65
getNumberMethod · 0.45

Tested by

no test coverage detected