modern-pdf-lib 0.19.9 → 0.22.9
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/README.md +16 -5
- package/dist/{batchOptimize-xo6BXbGZ.cjs → batchOptimize-Ba_pWw71.cjs} +2 -2
- package/dist/{batchOptimize-7U_kD3_j.mjs → batchOptimize-CxyY4fZe.mjs} +2 -2
- package/dist/browser.cjs +9 -9
- package/dist/browser.mjs +9 -9
- package/dist/cli/index.cjs +2 -2
- package/dist/cli/index.mjs +2 -2
- package/dist/{compressionAnalysis-eXYyDsrh.cjs → compressionAnalysis-B84FPXaQ.cjs} +4 -4
- package/dist/compressionAnalysis-BBv4BkQP.d.mts.map +1 -1
- package/dist/{compressionAnalysis-Bw2alOxt.mjs → compressionAnalysis-ChkscEa1.mjs} +4 -4
- package/dist/compressionAnalysis-CtJ2X9l2.d.cts.map +1 -1
- package/dist/create.cjs +3 -3
- package/dist/create.mjs +3 -3
- package/dist/{deduplicateImages-BX3Zg8Qp.mjs → deduplicateImages-CmTeo6Tx.mjs} +2 -2
- package/dist/{deduplicateImages-B5lmzL9j.cjs → deduplicateImages-cKsnD6Ep.cjs} +2 -2
- package/dist/{imageExtract-B6OvUEp-.mjs → imageExtract-Dnk_Ssv7.mjs} +2 -2
- package/dist/{imageExtract-PxdBvpHj.cjs → imageExtract-zEb1gnkb.cjs} +2 -2
- package/dist/index.cjs +9 -9
- package/dist/index.mjs +9 -9
- package/dist/{layout-Inbqegsk.cjs → layout-CuAVk_Or.cjs} +2 -2
- package/dist/{layout-BZ8tTeAk.mjs → layout-DgX_0jfK.mjs} +2 -2
- package/dist/parse.cjs +4 -4
- package/dist/parse.mjs +4 -4
- package/dist/{pdfDocument-DOg240g9.mjs → pdfDocument-BFxHD_2u.mjs} +101 -31
- package/dist/pdfDocument-BSiQdNZq.d.cts.map +1 -1
- package/dist/pdfDocument-i6U5fQ91.d.mts.map +1 -1
- package/dist/{pdfDocument-Duf9LelM.cjs → pdfDocument-pmRXryVI.cjs} +101 -31
- package/dist/{pdfPage-BacMkrLe.mjs → pdfPage-Cd8e7flb.mjs} +4 -4
- package/dist/{pdfPage-CirlQRzJ.cjs → pdfPage-Cd8jOJp6.cjs} +4 -4
- package/dist/{src-BLWEEbd7.cjs → src-6L07EQsi.cjs} +19 -19
- package/dist/{src-x0g7wiRq.mjs → src-Dm4aaZ8q.mjs} +19 -19
- package/dist/{streamDecode-CWN-nfPJ.mjs → streamDecode-Bj568Nc9.mjs} +1648 -39
- package/dist/{streamDecode-Bs0_MT_Q.cjs → streamDecode-CvgErkFu.cjs} +1648 -39
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_pdfPage = require('./pdfPage-
|
|
1
|
+
const require_pdfPage = require('./pdfPage-Cd8jOJp6.cjs');
|
|
2
2
|
const require_pdfObjects = require('./pdfObjects-1veop1_d.cjs');
|
|
3
3
|
const require_pdfCatalog = require('./pdfCatalog-CYy4NXEY.cjs');
|
|
4
4
|
const require_libdeflateWasm = require('./libdeflateWasm-BdiDEJOj.cjs');
|
|
@@ -6,7 +6,7 @@ const require_fontSubset = require('./fontSubset-5SLWMmEw.cjs');
|
|
|
6
6
|
const require_pngEmbed = require('./pngEmbed-D4X4ZN-3.cjs');
|
|
7
7
|
const require_fflateAdapter = require('./fflateAdapter-LTAeAhaD.cjs');
|
|
8
8
|
const require_pdfForm = require('./pdfForm-9gd40uz9.cjs');
|
|
9
|
-
const require_streamDecode = require('./streamDecode-
|
|
9
|
+
const require_streamDecode = require('./streamDecode-CvgErkFu.cjs');
|
|
10
10
|
let fflate = require("fflate");
|
|
11
11
|
|
|
12
12
|
//#region src/core/pdfWriter.ts
|
|
@@ -4196,7 +4196,7 @@ var PdfLexer = class {
|
|
|
4196
4196
|
this.position = pos;
|
|
4197
4197
|
return {
|
|
4198
4198
|
type: TokenType.HexString,
|
|
4199
|
-
value: String.fromCharCode
|
|
4199
|
+
value: String.fromCharCode(...bytes),
|
|
4200
4200
|
offset: startPos
|
|
4201
4201
|
};
|
|
4202
4202
|
}
|
|
@@ -4355,7 +4355,7 @@ var PdfLexer = class {
|
|
|
4355
4355
|
* because it avoids the per-call overhead of the streaming decoder.
|
|
4356
4356
|
*/
|
|
4357
4357
|
bytesToAscii(from, to) {
|
|
4358
|
-
return String.fromCharCode
|
|
4358
|
+
return String.fromCharCode(...this._data.subarray(from, to));
|
|
4359
4359
|
}
|
|
4360
4360
|
};
|
|
4361
4361
|
|
|
@@ -5147,13 +5147,13 @@ var XrefParser = class {
|
|
|
5147
5147
|
actual: "no \"startxref\" found",
|
|
5148
5148
|
data: this.data
|
|
5149
5149
|
});
|
|
5150
|
-
const afterKeyword = tail.
|
|
5150
|
+
const afterKeyword = tail.slice(idx + 9).trim();
|
|
5151
5151
|
const match = afterKeyword.match(/^(\d+)/);
|
|
5152
5152
|
if (!match) throw new PdfParseError({
|
|
5153
5153
|
message: "Invalid PDF: \"startxref\" found but no valid offset follows it.",
|
|
5154
5154
|
offset: startPos + idx,
|
|
5155
5155
|
expected: "decimal offset after \"startxref\"",
|
|
5156
|
-
actual: `"${afterKeyword.
|
|
5156
|
+
actual: `"${afterKeyword.slice(0, 20)}"`,
|
|
5157
5157
|
data: this.data
|
|
5158
5158
|
});
|
|
5159
5159
|
const offset = parseInt(match[1], 10);
|
|
@@ -6670,9 +6670,9 @@ const FILE_KEY_CACHE_MAX = 32;
|
|
|
6670
6670
|
* a key derivation result.
|
|
6671
6671
|
*/
|
|
6672
6672
|
function buildCacheKey(password, dict, fileId) {
|
|
6673
|
-
const oHex =
|
|
6674
|
-
const uHex =
|
|
6675
|
-
const fHex =
|
|
6673
|
+
const oHex = dict.ownerKey.subarray(0, 16).toHex();
|
|
6674
|
+
const uHex = dict.userKey.subarray(0, 16).toHex();
|
|
6675
|
+
const fHex = fileId.subarray(0, 16).toHex();
|
|
6676
6676
|
return `${dict.revision}:${dict.permissions}:${password}:${oHex}:${uHex}:${fHex}`;
|
|
6677
6677
|
}
|
|
6678
6678
|
/**
|
|
@@ -7666,12 +7666,12 @@ var PdfDocumentParser = class {
|
|
|
7666
7666
|
actual: "no \"%PDF-\" marker found",
|
|
7667
7667
|
data: this.data
|
|
7668
7668
|
});
|
|
7669
|
-
const versionMatch = header.
|
|
7669
|
+
const versionMatch = header.slice(pdfIdx).match(/%PDF-(\d+\.\d+)/);
|
|
7670
7670
|
if (!versionMatch) throw new PdfParseError({
|
|
7671
7671
|
message: "Invalid PDF: could not parse version from header.",
|
|
7672
7672
|
offset: pdfIdx,
|
|
7673
7673
|
expected: "\"%PDF-X.Y\" version string",
|
|
7674
|
-
actual: `"${header.
|
|
7674
|
+
actual: `"${header.slice(pdfIdx, pdfIdx + 10)}"`,
|
|
7675
7675
|
data: this.data
|
|
7676
7676
|
});
|
|
7677
7677
|
this.pdfVersion = versionMatch[1];
|
|
@@ -8168,9 +8168,9 @@ var PdfDocumentParser = class {
|
|
|
8168
8168
|
if (subObj === void 0 || subObj.kind !== "dict") return 0;
|
|
8169
8169
|
const subDict = subObj;
|
|
8170
8170
|
return Iterator.from(subDict).map(([key]) => {
|
|
8171
|
-
const name = key.startsWith("/") ? key.
|
|
8171
|
+
const name = key.startsWith("/") ? key.slice(1) : key;
|
|
8172
8172
|
if (name.startsWith(prefix)) {
|
|
8173
|
-
const num = parseInt(name.
|
|
8173
|
+
const num = parseInt(name.slice(prefix.length), 10);
|
|
8174
8174
|
return isNaN(num) ? 0 : num;
|
|
8175
8175
|
}
|
|
8176
8176
|
return 0;
|
|
@@ -8196,7 +8196,7 @@ var PdfDocumentParser = class {
|
|
|
8196
8196
|
*/
|
|
8197
8197
|
function parsePdfDate(dateStr) {
|
|
8198
8198
|
let s = dateStr;
|
|
8199
|
-
if (s.startsWith("D:")) s = s.
|
|
8199
|
+
if (s.startsWith("D:")) s = s.slice(2);
|
|
8200
8200
|
const match = s.match(/^(\d{4})(\d{2})?(\d{2})?(\d{2})?(\d{2})?(\d{2})?([Z+\-])?(\d{2})?'?(\d{2})?/);
|
|
8201
8201
|
if (!match) return void 0;
|
|
8202
8202
|
const year = parseInt(match[1], 10);
|
|
@@ -10397,7 +10397,7 @@ function prepareForSigning(pdfBytes, signatureFieldName, placeholderSize = 8192,
|
|
|
10397
10397
|
const pdfStr = decoder$2.decode(pdfBytes);
|
|
10398
10398
|
const startxrefIdx = pdfStr.lastIndexOf("startxref");
|
|
10399
10399
|
if (startxrefIdx === -1) throw new Error("Cannot find startxref in PDF — file may be corrupted");
|
|
10400
|
-
const xrefOffsetMatch = pdfStr.
|
|
10400
|
+
const xrefOffsetMatch = pdfStr.slice(startxrefIdx + 9).trim().match(/^(\d+)/);
|
|
10401
10401
|
if (!xrefOffsetMatch) throw new Error("Cannot parse xref offset from startxref");
|
|
10402
10402
|
const prevXrefOffset = parseInt(xrefOffsetMatch[1], 10);
|
|
10403
10403
|
const sizeMatch = pdfStr.match(/\/Size\s+(\d+)/);
|
|
@@ -10568,12 +10568,12 @@ function findSignatures(pdfBytes) {
|
|
|
10568
10568
|
];
|
|
10569
10569
|
const searchStart = Math.max(0, match.index - 2e3);
|
|
10570
10570
|
const searchEnd = Math.min(text.length, match.index + 2e3);
|
|
10571
|
-
const contentsKeyIdx = text.
|
|
10571
|
+
const contentsKeyIdx = text.slice(searchStart, searchEnd).indexOf("/Contents <");
|
|
10572
10572
|
if (contentsKeyIdx !== -1) {
|
|
10573
10573
|
const absoluteHexStart = searchStart + (contentsKeyIdx + 10);
|
|
10574
10574
|
const closingBracket = text.indexOf(">", absoluteHexStart + 1);
|
|
10575
10575
|
if (closingBracket !== -1) {
|
|
10576
|
-
const hexStr = text.
|
|
10576
|
+
const hexStr = text.slice(absoluteHexStart + 1, closingBracket);
|
|
10577
10577
|
const contentsLen = closingBracket - absoluteHexStart + 1;
|
|
10578
10578
|
results.push({
|
|
10579
10579
|
byteRange: br,
|
|
@@ -11140,7 +11140,7 @@ const decoder$1 = new TextDecoder("latin1");
|
|
|
11140
11140
|
*/
|
|
11141
11141
|
function extractFieldName(pdfStr, sigDictOffset) {
|
|
11142
11142
|
const searchStart = Math.max(0, sigDictOffset - 2e3);
|
|
11143
|
-
const tMatch = pdfStr.
|
|
11143
|
+
const tMatch = pdfStr.slice(searchStart, sigDictOffset + 1e3).match(/\/T\s*\(([^)]*)\)/);
|
|
11144
11144
|
if (tMatch) return tMatch[1];
|
|
11145
11145
|
return "Signature";
|
|
11146
11146
|
}
|
|
@@ -11151,7 +11151,7 @@ function extractFieldName(pdfStr, sigDictOffset) {
|
|
|
11151
11151
|
function extractSigDictStrings(pdfStr, byteRangeOffset) {
|
|
11152
11152
|
const searchStart = Math.max(0, byteRangeOffset - 1e3);
|
|
11153
11153
|
const searchEnd = Math.min(pdfStr.length, byteRangeOffset + 2e3);
|
|
11154
|
-
const region = pdfStr.
|
|
11154
|
+
const region = pdfStr.slice(searchStart, searchEnd);
|
|
11155
11155
|
const result = {};
|
|
11156
11156
|
const reasonMatch = region.match(/\/Reason\s*\(([^)]*)\)/);
|
|
11157
11157
|
if (reasonMatch && reasonMatch[1] !== void 0) result.reason = reasonMatch[1];
|
|
@@ -11197,7 +11197,7 @@ function hexToBytes$1(hex) {
|
|
|
11197
11197
|
const trimLen = trailingZeros[0].length;
|
|
11198
11198
|
if (trimLen % 2 === 0) {
|
|
11199
11199
|
const nonZeroEnd = cleanHex.length - trimLen;
|
|
11200
|
-
if (nonZeroEnd > 0 && nonZeroEnd % 2 === 0) cleanHex = cleanHex.
|
|
11200
|
+
if (nonZeroEnd > 0 && nonZeroEnd % 2 === 0) cleanHex = cleanHex.slice(0, nonZeroEnd);
|
|
11201
11201
|
}
|
|
11202
11202
|
}
|
|
11203
11203
|
if (cleanHex.length % 2 !== 0) cleanHex = "0" + cleanHex;
|
|
@@ -11262,7 +11262,7 @@ async function signPdf(pdfBytes, fieldName, options) {
|
|
|
11262
11262
|
}
|
|
11263
11263
|
if (options.reason) textLines.push(`Reason: ${options.reason}`);
|
|
11264
11264
|
if (options.location) textLines.push(`Location: ${options.location}`);
|
|
11265
|
-
textLines.push(`Date: ${(/* @__PURE__ */ new Date()).toISOString().
|
|
11265
|
+
textLines.push(`Date: ${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`);
|
|
11266
11266
|
}
|
|
11267
11267
|
prepareAppearance = {
|
|
11268
11268
|
rect: ap.rect,
|
|
@@ -11346,7 +11346,7 @@ function hexToBytes(hex) {
|
|
|
11346
11346
|
endIdx = clean.length - trailingMatch[0].length;
|
|
11347
11347
|
if (endIdx < 2) endIdx = clean.length;
|
|
11348
11348
|
}
|
|
11349
|
-
return Uint8Array.fromHex(clean.
|
|
11349
|
+
return Uint8Array.fromHex(clean.slice(0, endIdx));
|
|
11350
11350
|
}
|
|
11351
11351
|
/**
|
|
11352
11352
|
* Extract the certificate, signed attributes, and raw signature
|
|
@@ -11447,12 +11447,12 @@ function extractSigningTime(signedAttrs) {
|
|
|
11447
11447
|
*/
|
|
11448
11448
|
function parseUtcTime(utcTime) {
|
|
11449
11449
|
const clean = utcTime.replace("Z", "");
|
|
11450
|
-
const year = parseInt(clean.
|
|
11451
|
-
const month = parseInt(clean.
|
|
11452
|
-
const day = parseInt(clean.
|
|
11453
|
-
const hours = parseInt(clean.
|
|
11454
|
-
const minutes = parseInt(clean.
|
|
11455
|
-
const seconds = parseInt(clean.
|
|
11450
|
+
const year = parseInt(clean.slice(0, 2), 10);
|
|
11451
|
+
const month = parseInt(clean.slice(2, 4), 10) - 1;
|
|
11452
|
+
const day = parseInt(clean.slice(4, 6), 10);
|
|
11453
|
+
const hours = parseInt(clean.slice(6, 8), 10);
|
|
11454
|
+
const minutes = parseInt(clean.slice(8, 10), 10);
|
|
11455
|
+
const seconds = parseInt(clean.slice(10, 12), 10);
|
|
11456
11456
|
const fullYear = year < 50 ? 2e3 + year : 1900 + year;
|
|
11457
11457
|
return new Date(Date.UTC(fullYear, month, day, hours, minutes, seconds));
|
|
11458
11458
|
}
|
|
@@ -11463,7 +11463,7 @@ function parseUtcTime(utcTime) {
|
|
|
11463
11463
|
function extractFieldInfo(pdfStr, contentsOffset) {
|
|
11464
11464
|
const searchStart = Math.max(0, contentsOffset - 3e3);
|
|
11465
11465
|
const searchEnd = Math.min(pdfStr.length, contentsOffset + 2e3);
|
|
11466
|
-
const region = pdfStr.
|
|
11466
|
+
const region = pdfStr.slice(searchStart, searchEnd);
|
|
11467
11467
|
let fieldName = "Signature";
|
|
11468
11468
|
const tMatch = region.match(/\/T\s*\(([^)]*)\)/);
|
|
11469
11469
|
if (tMatch) fieldName = tMatch[1];
|
|
@@ -11845,6 +11845,21 @@ function addWatermark(doc, options) {
|
|
|
11845
11845
|
}
|
|
11846
11846
|
}
|
|
11847
11847
|
|
|
11848
|
+
//#endregion
|
|
11849
|
+
//#region src/form/documentScripts.ts
|
|
11850
|
+
/** WeakMap to store document-level action state per PdfDocument instance. */
|
|
11851
|
+
const documentActionState = /* @__PURE__ */ new WeakMap();
|
|
11852
|
+
/**
|
|
11853
|
+
* Get the internal state for a document's catalog-level actions.
|
|
11854
|
+
*
|
|
11855
|
+
* Used by the catalog builder to set `/OpenAction` and `/AA` entries.
|
|
11856
|
+
*
|
|
11857
|
+
* @internal
|
|
11858
|
+
*/
|
|
11859
|
+
function getDocumentActionState(doc) {
|
|
11860
|
+
return documentActionState.get(doc);
|
|
11861
|
+
}
|
|
11862
|
+
|
|
11848
11863
|
//#endregion
|
|
11849
11864
|
//#region src/core/pdfEmbed.ts
|
|
11850
11865
|
/**
|
|
@@ -12828,7 +12843,7 @@ var PdfDocument = class PdfDocument {
|
|
|
12828
12843
|
if (data.length < 4) throw new Error("Image data too short to detect format");
|
|
12829
12844
|
if (data[0] === 137 && data[1] === 80 && data[2] === 78 && data[3] === 71) return this.embedPng(data);
|
|
12830
12845
|
if (data[0] === 255 && data[1] === 216 && data[2] === 255) return this.embedJpeg(data);
|
|
12831
|
-
throw new Error(`Unsupported image format. Expected PNG (89 50 4E 47) or JPEG (FF D8 FF), got ${
|
|
12846
|
+
throw new Error(`Unsupported image format. Expected PNG (89 50 4E 47) or JPEG (FF D8 FF), got ${data.subarray(0, 4).toHex().match(/.{2}/g)?.join(" ") ?? ""}.`);
|
|
12832
12847
|
}
|
|
12833
12848
|
/**
|
|
12834
12849
|
* Embed pages from another PDF as Form XObjects.
|
|
@@ -13607,6 +13622,61 @@ var PdfDocument = class PdfDocument {
|
|
|
13607
13622
|
catalogObj.set("/Names", namesDict);
|
|
13608
13623
|
}
|
|
13609
13624
|
}
|
|
13625
|
+
const actionState = getDocumentActionState(this);
|
|
13626
|
+
if (actionState) {
|
|
13627
|
+
if (actionState.openAction !== void 0) {
|
|
13628
|
+
const openActionDict = new require_pdfObjects.PdfDict();
|
|
13629
|
+
openActionDict.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13630
|
+
openActionDict.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13631
|
+
openActionDict.set("/JS", require_pdfObjects.PdfString.literal(actionState.openAction));
|
|
13632
|
+
const openActionRef = this.registry.register(openActionDict);
|
|
13633
|
+
catalogObj.set("/OpenAction", openActionRef);
|
|
13634
|
+
}
|
|
13635
|
+
if (actionState.closeAction !== void 0 || actionState.beforePrint !== void 0 || actionState.afterPrint !== void 0 || actionState.beforeSave !== void 0 || actionState.afterSave !== void 0) {
|
|
13636
|
+
const aaDict = new require_pdfObjects.PdfDict();
|
|
13637
|
+
if (actionState.closeAction !== void 0) {
|
|
13638
|
+
const d = new require_pdfObjects.PdfDict();
|
|
13639
|
+
d.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13640
|
+
d.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13641
|
+
d.set("/JS", require_pdfObjects.PdfString.literal(actionState.closeAction));
|
|
13642
|
+
const ref = this.registry.register(d);
|
|
13643
|
+
aaDict.set("/WC", ref);
|
|
13644
|
+
}
|
|
13645
|
+
if (actionState.beforePrint !== void 0) {
|
|
13646
|
+
const d = new require_pdfObjects.PdfDict();
|
|
13647
|
+
d.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13648
|
+
d.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13649
|
+
d.set("/JS", require_pdfObjects.PdfString.literal(actionState.beforePrint));
|
|
13650
|
+
const ref = this.registry.register(d);
|
|
13651
|
+
aaDict.set("/WP", ref);
|
|
13652
|
+
}
|
|
13653
|
+
if (actionState.afterPrint !== void 0) {
|
|
13654
|
+
const d = new require_pdfObjects.PdfDict();
|
|
13655
|
+
d.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13656
|
+
d.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13657
|
+
d.set("/JS", require_pdfObjects.PdfString.literal(actionState.afterPrint));
|
|
13658
|
+
const ref = this.registry.register(d);
|
|
13659
|
+
aaDict.set("/DP", ref);
|
|
13660
|
+
}
|
|
13661
|
+
if (actionState.beforeSave !== void 0) {
|
|
13662
|
+
const d = new require_pdfObjects.PdfDict();
|
|
13663
|
+
d.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13664
|
+
d.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13665
|
+
d.set("/JS", require_pdfObjects.PdfString.literal(actionState.beforeSave));
|
|
13666
|
+
const ref = this.registry.register(d);
|
|
13667
|
+
aaDict.set("/WS", ref);
|
|
13668
|
+
}
|
|
13669
|
+
if (actionState.afterSave !== void 0) {
|
|
13670
|
+
const d = new require_pdfObjects.PdfDict();
|
|
13671
|
+
d.set("/Type", require_pdfObjects.PdfName.of("Action"));
|
|
13672
|
+
d.set("/S", require_pdfObjects.PdfName.of("JavaScript"));
|
|
13673
|
+
d.set("/JS", require_pdfObjects.PdfString.literal(actionState.afterSave));
|
|
13674
|
+
const ref = this.registry.register(d);
|
|
13675
|
+
aaDict.set("/DS", ref);
|
|
13676
|
+
}
|
|
13677
|
+
catalogObj.set("/AA", aaDict);
|
|
13678
|
+
}
|
|
13679
|
+
}
|
|
13610
13680
|
}
|
|
13611
13681
|
if (this.originalBytes !== void 0) {
|
|
13612
13682
|
const rootRefs = [structure.catalogRef, structure.infoRef];
|
|
@@ -14107,4 +14177,4 @@ Object.defineProperty(exports, 'verifyUserPassword', {
|
|
|
14107
14177
|
return verifyUserPassword;
|
|
14108
14178
|
}
|
|
14109
14179
|
});
|
|
14110
|
-
//# sourceMappingURL=pdfDocument-
|
|
14180
|
+
//# sourceMappingURL=pdfDocument-pmRXryVI.cjs.map
|
|
@@ -5372,12 +5372,12 @@ function encodeData(data, mode, buf) {
|
|
|
5372
5372
|
function encodeNumeric(data, buf) {
|
|
5373
5373
|
let i = 0;
|
|
5374
5374
|
while (i + 2 < data.length) {
|
|
5375
|
-
const group = parseInt(data.
|
|
5375
|
+
const group = parseInt(data.slice(i, i + 3), 10);
|
|
5376
5376
|
buf.put(group, 10);
|
|
5377
5377
|
i += 3;
|
|
5378
5378
|
}
|
|
5379
|
-
if (data.length - i === 2) buf.put(parseInt(data.
|
|
5380
|
-
else if (data.length - i === 1) buf.put(parseInt(data.
|
|
5379
|
+
if (data.length - i === 2) buf.put(parseInt(data.slice(i, i + 2), 10), 7);
|
|
5380
|
+
else if (data.length - i === 1) buf.put(parseInt(data.slice(i, i + 1), 10), 4);
|
|
5381
5381
|
}
|
|
5382
5382
|
function encodeAlphanumeric(data, buf) {
|
|
5383
5383
|
let i = 0;
|
|
@@ -8012,4 +8012,4 @@ var PdfPage = class PdfPage {
|
|
|
8012
8012
|
|
|
8013
8013
|
//#endregion
|
|
8014
8014
|
export { translate as $, setCharacterSpacing as $t, buildAnnotationDict as A, curveToFinal as At, wrapInMarkedContent as B, rectangle as Bt, parseSvg as C, clip as Ct, AnnotationFlags as D, closeFillEvenOddAndStroke as Dt, parseSvgTransform as E, closeFillAndStroke as Et, beginMarkedContentSequence as F, fillAndStroke as Ft, radiansToDegrees as G, setLineWidth as Gt, degrees as H, setFlatness as Ht, beginMarkedContentWithProperties as I, fillEvenOdd as It, rotationMatrix as J, beginText as Jt, restoreState as K, setMiterLimit as Kt, createMarkedContentScope as L, fillEvenOddAndStroke as Lt, beginArtifact as M, ellipsePath as Mt, beginArtifactWithType as N, endPath as Nt, PdfAnnotation as O, closePath as Ot, beginMarkedContent as P, fill as Pt, skew as Q, nextLine as Qt, endArtifact as R, lineTo as Rt, svgToPdfOperators as S, circlePath as St, parseSvgPath as T, closeAndStroke as Tt, degreesToRadians as U, setLineCap as Ut, concatMatrix as V, setDashPattern as Vt, radians as W, setLineJoin as Wt, scale as X, moveText as Xt, saveState as Y, endText as Yt, setGraphicsState as Z, moveTextSetLeading as Zt, PdfLayer as _, setStrokeColorSpace as _t, renderMultiPageTable as a, setTextRise as an, grayscale as at, endLayerContent as b, drawImageXObject as bt, qrCodeToOperators as c, showTextArray as cn, setFillColor as ct, linearGradient as d, showTextWithSpacing as dn, setFillColorRgb as dt, setFont as en, applyFillColor as et, radialGradient as f, setFillingColor as ft, markForRedaction as g, setStrokeColorRgb as gt, getRedactionMarks as h, setStrokeColorGray as ht, wrapText as i, setTextRenderingMode as in, componentsToColor as it, createAnnotation as j, curveToInitial as jt, annotationFromDict as k, curveTo as kt, buildGradientObjects as l, showTextHex as ln, setFillColorCmyk as lt, applyRedactions as m, setStrokeColorCmyk as mt, PdfPage as n, setLeading as nn, cmyk as nt, renderTable as o, setWordSpacing as on, rgb as ot, tilingPattern as p, setStrokeColor as pt, rotate as q, stroke as qt, pdfPage_exports as r, setTextMatrix as rn, colorToComponents as rt, encodeQrCode as s, showText as sn, setColorSpace as st, PageSizes as t, setFontSize as tn, applyStrokeColor as tt, buildPatternObjects as u, showTextNextLine as un, setFillColorGray as ut, PdfLayerManager as v, setStrokingColor as vt, parseSvgColor as w, clipEvenOdd as wt, drawSvgOnPage as x, drawXObject as xt, beginLayerContent as y, drawImageWithMatrix as yt, endMarkedContent as z, moveTo as zt };
|
|
8015
|
-
//# sourceMappingURL=pdfPage-
|
|
8015
|
+
//# sourceMappingURL=pdfPage-Cd8e7flb.mjs.map
|
|
@@ -5372,12 +5372,12 @@ function encodeData(data, mode, buf) {
|
|
|
5372
5372
|
function encodeNumeric(data, buf) {
|
|
5373
5373
|
let i = 0;
|
|
5374
5374
|
while (i + 2 < data.length) {
|
|
5375
|
-
const group = parseInt(data.
|
|
5375
|
+
const group = parseInt(data.slice(i, i + 3), 10);
|
|
5376
5376
|
buf.put(group, 10);
|
|
5377
5377
|
i += 3;
|
|
5378
5378
|
}
|
|
5379
|
-
if (data.length - i === 2) buf.put(parseInt(data.
|
|
5380
|
-
else if (data.length - i === 1) buf.put(parseInt(data.
|
|
5379
|
+
if (data.length - i === 2) buf.put(parseInt(data.slice(i, i + 2), 10), 7);
|
|
5380
|
+
else if (data.length - i === 1) buf.put(parseInt(data.slice(i, i + 1), 10), 4);
|
|
5381
5381
|
}
|
|
5382
5382
|
function encodeAlphanumeric(data, buf) {
|
|
5383
5383
|
let i = 0;
|
|
@@ -8725,4 +8725,4 @@ Object.defineProperty(exports, 'wrapText', {
|
|
|
8725
8725
|
return wrapText;
|
|
8726
8726
|
}
|
|
8727
8727
|
});
|
|
8728
|
-
//# sourceMappingURL=pdfPage-
|
|
8728
|
+
//# sourceMappingURL=pdfPage-Cd8jOJp6.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const require_pdfPage = require('./pdfPage-
|
|
1
|
+
const require_pdfPage = require('./pdfPage-Cd8jOJp6.cjs');
|
|
2
2
|
const require_pdfObjects = require('./pdfObjects-1veop1_d.cjs');
|
|
3
|
-
const require_pdfDocument = require('./pdfDocument-
|
|
3
|
+
const require_pdfDocument = require('./pdfDocument-pmRXryVI.cjs');
|
|
4
4
|
let fflate = require("fflate");
|
|
5
5
|
|
|
6
6
|
//#region src/utils/pdfValueHelpers.ts
|
|
@@ -310,7 +310,7 @@ function compressStream(stream, level) {
|
|
|
310
310
|
*/
|
|
311
311
|
async function saveDocumentIncremental(originalBytes, doc, options) {
|
|
312
312
|
const { buildDocumentStructure } = await Promise.resolve().then(() => require("./pdfCatalog-CYy4NXEY.cjs")).then((n) => n.pdfCatalog_exports);
|
|
313
|
-
const { PdfPage: _PdfPage } = await Promise.resolve().then(() => require("./pdfPage-
|
|
313
|
+
const { PdfPage: _PdfPage } = await Promise.resolve().then(() => require("./pdfPage-Cd8jOJp6.cjs")).then((n) => n.pdfPage_exports);
|
|
314
314
|
const registry = doc.getRegistry();
|
|
315
315
|
const structure = buildDocumentStructure(doc.getInternalPages().map((p) => p.finalize()), {
|
|
316
316
|
producer: doc.getProducer(),
|
|
@@ -1937,12 +1937,12 @@ function encodeIntegerValue(value) {
|
|
|
1937
1937
|
*/
|
|
1938
1938
|
function parseGeneralizedTime(timeStr) {
|
|
1939
1939
|
const clean = timeStr.replace("Z", "").replace(/\..*$/, "");
|
|
1940
|
-
const year = parseInt(clean.
|
|
1941
|
-
const month = parseInt(clean.
|
|
1942
|
-
const day = parseInt(clean.
|
|
1943
|
-
const hours = parseInt(clean.
|
|
1944
|
-
const minutes = parseInt(clean.
|
|
1945
|
-
const seconds = parseInt(clean.
|
|
1940
|
+
const year = parseInt(clean.slice(0, 4), 10);
|
|
1941
|
+
const month = parseInt(clean.slice(4, 6), 10) - 1;
|
|
1942
|
+
const day = parseInt(clean.slice(6, 8), 10);
|
|
1943
|
+
const hours = parseInt(clean.slice(8, 10), 10);
|
|
1944
|
+
const minutes = parseInt(clean.slice(10, 12), 10);
|
|
1945
|
+
const seconds = parseInt(clean.slice(12, 14), 10) || 0;
|
|
1946
1946
|
return new Date(Date.UTC(year, month, day, hours, minutes, seconds));
|
|
1947
1947
|
}
|
|
1948
1948
|
/**
|
|
@@ -1950,12 +1950,12 @@ function parseGeneralizedTime(timeStr) {
|
|
|
1950
1950
|
*/
|
|
1951
1951
|
function parseUtcTime(timeStr) {
|
|
1952
1952
|
const clean = timeStr.replace("Z", "");
|
|
1953
|
-
const year = parseInt(clean.
|
|
1954
|
-
const month = parseInt(clean.
|
|
1955
|
-
const day = parseInt(clean.
|
|
1956
|
-
const hours = parseInt(clean.
|
|
1957
|
-
const minutes = parseInt(clean.
|
|
1958
|
-
const seconds = parseInt(clean.
|
|
1953
|
+
const year = parseInt(clean.slice(0, 2), 10);
|
|
1954
|
+
const month = parseInt(clean.slice(2, 4), 10) - 1;
|
|
1955
|
+
const day = parseInt(clean.slice(4, 6), 10);
|
|
1956
|
+
const hours = parseInt(clean.slice(6, 8), 10);
|
|
1957
|
+
const minutes = parseInt(clean.slice(8, 10), 10);
|
|
1958
|
+
const seconds = parseInt(clean.slice(10, 12), 10) || 0;
|
|
1959
1959
|
const fullYear = year < 50 ? 2e3 + year : 1900 + year;
|
|
1960
1960
|
return new Date(Date.UTC(fullYear, month, day, hours, minutes, seconds));
|
|
1961
1961
|
}
|
|
@@ -2369,7 +2369,7 @@ async function linearizePdf(pdfBytes, options) {
|
|
|
2369
2369
|
}
|
|
2370
2370
|
/** Build a simplified hint stream. */
|
|
2371
2371
|
function buildSimpleHintStream(firstPageObjs, remainingObjs, offsets) {
|
|
2372
|
-
const allObjNums = firstPageObjs
|
|
2372
|
+
const allObjNums = [...firstPageObjs, ...remainingObjs];
|
|
2373
2373
|
const data = new Uint8Array(allObjNums.length * 4);
|
|
2374
2374
|
for (let i = 0; i < allObjNums.length; i++) {
|
|
2375
2375
|
const off = offsets.get(allObjNums[i]) ?? 0;
|
|
@@ -3858,7 +3858,7 @@ function extractXmpMetadata(pdfBytes) {
|
|
|
3858
3858
|
if (start < 0) return void 0;
|
|
3859
3859
|
const end = text.indexOf("</x:xmpmeta>", start);
|
|
3860
3860
|
if (end < 0) return void 0;
|
|
3861
|
-
return text.
|
|
3861
|
+
return text.slice(start, end + 12);
|
|
3862
3862
|
}
|
|
3863
3863
|
/**
|
|
3864
3864
|
* Parse an XMP metadata string into structured data.
|
|
@@ -6370,7 +6370,7 @@ function encodeCode128Values(data) {
|
|
|
6370
6370
|
const digitsAhead = countDigits(data, pos);
|
|
6371
6371
|
if (currentSet === "C") {
|
|
6372
6372
|
if (digitsAhead >= 2) {
|
|
6373
|
-
const pair = parseInt(data.
|
|
6373
|
+
const pair = parseInt(data.slice(pos, pos + 2), 10);
|
|
6374
6374
|
values.push(pair);
|
|
6375
6375
|
pos += 2;
|
|
6376
6376
|
continue;
|
|
@@ -11849,4 +11849,4 @@ Object.defineProperty(exports, 'wrapText', {
|
|
|
11849
11849
|
return wrapText;
|
|
11850
11850
|
}
|
|
11851
11851
|
});
|
|
11852
|
-
//# sourceMappingURL=src-
|
|
11852
|
+
//# sourceMappingURL=src-6L07EQsi.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as buildAnnotationDict, Bt as rectangle, Gt as setLineWidth, Jt as beginText, K as restoreState, O as PdfAnnotation, Pt as fill, Xt as moveText, Y as saveState, Yt as endText, en as setFont, et as applyFillColor, qt as stroke, sn as showText, tt as applyStrokeColor } from "./pdfPage-
|
|
1
|
+
import { A as buildAnnotationDict, Bt as rectangle, Gt as setLineWidth, Jt as beginText, K as restoreState, O as PdfAnnotation, Pt as fill, Xt as moveText, Y as saveState, Yt as endText, en as setFont, et as applyFillColor, qt as stroke, sn as showText, tt as applyStrokeColor } from "./pdfPage-Cd8e7flb.mjs";
|
|
2
2
|
import { i as PdfName, l as PdfStream, n as PdfBool, o as PdfNumber, r as PdfDict, t as PdfArray, u as PdfString } from "./pdfObjects-uEsWlfzU.mjs";
|
|
3
|
-
import { E as parseDerTlv, S as encodeSequence, b as encodeOctetString, h as decodeOidBytes, y as encodeOID } from "./pdfDocument-
|
|
3
|
+
import { E as parseDerTlv, S as encodeSequence, b as encodeOctetString, h as decodeOidBytes, y as encodeOID } from "./pdfDocument-BFxHD_2u.mjs";
|
|
4
4
|
import { deflateSync } from "fflate";
|
|
5
5
|
|
|
6
6
|
//#region src/utils/pdfValueHelpers.ts
|
|
@@ -310,7 +310,7 @@ function compressStream(stream, level) {
|
|
|
310
310
|
*/
|
|
311
311
|
async function saveDocumentIncremental(originalBytes, doc, options) {
|
|
312
312
|
const { buildDocumentStructure } = await import("./pdfCatalog-IImGcMbR.mjs").then((n) => n.o);
|
|
313
|
-
const { PdfPage: _PdfPage } = await import("./pdfPage-
|
|
313
|
+
const { PdfPage: _PdfPage } = await import("./pdfPage-Cd8e7flb.mjs").then((n) => n.r);
|
|
314
314
|
const registry = doc.getRegistry();
|
|
315
315
|
const structure = buildDocumentStructure(doc.getInternalPages().map((p) => p.finalize()), {
|
|
316
316
|
producer: doc.getProducer(),
|
|
@@ -1937,12 +1937,12 @@ function encodeIntegerValue(value) {
|
|
|
1937
1937
|
*/
|
|
1938
1938
|
function parseGeneralizedTime(timeStr) {
|
|
1939
1939
|
const clean = timeStr.replace("Z", "").replace(/\..*$/, "");
|
|
1940
|
-
const year = parseInt(clean.
|
|
1941
|
-
const month = parseInt(clean.
|
|
1942
|
-
const day = parseInt(clean.
|
|
1943
|
-
const hours = parseInt(clean.
|
|
1944
|
-
const minutes = parseInt(clean.
|
|
1945
|
-
const seconds = parseInt(clean.
|
|
1940
|
+
const year = parseInt(clean.slice(0, 4), 10);
|
|
1941
|
+
const month = parseInt(clean.slice(4, 6), 10) - 1;
|
|
1942
|
+
const day = parseInt(clean.slice(6, 8), 10);
|
|
1943
|
+
const hours = parseInt(clean.slice(8, 10), 10);
|
|
1944
|
+
const minutes = parseInt(clean.slice(10, 12), 10);
|
|
1945
|
+
const seconds = parseInt(clean.slice(12, 14), 10) || 0;
|
|
1946
1946
|
return new Date(Date.UTC(year, month, day, hours, minutes, seconds));
|
|
1947
1947
|
}
|
|
1948
1948
|
/**
|
|
@@ -1950,12 +1950,12 @@ function parseGeneralizedTime(timeStr) {
|
|
|
1950
1950
|
*/
|
|
1951
1951
|
function parseUtcTime(timeStr) {
|
|
1952
1952
|
const clean = timeStr.replace("Z", "");
|
|
1953
|
-
const year = parseInt(clean.
|
|
1954
|
-
const month = parseInt(clean.
|
|
1955
|
-
const day = parseInt(clean.
|
|
1956
|
-
const hours = parseInt(clean.
|
|
1957
|
-
const minutes = parseInt(clean.
|
|
1958
|
-
const seconds = parseInt(clean.
|
|
1953
|
+
const year = parseInt(clean.slice(0, 2), 10);
|
|
1954
|
+
const month = parseInt(clean.slice(2, 4), 10) - 1;
|
|
1955
|
+
const day = parseInt(clean.slice(4, 6), 10);
|
|
1956
|
+
const hours = parseInt(clean.slice(6, 8), 10);
|
|
1957
|
+
const minutes = parseInt(clean.slice(8, 10), 10);
|
|
1958
|
+
const seconds = parseInt(clean.slice(10, 12), 10) || 0;
|
|
1959
1959
|
const fullYear = year < 50 ? 2e3 + year : 1900 + year;
|
|
1960
1960
|
return new Date(Date.UTC(fullYear, month, day, hours, minutes, seconds));
|
|
1961
1961
|
}
|
|
@@ -2369,7 +2369,7 @@ async function linearizePdf(pdfBytes, options) {
|
|
|
2369
2369
|
}
|
|
2370
2370
|
/** Build a simplified hint stream. */
|
|
2371
2371
|
function buildSimpleHintStream(firstPageObjs, remainingObjs, offsets) {
|
|
2372
|
-
const allObjNums = firstPageObjs
|
|
2372
|
+
const allObjNums = [...firstPageObjs, ...remainingObjs];
|
|
2373
2373
|
const data = new Uint8Array(allObjNums.length * 4);
|
|
2374
2374
|
for (let i = 0; i < allObjNums.length; i++) {
|
|
2375
2375
|
const off = offsets.get(allObjNums[i]) ?? 0;
|
|
@@ -3858,7 +3858,7 @@ function extractXmpMetadata(pdfBytes) {
|
|
|
3858
3858
|
if (start < 0) return void 0;
|
|
3859
3859
|
const end = text.indexOf("</x:xmpmeta>", start);
|
|
3860
3860
|
if (end < 0) return void 0;
|
|
3861
|
-
return text.
|
|
3861
|
+
return text.slice(start, end + 12);
|
|
3862
3862
|
}
|
|
3863
3863
|
/**
|
|
3864
3864
|
* Parse an XMP metadata string into structured data.
|
|
@@ -6370,7 +6370,7 @@ function encodeCode128Values(data) {
|
|
|
6370
6370
|
const digitsAhead = countDigits(data, pos);
|
|
6371
6371
|
if (currentSet === "C") {
|
|
6372
6372
|
if (digitsAhead >= 2) {
|
|
6373
|
-
const pair = parseInt(data.
|
|
6373
|
+
const pair = parseInt(data.slice(pos, pos + 2), 10);
|
|
6374
6374
|
values.push(pair);
|
|
6375
6375
|
pos += 2;
|
|
6376
6376
|
continue;
|
|
@@ -11100,4 +11100,4 @@ async function initWasm(options) {
|
|
|
11100
11100
|
|
|
11101
11101
|
//#endregion
|
|
11102
11102
|
export { encodeCode128Values as $, PdfFreeTextAnnotation as $t, readEan13 as A, flattenTransparency as At, upcAToOperators as B, PdfPopupAnnotation as Bt, borderedPreset as C, generateWinAnsiToUnicodeCmap as Ct, readBarcode as D, SRGB_ICC_PROFILE as Dt, stripedPreset as E, buildOutputIntent as Et, pdf417ToOperators as F, buildTimestampRequest as Ft, encodeEan8 as G, PdfLineAnnotation as Gt, ean13ToOperators as H, PdfInkAnnotation as Ht, dataMatrixToOperators as I, parseTimestampResponse as It, code39ToOperators as J, PdfSquareAnnotation as Jt, encodeItf as K, PdfPolyLineAnnotation as Kt, encodeDataMatrix as L, requestTimestamp as Lt, calculateBarcodeDimensions as M, validatePdfA as Mt, renderStyledBarcode as N, isLinearized as Nt, readCode128 as O, generateSrgbIccProfile as Ot, encodePdf417 as P, linearizePdf as Pt, encodeCode128 as Q, PdfUnderlineAnnotation as Qt, calculateUpcCheckDigit as R, PdfFileAttachmentAnnotation as Rt, applyTablePreset as S, generateSymbolToUnicodeCmap as St, professionalPreset as T, getToUnicodeCmap as Tt, ean8ToOperators as U, PdfStampAnnotation as Ut, calculateEanCheckDigit as V, PdfRedactAnnotation as Vt, encodeEan13 as W, PdfCircleAnnotation as Wt, encodeCode39 as X, PdfSquigglyAnnotation as Xt, computeCode39CheckDigit as Y, PdfHighlightAnnotation as Yt, code128ToOperators as Z, PdfStrikeOutAnnotation as Zt, estimateTextWidth as _, asPDFNumber as _n, parseXmpMetadata as _t, FieldAlreadyExistsError as a, generateSquareAppearance as an, downscaleImage as at, wrapText as b, getSupportedLevels as bt, ForeignPageError as c, generateUnderlineAppearance as cn, recompressImage as ct, NoSuchFieldError as d, PDFOperator as dn, generatePdfAXmpBytes as dt, generateCircleAppearance as en, valuesToModules as et, RemovePageFromEmptyDocumentError as f, ChangeTracker as fn, countOccurrences as ft, ellipsisText as g, asPDFName as gn, extractXmpMetadata as gt, applyOverflow as h, asNumber as hn, createAssociatedFile as ht, ExceededMaxLengthError as i, generateLineAppearance as in, analyzeJpegMarkers as it, readEan8 as j, enforcePdfA as jt, readCode39 as k, detectTransparency as kt, InvalidFieldNamePartError as l, PdfLinkAnnotation as ln, enforcePdfAFull as lt, UnexpectedFieldTypeError as m, saveIncremental as mn, buildAfArray as mt, CombedTextLayoutError as n, generateHighlightAppearance as nn, extractJpegMetadata as nt, FieldExistsAsNonTerminalError as o, generateSquigglyAppearance as on, estimateJpegQuality as ot, RichTextFieldReadError as p, saveDocumentIncremental as pn, stripProhibitedFeatures as pt, itfToOperators as q, PdfPolygonAnnotation as qt, EncryptedPdfError as r, generateInkAppearance as rn, injectJpegMetadata as rt, FontNotEmbeddedError as s, generateStrikeOutAppearance as sn, optimizeImage as st, initWasm as t, generateFreeTextAppearance as tn, PdfWorker as tt, MissingOnValueCheckError as u, PdfTextAnnotation as un, generatePdfAXmp as ut, shrinkFontSize as v, validateXmpMetadata as vt, minimalPreset as w, generateZapfDingbatsToUnicodeCmap as wt, applyPreset as x, isValidLevel as xt, truncateText as y, getProfile as yt, encodeUpcA as z, PdfCaretAnnotation as zt };
|
|
11103
|
-
//# sourceMappingURL=src-
|
|
11103
|
+
//# sourceMappingURL=src-Dm4aaZ8q.mjs.map
|