@libpdf/core 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +28 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import { createCMSECDSASignature } from "pkijs";
|
|
|
9
9
|
import { base64 } from "@scure/base";
|
|
10
10
|
|
|
11
11
|
//#region package.json
|
|
12
|
-
var version = "0.2.
|
|
12
|
+
var version = "0.2.1";
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/objects/pdf-array.ts
|
|
@@ -30610,22 +30610,36 @@ var DocumentParser = class {
|
|
|
30610
30610
|
else throw error;
|
|
30611
30611
|
}
|
|
30612
30612
|
const lengthResolver = (ref) => {
|
|
30613
|
-
const
|
|
30614
|
-
const cached = cache.get(
|
|
30615
|
-
if (cached
|
|
30613
|
+
const cacheKey = `${ref.objectNumber} ${ref.generation}`;
|
|
30614
|
+
const cached = cache.get(cacheKey);
|
|
30615
|
+
if (cached instanceof PdfNumber) return cached.value;
|
|
30616
30616
|
const entry = xref.get(ref.objectNumber);
|
|
30617
|
-
if (entry
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30621
|
-
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30617
|
+
if (!entry || entry.type === "free") return null;
|
|
30618
|
+
const savedPosition = this.scanner.position;
|
|
30619
|
+
try {
|
|
30620
|
+
let lengthObj = null;
|
|
30621
|
+
if (entry.type === "uncompressed") lengthObj = new IndirectObjectParser(this.scanner).parseObjectAt(entry.offset).value;
|
|
30622
|
+
else {
|
|
30623
|
+
const streamEntry = xref.get(entry.streamObjNum);
|
|
30624
|
+
if (streamEntry?.type === "uncompressed") {
|
|
30625
|
+
let objStreamParser = objectStreamCache.get(entry.streamObjNum);
|
|
30626
|
+
if (!objStreamParser) {
|
|
30627
|
+
const streamResult = new IndirectObjectParser(this.scanner).parseObjectAt(streamEntry.offset);
|
|
30628
|
+
if (streamResult.value instanceof PdfStream) {
|
|
30629
|
+
objStreamParser = new ObjectStreamParser(streamResult.value);
|
|
30630
|
+
objectStreamCache.set(entry.streamObjNum, objStreamParser);
|
|
30631
|
+
}
|
|
30632
|
+
}
|
|
30633
|
+
if (objStreamParser) lengthObj = objStreamParser.getObject(entry.indexInStream);
|
|
30625
30634
|
}
|
|
30626
|
-
} catch {
|
|
30627
|
-
this.scanner.moveTo(savedPosition);
|
|
30628
30635
|
}
|
|
30636
|
+
this.scanner.moveTo(savedPosition);
|
|
30637
|
+
if (lengthObj instanceof PdfNumber) {
|
|
30638
|
+
cache.set(cacheKey, lengthObj);
|
|
30639
|
+
return lengthObj.value;
|
|
30640
|
+
}
|
|
30641
|
+
} catch {
|
|
30642
|
+
this.scanner.moveTo(savedPosition);
|
|
30629
30643
|
}
|
|
30630
30644
|
return null;
|
|
30631
30645
|
};
|