@pdfme/pdf-lib 6.1.2 → 6.1.3-dev.2
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.js +36 -71
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -510,11 +510,6 @@ var isWithinBMP = (codePoint) => codePoint >= 0 && codePoint <= 65535;
|
|
|
510
510
|
var hasSurrogates = (codePoint) => codePoint >= 65536 && codePoint <= 1114111;
|
|
511
511
|
var highSurrogate = (codePoint) => Math.floor((codePoint - 65536) / 1024) + 55296;
|
|
512
512
|
var lowSurrogate = (codePoint) => (codePoint - 65536) % 1024 + 56320;
|
|
513
|
-
var ByteOrder = /* @__PURE__ */ function(ByteOrder) {
|
|
514
|
-
ByteOrder["BigEndian"] = "BigEndian";
|
|
515
|
-
ByteOrder["LittleEndian"] = "LittleEndian";
|
|
516
|
-
return ByteOrder;
|
|
517
|
-
}(ByteOrder || {});
|
|
518
513
|
var REPLACEMENT = "�".codePointAt(0);
|
|
519
514
|
/**
|
|
520
515
|
* Decodes a Uint8Array of data to a string using UTF-16.
|
|
@@ -530,7 +525,7 @@ var REPLACEMENT = "�".codePointAt(0);
|
|
|
530
525
|
*/
|
|
531
526
|
var utf16Decode = (input, byteOrderMark = true) => {
|
|
532
527
|
if (input.length <= 1) return String.fromCodePoint(REPLACEMENT);
|
|
533
|
-
const byteOrder = byteOrderMark ? readBOM(input) :
|
|
528
|
+
const byteOrder = byteOrderMark ? readBOM(input) : "BigEndian";
|
|
534
529
|
let idx = byteOrderMark ? 2 : 0;
|
|
535
530
|
const codePoints = [];
|
|
536
531
|
while (input.length - idx >= 2) {
|
|
@@ -572,8 +567,8 @@ var isLowSurrogate = (codePoint) => codePoint >= 56320 && codePoint <= 57343;
|
|
|
572
567
|
* Reference: https://en.wikipedia.org/wiki/UTF-16#Examples
|
|
573
568
|
*/
|
|
574
569
|
var decodeValues = (first, second, byteOrder) => {
|
|
575
|
-
if (byteOrder ===
|
|
576
|
-
if (byteOrder ===
|
|
570
|
+
if (byteOrder === "LittleEndian") return second << 8 | first;
|
|
571
|
+
if (byteOrder === "BigEndian") return first << 8 | second;
|
|
577
572
|
throw new Error(`Invalid byteOrder: ${byteOrder}`);
|
|
578
573
|
};
|
|
579
574
|
/**
|
|
@@ -584,7 +579,7 @@ var decodeValues = (first, second, byteOrder) => {
|
|
|
584
579
|
*
|
|
585
580
|
* @param bytes The byte array to be evaluated.
|
|
586
581
|
*/
|
|
587
|
-
var readBOM = (bytes) => hasUtf16BigEndianBOM(bytes) ?
|
|
582
|
+
var readBOM = (bytes) => hasUtf16BigEndianBOM(bytes) ? "BigEndian" : hasUtf16LittleEndianBOM(bytes) ? "LittleEndian" : "BigEndian";
|
|
588
583
|
var hasUtf16BigEndianBOM = (bytes) => bytes[0] === 254 && bytes[1] === 255;
|
|
589
584
|
var hasUtf16LittleEndianBOM = (bytes) => bytes[0] === 255 && bytes[1] === 254;
|
|
590
585
|
var hasUtf16BOM = (bytes) => hasUtf16BigEndianBOM(bytes) || hasUtf16LittleEndianBOM(bytes);
|
|
@@ -819,7 +814,7 @@ var pdfDocEncodingDecode = (bytes) => {
|
|
|
819
814
|
return String.fromCodePoint(...codePoints);
|
|
820
815
|
};
|
|
821
816
|
//#endregion
|
|
822
|
-
//#region \0@oxc-project+runtime@0.
|
|
817
|
+
//#region \0@oxc-project+runtime@0.132.0/helpers/typeof.js
|
|
823
818
|
function _typeof(o) {
|
|
824
819
|
"@babel/helpers - typeof";
|
|
825
820
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -829,7 +824,7 @@ function _typeof(o) {
|
|
|
829
824
|
}, _typeof(o);
|
|
830
825
|
}
|
|
831
826
|
//#endregion
|
|
832
|
-
//#region \0@oxc-project+runtime@0.
|
|
827
|
+
//#region \0@oxc-project+runtime@0.132.0/helpers/toPrimitive.js
|
|
833
828
|
function toPrimitive(t, r) {
|
|
834
829
|
if ("object" != _typeof(t) || !t) return t;
|
|
835
830
|
var e = t[Symbol.toPrimitive];
|
|
@@ -841,13 +836,13 @@ function toPrimitive(t, r) {
|
|
|
841
836
|
return ("string" === r ? String : Number)(t);
|
|
842
837
|
}
|
|
843
838
|
//#endregion
|
|
844
|
-
//#region \0@oxc-project+runtime@0.
|
|
839
|
+
//#region \0@oxc-project+runtime@0.132.0/helpers/toPropertyKey.js
|
|
845
840
|
function toPropertyKey(t) {
|
|
846
841
|
var i = toPrimitive(t, "string");
|
|
847
842
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
848
843
|
}
|
|
849
844
|
//#endregion
|
|
850
|
-
//#region \0@oxc-project+runtime@0.
|
|
845
|
+
//#region \0@oxc-project+runtime@0.132.0/helpers/defineProperty.js
|
|
851
846
|
function _defineProperty(e, r, t) {
|
|
852
847
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
853
848
|
value: t,
|
|
@@ -1064,7 +1059,7 @@ var CharCodes = /* @__PURE__ */ function(CharCodes) {
|
|
|
1064
1059
|
CharCodes[CharCodes["RightParen"] = 41] = "RightParen";
|
|
1065
1060
|
CharCodes[CharCodes["Plus"] = 43] = "Plus";
|
|
1066
1061
|
CharCodes[CharCodes["Minus"] = 45] = "Minus";
|
|
1067
|
-
CharCodes[CharCodes["Dash"] =
|
|
1062
|
+
CharCodes[CharCodes["Dash"] = 45] = "Dash";
|
|
1068
1063
|
CharCodes[CharCodes["Period"] = 46] = "Period";
|
|
1069
1064
|
CharCodes[CharCodes["ForwardSlash"] = 47] = "ForwardSlash";
|
|
1070
1065
|
CharCodes[CharCodes["Zero"] = 48] = "Zero";
|
|
@@ -2753,12 +2748,6 @@ _defineProperty(PDFInvalidObject, "of", (data) => new _PDFInvalidObject(data));
|
|
|
2753
2748
|
//#endregion
|
|
2754
2749
|
//#region src/core/structures/PDFCrossRefStream.ts
|
|
2755
2750
|
var _PDFCrossRefStream;
|
|
2756
|
-
var EntryType = /* @__PURE__ */ function(EntryType) {
|
|
2757
|
-
EntryType[EntryType["Deleted"] = 0] = "Deleted";
|
|
2758
|
-
EntryType[EntryType["Uncompressed"] = 1] = "Uncompressed";
|
|
2759
|
-
EntryType[EntryType["Compressed"] = 2] = "Compressed";
|
|
2760
|
-
return EntryType;
|
|
2761
|
-
}({});
|
|
2762
2751
|
/**
|
|
2763
2752
|
* Entries should be added using the [[addDeletedEntry]],
|
|
2764
2753
|
* [[addUncompressedEntry]], and [[addCompressedEntry]] methods
|
|
@@ -2792,7 +2781,7 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2792
2781
|
const entryTuples = Array(this.entries.length);
|
|
2793
2782
|
for (let idx = 0, len = this.entries.length; idx < len; idx++) {
|
|
2794
2783
|
const entry = this.entries[idx];
|
|
2795
|
-
if (entry.type ===
|
|
2784
|
+
if (entry.type === 0) {
|
|
2796
2785
|
const { type, nextFreeObjectNumber, ref } = entry;
|
|
2797
2786
|
entryTuples[idx] = [
|
|
2798
2787
|
type,
|
|
@@ -2800,7 +2789,7 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2800
2789
|
ref.generationNumber
|
|
2801
2790
|
];
|
|
2802
2791
|
}
|
|
2803
|
-
if (entry.type ===
|
|
2792
|
+
if (entry.type === 1) {
|
|
2804
2793
|
const { type, offset, ref } = entry;
|
|
2805
2794
|
entryTuples[idx] = [
|
|
2806
2795
|
type,
|
|
@@ -2808,7 +2797,7 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2808
2797
|
ref.generationNumber
|
|
2809
2798
|
];
|
|
2810
2799
|
}
|
|
2811
|
-
if (entry.type ===
|
|
2800
|
+
if (entry.type === 2) {
|
|
2812
2801
|
const { type, objectStreamRef, index } = entry;
|
|
2813
2802
|
entryTuples[idx] = [
|
|
2814
2803
|
type,
|
|
@@ -2844,9 +2833,8 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2844
2833
|
dict.set(PDFName.of("Type"), PDFName.of("XRef"));
|
|
2845
2834
|
}
|
|
2846
2835
|
addDeletedEntry(ref, nextFreeObjectNumber) {
|
|
2847
|
-
const type = EntryType.Deleted;
|
|
2848
2836
|
this.entries.push({
|
|
2849
|
-
type,
|
|
2837
|
+
type: 0,
|
|
2850
2838
|
ref,
|
|
2851
2839
|
nextFreeObjectNumber
|
|
2852
2840
|
});
|
|
@@ -2856,9 +2844,8 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2856
2844
|
this.contentsCache.invalidate();
|
|
2857
2845
|
}
|
|
2858
2846
|
addUncompressedEntry(ref, offset) {
|
|
2859
|
-
const type = EntryType.Uncompressed;
|
|
2860
2847
|
this.entries.push({
|
|
2861
|
-
type,
|
|
2848
|
+
type: 1,
|
|
2862
2849
|
ref,
|
|
2863
2850
|
offset
|
|
2864
2851
|
});
|
|
@@ -2868,9 +2855,8 @@ var PDFCrossRefStream = class PDFCrossRefStream extends PDFFlateStream {
|
|
|
2868
2855
|
this.contentsCache.invalidate();
|
|
2869
2856
|
}
|
|
2870
2857
|
addCompressedEntry(ref, objectStreamRef, index) {
|
|
2871
|
-
const type = EntryType.Compressed;
|
|
2872
2858
|
this.entries.push({
|
|
2873
|
-
type,
|
|
2859
|
+
type: 2,
|
|
2874
2860
|
ref,
|
|
2875
2861
|
objectStreamRef,
|
|
2876
2862
|
index
|
|
@@ -3536,7 +3522,7 @@ var AFRelationship = /* @__PURE__ */ function(AFRelationship) {
|
|
|
3536
3522
|
AFRelationship["Alternative"] = "Alternative";
|
|
3537
3523
|
AFRelationship["Supplement"] = "Supplement";
|
|
3538
3524
|
AFRelationship["EncryptedPayload"] = "EncryptedPayload";
|
|
3539
|
-
AFRelationship[
|
|
3525
|
+
AFRelationship["FormData"] = "EncryptedPayload";
|
|
3540
3526
|
AFRelationship["Schema"] = "Schema";
|
|
3541
3527
|
AFRelationship["Unspecified"] = "Unspecified";
|
|
3542
3528
|
return AFRelationship;
|
|
@@ -3598,16 +3584,10 @@ var MARKERS = [
|
|
|
3598
3584
|
65486,
|
|
3599
3585
|
65487
|
|
3600
3586
|
];
|
|
3601
|
-
var ColorSpace = /* @__PURE__ */ function(ColorSpace) {
|
|
3602
|
-
ColorSpace["DeviceGray"] = "DeviceGray";
|
|
3603
|
-
ColorSpace["DeviceRGB"] = "DeviceRGB";
|
|
3604
|
-
ColorSpace["DeviceCMYK"] = "DeviceCMYK";
|
|
3605
|
-
return ColorSpace;
|
|
3606
|
-
}(ColorSpace || {});
|
|
3607
3587
|
var ChannelToColorSpace = {
|
|
3608
|
-
1:
|
|
3609
|
-
3:
|
|
3610
|
-
4:
|
|
3588
|
+
1: "DeviceGray",
|
|
3589
|
+
3: "DeviceRGB",
|
|
3590
|
+
4: "DeviceCMYK"
|
|
3611
3591
|
};
|
|
3612
3592
|
/**
|
|
3613
3593
|
* A note of thanks to the developers of https://github.com/foliojs/pdfkit, as
|
|
@@ -3658,7 +3638,7 @@ var JpegEmbedder = class JpegEmbedder {
|
|
|
3658
3638
|
Height: this.height,
|
|
3659
3639
|
ColorSpace: this.colorSpace,
|
|
3660
3640
|
Filter: "DCTDecode",
|
|
3661
|
-
Decode: this.colorSpace ===
|
|
3641
|
+
Decode: this.colorSpace === "DeviceCMYK" ? [
|
|
3662
3642
|
1,
|
|
3663
3643
|
0,
|
|
3664
3644
|
1,
|
|
@@ -3689,11 +3669,11 @@ var resolveUPNG = (value) => {
|
|
|
3689
3669
|
};
|
|
3690
3670
|
var UPNG = resolveUPNG(UPNGModule);
|
|
3691
3671
|
var getImageType = (ctype) => {
|
|
3692
|
-
if (ctype === 0) return
|
|
3693
|
-
if (ctype === 2) return
|
|
3694
|
-
if (ctype === 3) return
|
|
3695
|
-
if (ctype === 4) return
|
|
3696
|
-
if (ctype === 6) return
|
|
3672
|
+
if (ctype === 0) return "Greyscale";
|
|
3673
|
+
if (ctype === 2) return "Truecolour";
|
|
3674
|
+
if (ctype === 3) return "IndexedColour";
|
|
3675
|
+
if (ctype === 4) return "GreyscaleWithAlpha";
|
|
3676
|
+
if (ctype === 6) return "TruecolourWithAlpha";
|
|
3697
3677
|
throw new Error(`Unknown color type: ${ctype}`);
|
|
3698
3678
|
};
|
|
3699
3679
|
var splitAlphaChannel = (rgbaChannel) => {
|
|
@@ -3714,14 +3694,6 @@ var splitAlphaChannel = (rgbaChannel) => {
|
|
|
3714
3694
|
alphaChannel
|
|
3715
3695
|
};
|
|
3716
3696
|
};
|
|
3717
|
-
var PngType = /* @__PURE__ */ function(PngType) {
|
|
3718
|
-
PngType["Greyscale"] = "Greyscale";
|
|
3719
|
-
PngType["Truecolour"] = "Truecolour";
|
|
3720
|
-
PngType["IndexedColour"] = "IndexedColour";
|
|
3721
|
-
PngType["GreyscaleWithAlpha"] = "GreyscaleWithAlpha";
|
|
3722
|
-
PngType["TruecolourWithAlpha"] = "TruecolourWithAlpha";
|
|
3723
|
-
return PngType;
|
|
3724
|
-
}({});
|
|
3725
3697
|
var PNG = class {
|
|
3726
3698
|
constructor(pngData) {
|
|
3727
3699
|
_defineProperty(this, "rgbChannel", void 0);
|
|
@@ -5341,7 +5313,7 @@ var ViewerPreferences = class {
|
|
|
5341
5313
|
*/
|
|
5342
5314
|
getNonFullScreenPageMode() {
|
|
5343
5315
|
const mode = this.NonFullScreenPageMode()?.decodeText();
|
|
5344
|
-
return asEnum(mode, NonFullScreenPageMode) ??
|
|
5316
|
+
return asEnum(mode, NonFullScreenPageMode) ?? "UseNone";
|
|
5345
5317
|
}
|
|
5346
5318
|
/**
|
|
5347
5319
|
* Returns the predominant reading order for text.
|
|
@@ -5349,7 +5321,7 @@ var ViewerPreferences = class {
|
|
|
5349
5321
|
*/
|
|
5350
5322
|
getReadingDirection() {
|
|
5351
5323
|
const direction = this.Direction()?.decodeText();
|
|
5352
|
-
return asEnum(direction, ReadingDirection) ??
|
|
5324
|
+
return asEnum(direction, ReadingDirection) ?? "L2R";
|
|
5353
5325
|
}
|
|
5354
5326
|
/**
|
|
5355
5327
|
* Returns the page scaling option that the PDF reader should select when the
|
|
@@ -5358,7 +5330,7 @@ var ViewerPreferences = class {
|
|
|
5358
5330
|
*/
|
|
5359
5331
|
getPrintScaling() {
|
|
5360
5332
|
const scaling = this.PrintScaling()?.decodeText();
|
|
5361
|
-
return asEnum(scaling, PrintScaling) ??
|
|
5333
|
+
return asEnum(scaling, PrintScaling) ?? "AppDefault";
|
|
5362
5334
|
}
|
|
5363
5335
|
/**
|
|
5364
5336
|
* Returns the paper handling option that should be used when printing the
|
|
@@ -7755,14 +7727,14 @@ var RotationTypes = /* @__PURE__ */ function(RotationTypes) {
|
|
|
7755
7727
|
var radians = (radianAngle) => {
|
|
7756
7728
|
assertIs(radianAngle, "radianAngle", ["number"]);
|
|
7757
7729
|
return {
|
|
7758
|
-
type:
|
|
7730
|
+
type: "radians",
|
|
7759
7731
|
angle: radianAngle
|
|
7760
7732
|
};
|
|
7761
7733
|
};
|
|
7762
7734
|
var degrees = (degreeAngle) => {
|
|
7763
7735
|
assertIs(degreeAngle, "degreeAngle", ["number"]);
|
|
7764
7736
|
return {
|
|
7765
|
-
type:
|
|
7737
|
+
type: "degrees",
|
|
7766
7738
|
angle: degreeAngle
|
|
7767
7739
|
};
|
|
7768
7740
|
};
|
|
@@ -7980,7 +7952,7 @@ var ColorTypes = /* @__PURE__ */ function(ColorTypes) {
|
|
|
7980
7952
|
var grayscale = (gray) => {
|
|
7981
7953
|
assertRange(gray, "gray", 0, 1);
|
|
7982
7954
|
return {
|
|
7983
|
-
type:
|
|
7955
|
+
type: "Grayscale",
|
|
7984
7956
|
gray
|
|
7985
7957
|
};
|
|
7986
7958
|
};
|
|
@@ -7989,7 +7961,7 @@ var rgb = (red, green, blue) => {
|
|
|
7989
7961
|
assertRange(green, "green", 0, 1);
|
|
7990
7962
|
assertRange(blue, "blue", 0, 1);
|
|
7991
7963
|
return {
|
|
7992
|
-
type:
|
|
7964
|
+
type: "RGB",
|
|
7993
7965
|
red,
|
|
7994
7966
|
green,
|
|
7995
7967
|
blue
|
|
@@ -8001,7 +7973,7 @@ var cmyk = (cyan, magenta, yellow, key) => {
|
|
|
8001
7973
|
assertRange(yellow, "yellow", 0, 1);
|
|
8002
7974
|
assertRange(key, "key", 0, 1);
|
|
8003
7975
|
return {
|
|
8004
|
-
type:
|
|
7976
|
+
type: "CMYK",
|
|
8005
7977
|
cyan,
|
|
8006
7978
|
magenta,
|
|
8007
7979
|
yellow,
|
|
@@ -8573,21 +8545,14 @@ var drawSvgPath = (path, options) => [
|
|
|
8573
8545
|
].filter(Boolean);
|
|
8574
8546
|
var drawCheckMark = (options) => {
|
|
8575
8547
|
const size = asNumber(options.size);
|
|
8576
|
-
/*********************** Define Check Mark Points ***************************/
|
|
8577
|
-
const p2x = -.25;
|
|
8578
|
-
const p2y = -.49;
|
|
8579
|
-
const p3y = .475;
|
|
8580
|
-
const p3x = .69;
|
|
8581
|
-
const p1x = -.675;
|
|
8582
|
-
const p1y = -((p1x - p2x) * (p3x - p2x)) / (p3y - p2y) + p2y;
|
|
8583
8548
|
return [
|
|
8584
8549
|
pushGraphicsState(),
|
|
8585
8550
|
options.color && setStrokingColor(options.color),
|
|
8586
8551
|
setLineWidth(options.thickness),
|
|
8587
8552
|
translate(options.x, options.y),
|
|
8588
|
-
moveTo(
|
|
8589
|
-
lineTo(
|
|
8590
|
-
lineTo(
|
|
8553
|
+
moveTo(-.675 * size, -.07601036269430045 * size),
|
|
8554
|
+
lineTo(-.25 * size, -.49 * size),
|
|
8555
|
+
lineTo(.69 * size, .475 * size),
|
|
8591
8556
|
stroke(),
|
|
8592
8557
|
popGraphicsState()
|
|
8593
8558
|
].filter(Boolean);
|