modern-pdf-lib 0.25.0 → 0.28.0
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 -3
- package/dist/{batchOptimize-Ba_pWw71.cjs → batchOptimize-CXC9gNqD.cjs} +55 -55
- package/dist/{batchOptimize-DtRwBOqR.mjs → batchOptimize-CjLGD5ie.mjs} +25 -25
- package/dist/{bridge-DYCQzxF7.cjs → bridge-ByvzPu5h.cjs} +29 -31
- package/dist/{bridge-CcivG_Sm.mjs → bridge-ZD6O6QQa.mjs} +4 -5
- package/dist/browser.cjs +263 -151
- package/dist/browser.d.cts +166 -166
- package/dist/browser.d.cts.map +1 -1
- package/dist/browser.d.mts +166 -166
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +15 -19
- package/dist/cli/index.cjs +7 -7
- package/dist/cli/index.mjs +8 -8
- package/dist/{compressionAnalysis-odbHC7Uk.mjs → compressionAnalysis-BgKy45pA.mjs} +60 -74
- package/dist/{compressionAnalysis-DGs-MqTe.d.mts → compressionAnalysis-CDOp_vPr.d.mts} +136 -136
- package/dist/compressionAnalysis-CDOp_vPr.d.mts.map +1 -0
- package/dist/{compressionAnalysis-B84FPXaQ.cjs → compressionAnalysis-Djv-Zvcd.cjs} +90 -104
- package/dist/{compressionAnalysis-VtYV9Zmq.d.cts → compressionAnalysis-UfmonqbM.d.cts} +136 -136
- package/dist/compressionAnalysis-UfmonqbM.d.cts.map +1 -0
- package/dist/create.cjs +21 -23
- package/dist/create.d.cts +2 -2
- package/dist/create.d.mts +2 -2
- package/dist/create.mjs +3 -5
- package/dist/{deduplicateImages-MfUDPxQz.mjs → deduplicateImages-BTCyAPfJ.mjs} +4 -5
- package/dist/{deduplicateImages-cKsnD6Ep.cjs → deduplicateImages-CaGgaqyS.cjs} +14 -15
- package/dist/{fieldAppearance-C8PoLFSc.d.mts → fieldAppearance-Df1262CT.d.cts} +44 -44
- package/dist/fieldAppearance-Df1262CT.d.cts.map +1 -0
- package/dist/{fieldAppearance-CdiGFG5e.d.cts → fieldAppearance-_CZdoUCD.d.mts} +44 -44
- package/dist/fieldAppearance-_CZdoUCD.d.mts.map +1 -0
- package/dist/fontEmbed-DGiZS0h2.d.cts +677 -0
- package/dist/fontEmbed-DGiZS0h2.d.cts.map +1 -0
- package/dist/fontEmbed-DtA_riGC.d.mts +677 -0
- package/dist/fontEmbed-DtA_riGC.d.mts.map +1 -0
- package/dist/forms.cjs +3 -4
- package/dist/forms.d.cts +2 -2
- package/dist/forms.d.mts +2 -2
- package/dist/forms.mjs +2 -3
- package/dist/{grayscaleDetect-C6kFF3dk.mjs → grayscaleDetect-6GJrgBRT.mjs} +3 -3
- package/dist/{grayscaleDetect-C2m-eEXR.cjs → grayscaleDetect-DAUqxjgR.cjs} +13 -14
- package/dist/{imageExtract-zEb1gnkb.cjs → imageExtract-DT50Hp_g.cjs} +13 -14
- package/dist/{imageExtract-Dnk_Ssv7.mjs → imageExtract-Dapir-ux.mjs} +3 -4
- package/dist/index-C1lZe66f.d.mts +8682 -0
- package/dist/index-C1lZe66f.d.mts.map +1 -0
- package/dist/index-D1SvXWSI.d.cts +8682 -0
- package/dist/index-D1SvXWSI.d.cts.map +1 -0
- package/dist/index.cjs +263 -150
- package/dist/index.d.cts +7 -7
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +14 -17
- package/dist/{layout-DH61a1iR.cjs → layout-C4vbTlBW.cjs} +184 -134
- package/dist/{layout-D6EUKSP8.mjs → layout-lO4x64kY.mjs} +50 -12
- package/dist/{loader-C7B5dVCI.mjs → loader-B1Ix7ozU.mjs} +259 -13
- package/dist/{loader-I4zdkoWc.cjs → loader-DR7H0XOf.cjs} +343 -67
- package/dist/parse.cjs +7 -8
- package/dist/parse.d.cts +3 -3
- package/dist/parse.d.mts +3 -3
- package/dist/parse.mjs +6 -7
- package/dist/pdfDocument-CH2E4UCc.d.mts +5160 -0
- package/dist/pdfDocument-CH2E4UCc.d.mts.map +1 -0
- package/dist/{pdfDocument-CEbbUP9i.cjs → pdfDocument-C_7mrBCL.cjs} +20493 -9511
- package/dist/pdfDocument-CzOipXnw.d.cts +5160 -0
- package/dist/pdfDocument-CzOipXnw.d.cts.map +1 -0
- package/dist/{pdfDocument-B0_XwS4X.mjs → pdfDocument-DRbT6HZw.mjs} +11017 -863
- package/dist/{pdfForm-9gd40uz9.cjs → pdfForm-BVS_do95.cjs} +113 -102
- package/dist/pdfForm-Ca86NDWn.d.cts +897 -0
- package/dist/pdfForm-Ca86NDWn.d.cts.map +1 -0
- package/dist/pdfForm-Ca86NDWn.d.mts +897 -0
- package/dist/pdfForm-Ca86NDWn.d.mts.map +1 -0
- package/dist/{pdfForm-Cn-cVicP.mjs → pdfForm-CfLnlsj-.mjs} +23 -18
- package/dist/{pdfObjects-1veop1_d.cjs → pdfObjects-BcPlSI0a.cjs} +62 -53
- package/dist/{pdfObjects-uEsWlfzU.mjs → pdfObjects-CB7TEdbW.mjs} +12 -2
- package/dist/rolldown-runtime-ak5kbic3.cjs +18 -0
- package/dist/{src-B1iDGLCL.cjs → src-C-IDXuvi.cjs} +9886 -1421
- package/dist/{src-Db6Qknoz.mjs → src-DJaD-bJ2.mjs} +8392 -515
- package/dist/{streamDecode-Bj568Nc9.mjs → streamDecode-BamENT3k.mjs} +129 -150
- package/dist/{streamDecode-CvgErkFu.cjs → streamDecode-DcaZz309.cjs} +139 -160
- package/package.json +26 -22
- package/dist/compressionAnalysis-DGs-MqTe.d.mts.map +0 -1
- package/dist/compressionAnalysis-VtYV9Zmq.d.cts.map +0 -1
- package/dist/fflateAdapter-LTAeAhaD.cjs +0 -207
- package/dist/fflateAdapter-PSiW_ML7.mjs +0 -196
- package/dist/fieldAppearance-C8PoLFSc.d.mts.map +0 -1
- package/dist/fieldAppearance-CdiGFG5e.d.cts.map +0 -1
- package/dist/fontEmbed-BN842wlb.d.cts +0 -659
- package/dist/fontEmbed-BN842wlb.d.cts.map +0 -1
- package/dist/fontEmbed-Dgq5K89o.d.mts +0 -659
- package/dist/fontEmbed-Dgq5K89o.d.mts.map +0 -1
- package/dist/fontSubset-5SLWMmEw.cjs +0 -518
- package/dist/fontSubset-D-vQQems.mjs +0 -495
- package/dist/index-DCSbmXWh.d.mts +0 -5939
- package/dist/index-DCSbmXWh.d.mts.map +0 -1
- package/dist/index-J1W3FdL8.d.cts +0 -5939
- package/dist/index-J1W3FdL8.d.cts.map +0 -1
- package/dist/libdeflateWasm-8b91Vmia.mjs +0 -220
- package/dist/libdeflateWasm-BdiDEJOj.cjs +0 -237
- package/dist/pdfCatalog-3yMIhJtt.mjs +0 -138
- package/dist/pdfCatalog-CYy4NXEY.cjs +0 -173
- package/dist/pdfDocument-BgvEP5Po.d.mts +0 -4673
- package/dist/pdfDocument-BgvEP5Po.d.mts.map +0 -1
- package/dist/pdfDocument-CbU-2TjT.d.cts +0 -4673
- package/dist/pdfDocument-CbU-2TjT.d.cts.map +0 -1
- package/dist/pdfForm-BiyNtYem.d.mts +0 -905
- package/dist/pdfForm-BiyNtYem.d.mts.map +0 -1
- package/dist/pdfForm-SOXJ72LW.d.cts +0 -905
- package/dist/pdfForm-SOXJ72LW.d.cts.map +0 -1
- package/dist/pdfPage-B_d9HmkG.mjs +0 -8015
- package/dist/pdfPage-Cd8jOJp6.cjs +0 -8728
- package/dist/pngEmbed-BWAbEUKF.mjs +0 -552
- package/dist/pngEmbed-D4X4ZN-3.cjs +0 -563
- package/dist/rolldown-runtime-CKhH4XqG.cjs +0 -24
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const require_pdfObjects = require(
|
|
2
|
-
const require_bridge = require(
|
|
3
|
-
const require_imageExtract = require(
|
|
4
|
-
const require_grayscaleDetect = require(
|
|
5
|
-
|
|
1
|
+
const require_pdfObjects = require("./pdfObjects-BcPlSI0a.cjs");
|
|
2
|
+
const require_bridge = require("./bridge-ByvzPu5h.cjs");
|
|
3
|
+
const require_imageExtract = require("./imageExtract-DT50Hp_g.cjs");
|
|
4
|
+
const require_grayscaleDetect = require("./grayscaleDetect-DAUqxjgR.cjs");
|
|
6
5
|
//#region src/parser/textExtractor.ts
|
|
7
6
|
/**
|
|
8
7
|
* @module parser/textExtractor
|
|
@@ -372,7 +371,7 @@ function hexToUnicode(hex) {
|
|
|
372
371
|
for (let i = 0; i < hex.length; i += step) {
|
|
373
372
|
const chunk = hex.slice(i, i + step);
|
|
374
373
|
const code = parseInt(chunk, 16);
|
|
375
|
-
if (!isNaN(code)) parts.push(String.fromCodePoint(code));
|
|
374
|
+
if (!Number.isNaN(code)) parts.push(String.fromCodePoint(code));
|
|
376
375
|
}
|
|
377
376
|
return parts.join("");
|
|
378
377
|
}
|
|
@@ -543,14 +542,15 @@ var TextState = class {
|
|
|
543
542
|
* Concatenate a matrix with the CTM (cm).
|
|
544
543
|
*/
|
|
545
544
|
concatCTM(a, b, c, d, e, f) {
|
|
546
|
-
|
|
545
|
+
const m = [
|
|
547
546
|
a,
|
|
548
547
|
b,
|
|
549
548
|
c,
|
|
550
549
|
d,
|
|
551
550
|
e,
|
|
552
551
|
f
|
|
553
|
-
]
|
|
552
|
+
];
|
|
553
|
+
this.ctm = multiplyMatrices(m, this.ctm);
|
|
554
554
|
}
|
|
555
555
|
/**
|
|
556
556
|
* Reset the text matrix to identity (called at BT).
|
|
@@ -570,14 +570,15 @@ var TextState = class {
|
|
|
570
570
|
* Move text position (Td).
|
|
571
571
|
*/
|
|
572
572
|
moveText(tx, ty) {
|
|
573
|
-
|
|
573
|
+
const translation = [
|
|
574
574
|
1,
|
|
575
575
|
0,
|
|
576
576
|
0,
|
|
577
577
|
1,
|
|
578
578
|
tx,
|
|
579
579
|
ty
|
|
580
|
-
]
|
|
580
|
+
];
|
|
581
|
+
this.textLineMatrix = multiplyMatrices(translation, this.textLineMatrix);
|
|
581
582
|
this.textMatrix = [...this.textLineMatrix];
|
|
582
583
|
}
|
|
583
584
|
/**
|
|
@@ -633,14 +634,15 @@ var TextState = class {
|
|
|
633
634
|
* Advance the text matrix by the width of the given text.
|
|
634
635
|
*/
|
|
635
636
|
advanceByText(text) {
|
|
636
|
-
|
|
637
|
+
const tx = [
|
|
637
638
|
1,
|
|
638
639
|
0,
|
|
639
640
|
0,
|
|
640
641
|
1,
|
|
641
642
|
this.estimateWidth(text),
|
|
642
643
|
0
|
|
643
|
-
]
|
|
644
|
+
];
|
|
645
|
+
this.textMatrix = multiplyMatrices(tx, this.textMatrix);
|
|
644
646
|
}
|
|
645
647
|
/**
|
|
646
648
|
* Advance the text matrix by a TJ displacement value.
|
|
@@ -648,14 +650,15 @@ var TextState = class {
|
|
|
648
650
|
* The displacement is in thousandths of a unit of text space.
|
|
649
651
|
*/
|
|
650
652
|
advanceByDisplacement(displacement) {
|
|
651
|
-
|
|
653
|
+
const m = [
|
|
652
654
|
1,
|
|
653
655
|
0,
|
|
654
656
|
0,
|
|
655
657
|
1,
|
|
656
658
|
displacement / 1e3 * this.fontSize * (this.horizontalScaling / 100),
|
|
657
659
|
0
|
|
658
|
-
]
|
|
660
|
+
];
|
|
661
|
+
this.textMatrix = multiplyMatrices(m, this.textMatrix);
|
|
659
662
|
}
|
|
660
663
|
/**
|
|
661
664
|
* Decode an operand (string or hex string) into a readable text string.
|
|
@@ -666,7 +669,7 @@ var TextState = class {
|
|
|
666
669
|
decodeString(operand) {
|
|
667
670
|
if (operand == null) return "";
|
|
668
671
|
if (typeof operand === "number") return "";
|
|
669
|
-
const raw = typeof operand === "string" ? operand :
|
|
672
|
+
const raw = typeof operand === "string" ? operand : "";
|
|
670
673
|
const cmap = this.cmapCache.get(this.fontName);
|
|
671
674
|
const isCid = this.cidFontCache.get(this.fontName) ?? false;
|
|
672
675
|
if (cmap) return this.decodeWithCMap(raw, cmap, isCid);
|
|
@@ -737,7 +740,7 @@ function operandAsNumber(operand) {
|
|
|
737
740
|
if (operand instanceof require_pdfObjects.PdfNumber) return operand.value;
|
|
738
741
|
if (typeof operand === "string") {
|
|
739
742
|
const n = parseFloat(operand);
|
|
740
|
-
return isNaN(n) ? 0 : n;
|
|
743
|
+
return Number.isNaN(n) ? 0 : n;
|
|
741
744
|
}
|
|
742
745
|
return 0;
|
|
743
746
|
}
|
|
@@ -757,7 +760,6 @@ function operandAsString(operand) {
|
|
|
757
760
|
function decodeText(data) {
|
|
758
761
|
return new TextDecoder("latin1").decode(data);
|
|
759
762
|
}
|
|
760
|
-
|
|
761
763
|
//#endregion
|
|
762
764
|
//#region src/parser/contentStreamParser.ts
|
|
763
765
|
/**
|
|
@@ -785,26 +787,12 @@ function decodeText(data) {
|
|
|
785
787
|
function parseContentStream(data) {
|
|
786
788
|
return new ContentStreamLexer(data).parse();
|
|
787
789
|
}
|
|
788
|
-
var TokenType = /* @__PURE__ */ function(TokenType) {
|
|
789
|
-
TokenType[TokenType["Number"] = 0] = "Number";
|
|
790
|
-
TokenType[TokenType["String"] = 1] = "String";
|
|
791
|
-
TokenType[TokenType["HexString"] = 2] = "HexString";
|
|
792
|
-
TokenType[TokenType["Name"] = 3] = "Name";
|
|
793
|
-
TokenType[TokenType["Bool"] = 4] = "Bool";
|
|
794
|
-
TokenType[TokenType["Null"] = 5] = "Null";
|
|
795
|
-
TokenType[TokenType["ArrayStart"] = 6] = "ArrayStart";
|
|
796
|
-
TokenType[TokenType["ArrayEnd"] = 7] = "ArrayEnd";
|
|
797
|
-
TokenType[TokenType["Operator"] = 8] = "Operator";
|
|
798
|
-
TokenType[TokenType["InlineImage"] = 9] = "InlineImage";
|
|
799
|
-
TokenType[TokenType["EOF"] = 10] = "EOF";
|
|
800
|
-
return TokenType;
|
|
801
|
-
}(TokenType || {});
|
|
802
790
|
/**
|
|
803
791
|
* `hexVal[b]` is the numeric value (0-15) of a hex character, or -1 if
|
|
804
792
|
* the byte is not a valid hex digit.
|
|
805
793
|
*/
|
|
806
794
|
const hexVal = /* @__PURE__ */ (() => {
|
|
807
|
-
const t = new Int8Array(256).fill(-1);
|
|
795
|
+
const t = (/* @__PURE__ */ new Int8Array(256)).fill(-1);
|
|
808
796
|
for (let i = 0; i <= 9; i++) t[48 + i] = i;
|
|
809
797
|
for (let i = 0; i < 6; i++) {
|
|
810
798
|
t[65 + i] = 10 + i;
|
|
@@ -833,23 +821,23 @@ var ContentStreamLexer = class {
|
|
|
833
821
|
const operandStack = [];
|
|
834
822
|
while (true) {
|
|
835
823
|
const token = this.nextToken();
|
|
836
|
-
if (token.type ===
|
|
824
|
+
if (token.type === 10) break;
|
|
837
825
|
switch (token.type) {
|
|
838
|
-
case
|
|
839
|
-
case
|
|
840
|
-
case
|
|
841
|
-
case
|
|
842
|
-
case
|
|
843
|
-
case
|
|
826
|
+
case 0:
|
|
827
|
+
case 1:
|
|
828
|
+
case 2:
|
|
829
|
+
case 4:
|
|
830
|
+
case 5:
|
|
831
|
+
case 3:
|
|
844
832
|
operandStack.push(token.value);
|
|
845
833
|
break;
|
|
846
|
-
case
|
|
834
|
+
case 6: {
|
|
847
835
|
const arr = this.parseArray();
|
|
848
836
|
operandStack.push(arr);
|
|
849
837
|
break;
|
|
850
838
|
}
|
|
851
|
-
case
|
|
852
|
-
case
|
|
839
|
+
case 7: break;
|
|
840
|
+
case 8: {
|
|
853
841
|
const op = token.value;
|
|
854
842
|
if (op === "BI") {
|
|
855
843
|
const inlineImg = this.parseInlineImage();
|
|
@@ -863,7 +851,7 @@ var ContentStreamLexer = class {
|
|
|
863
851
|
});
|
|
864
852
|
break;
|
|
865
853
|
}
|
|
866
|
-
case
|
|
854
|
+
case 9: break;
|
|
867
855
|
}
|
|
868
856
|
}
|
|
869
857
|
return result;
|
|
@@ -875,18 +863,18 @@ var ContentStreamLexer = class {
|
|
|
875
863
|
const items = [];
|
|
876
864
|
while (true) {
|
|
877
865
|
const token = this.nextToken();
|
|
878
|
-
if (token.type ===
|
|
879
|
-
if (token.type ===
|
|
866
|
+
if (token.type === 10) break;
|
|
867
|
+
if (token.type === 7) break;
|
|
880
868
|
switch (token.type) {
|
|
881
|
-
case
|
|
882
|
-
case
|
|
883
|
-
case
|
|
884
|
-
case
|
|
885
|
-
case
|
|
886
|
-
case
|
|
869
|
+
case 0:
|
|
870
|
+
case 1:
|
|
871
|
+
case 2:
|
|
872
|
+
case 4:
|
|
873
|
+
case 5:
|
|
874
|
+
case 3:
|
|
887
875
|
items.push(token.value);
|
|
888
876
|
break;
|
|
889
|
-
case
|
|
877
|
+
case 6:
|
|
890
878
|
items.push(this.parseArray());
|
|
891
879
|
break;
|
|
892
880
|
default: break;
|
|
@@ -911,16 +899,16 @@ var ContentStreamLexer = class {
|
|
|
911
899
|
break;
|
|
912
900
|
}
|
|
913
901
|
const keyToken = this.nextToken();
|
|
914
|
-
if (keyToken.type ===
|
|
902
|
+
if (keyToken.type === 8) {
|
|
915
903
|
const kw = keyToken.value;
|
|
916
904
|
if (kw === "ID") break;
|
|
917
905
|
dict[kw] = this.nextToken().value;
|
|
918
906
|
continue;
|
|
919
907
|
}
|
|
920
|
-
if (keyToken.type ===
|
|
908
|
+
if (keyToken.type === 3) {
|
|
921
909
|
const name = keyToken.value.value;
|
|
922
910
|
dict[name] = this.nextToken().value;
|
|
923
|
-
} else if (keyToken.type ===
|
|
911
|
+
} else if (keyToken.type === 10) break;
|
|
924
912
|
}
|
|
925
913
|
if (this.pos < this.data.length) {
|
|
926
914
|
const ch = this.data[this.pos];
|
|
@@ -973,7 +961,7 @@ var ContentStreamLexer = class {
|
|
|
973
961
|
nextToken() {
|
|
974
962
|
this.skipWhitespaceAndComments();
|
|
975
963
|
if (this.pos >= this.data.length) return {
|
|
976
|
-
type:
|
|
964
|
+
type: 10,
|
|
977
965
|
value: null
|
|
978
966
|
};
|
|
979
967
|
const ch = this.data[this.pos];
|
|
@@ -992,14 +980,14 @@ var ContentStreamLexer = class {
|
|
|
992
980
|
if (ch === 91) {
|
|
993
981
|
this.pos++;
|
|
994
982
|
return {
|
|
995
|
-
type:
|
|
983
|
+
type: 6,
|
|
996
984
|
value: null
|
|
997
985
|
};
|
|
998
986
|
}
|
|
999
987
|
if (ch === 93) {
|
|
1000
988
|
this.pos++;
|
|
1001
989
|
return {
|
|
1002
|
-
type:
|
|
990
|
+
type: 7,
|
|
1003
991
|
value: null
|
|
1004
992
|
};
|
|
1005
993
|
}
|
|
@@ -1101,7 +1089,7 @@ var ContentStreamLexer = class {
|
|
|
1101
1089
|
}
|
|
1102
1090
|
}
|
|
1103
1091
|
return {
|
|
1104
|
-
type:
|
|
1092
|
+
type: 1,
|
|
1105
1093
|
value: parts.join("")
|
|
1106
1094
|
};
|
|
1107
1095
|
}
|
|
@@ -1136,7 +1124,7 @@ var ContentStreamLexer = class {
|
|
|
1136
1124
|
}
|
|
1137
1125
|
if (hi !== -1) bytes.push(hi << 4);
|
|
1138
1126
|
return {
|
|
1139
|
-
type:
|
|
1127
|
+
type: 2,
|
|
1140
1128
|
value: String.fromCharCode(...bytes)
|
|
1141
1129
|
};
|
|
1142
1130
|
}
|
|
@@ -1162,7 +1150,7 @@ var ContentStreamLexer = class {
|
|
|
1162
1150
|
this.pos++;
|
|
1163
1151
|
}
|
|
1164
1152
|
return {
|
|
1165
|
-
type:
|
|
1153
|
+
type: 3,
|
|
1166
1154
|
value: require_pdfObjects.PdfName.of(parts.join(""))
|
|
1167
1155
|
};
|
|
1168
1156
|
}
|
|
@@ -1185,8 +1173,8 @@ var ContentStreamLexer = class {
|
|
|
1185
1173
|
const str = this.decodeAscii(start, this.pos);
|
|
1186
1174
|
const value = parseFloat(str);
|
|
1187
1175
|
return {
|
|
1188
|
-
type:
|
|
1189
|
-
value: isNaN(value) ? 0 : value
|
|
1176
|
+
type: 0,
|
|
1177
|
+
value: Number.isNaN(value) ? 0 : value
|
|
1190
1178
|
};
|
|
1191
1179
|
}
|
|
1192
1180
|
/**
|
|
@@ -1202,19 +1190,19 @@ var ContentStreamLexer = class {
|
|
|
1202
1190
|
}
|
|
1203
1191
|
const word = this.decodeAscii(start, this.pos);
|
|
1204
1192
|
if (word === "true") return {
|
|
1205
|
-
type:
|
|
1193
|
+
type: 4,
|
|
1206
1194
|
value: true
|
|
1207
1195
|
};
|
|
1208
1196
|
if (word === "false") return {
|
|
1209
|
-
type:
|
|
1197
|
+
type: 4,
|
|
1210
1198
|
value: false
|
|
1211
1199
|
};
|
|
1212
1200
|
if (word === "null") return {
|
|
1213
|
-
type:
|
|
1201
|
+
type: 5,
|
|
1214
1202
|
value: null
|
|
1215
1203
|
};
|
|
1216
1204
|
return {
|
|
1217
|
-
type:
|
|
1205
|
+
type: 8,
|
|
1218
1206
|
value: word
|
|
1219
1207
|
};
|
|
1220
1208
|
}
|
|
@@ -1257,10 +1245,9 @@ var ContentStreamLexer = class {
|
|
|
1257
1245
|
* Decode a slice of the data as ASCII text.
|
|
1258
1246
|
*/
|
|
1259
1247
|
decodeAscii(start, end) {
|
|
1260
|
-
return
|
|
1248
|
+
return new TextDecoder("latin1").decode(this.data.subarray(start, end));
|
|
1261
1249
|
}
|
|
1262
1250
|
};
|
|
1263
|
-
|
|
1264
1251
|
//#endregion
|
|
1265
1252
|
//#region src/assets/image/dpiAnalyze.ts
|
|
1266
1253
|
/**
|
|
@@ -1310,7 +1297,7 @@ function computeImageDpi(imageWidth, imageHeight, displayWidth, displayHeight) {
|
|
|
1310
1297
|
*/
|
|
1311
1298
|
function computeTargetDimensions(imageWidth, imageHeight, displayWidth, displayHeight, maxDpi) {
|
|
1312
1299
|
const dpi = computeImageDpi(imageWidth, imageHeight, displayWidth, displayHeight);
|
|
1313
|
-
if (dpi.effectiveDpi <= maxDpi || !isFinite(dpi.effectiveDpi)) return {
|
|
1300
|
+
if (dpi.effectiveDpi <= maxDpi || !Number.isFinite(dpi.effectiveDpi)) return {
|
|
1314
1301
|
width: imageWidth,
|
|
1315
1302
|
height: imageHeight,
|
|
1316
1303
|
downscaled: false
|
|
@@ -1322,7 +1309,6 @@ function computeTargetDimensions(imageWidth, imageHeight, displayWidth, displayH
|
|
|
1322
1309
|
downscaled: true
|
|
1323
1310
|
};
|
|
1324
1311
|
}
|
|
1325
|
-
|
|
1326
1312
|
//#endregion
|
|
1327
1313
|
//#region src/assets/image/compressionAnalysis.ts
|
|
1328
1314
|
/**
|
|
@@ -1366,7 +1352,7 @@ function estimateJpegSizeHeuristic(width, height, channels, quality) {
|
|
|
1366
1352
|
*/
|
|
1367
1353
|
function determineRecommendation(savingsPercent, isGrayscale, colorSpace, effectiveDpi, maxDpi) {
|
|
1368
1354
|
if (isGrayscale && colorSpace !== "DeviceGray" && colorSpace !== "CalGray") return "grayscale";
|
|
1369
|
-
if (effectiveDpi !== void 0 && isFinite(effectiveDpi) && effectiveDpi > maxDpi) return "downscale";
|
|
1355
|
+
if (effectiveDpi !== void 0 && Number.isFinite(effectiveDpi) && effectiveDpi > maxDpi) return "downscale";
|
|
1370
1356
|
if (savingsPercent > 10) return "recompress";
|
|
1371
1357
|
return "keep";
|
|
1372
1358
|
}
|
|
@@ -1484,42 +1470,42 @@ function analyzeImages(doc, options) {
|
|
|
1484
1470
|
totalSavingsPercent: totalCurrentSize > 0 ? totalSavings / totalCurrentSize * 100 : 0
|
|
1485
1471
|
};
|
|
1486
1472
|
}
|
|
1487
|
-
|
|
1488
1473
|
//#endregion
|
|
1489
|
-
Object.defineProperty(exports,
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1474
|
+
Object.defineProperty(exports, "analyzeImages", {
|
|
1475
|
+
enumerable: true,
|
|
1476
|
+
get: function() {
|
|
1477
|
+
return analyzeImages;
|
|
1478
|
+
}
|
|
1494
1479
|
});
|
|
1495
|
-
Object.defineProperty(exports,
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1480
|
+
Object.defineProperty(exports, "computeImageDpi", {
|
|
1481
|
+
enumerable: true,
|
|
1482
|
+
get: function() {
|
|
1483
|
+
return computeImageDpi;
|
|
1484
|
+
}
|
|
1500
1485
|
});
|
|
1501
|
-
Object.defineProperty(exports,
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1486
|
+
Object.defineProperty(exports, "computeTargetDimensions", {
|
|
1487
|
+
enumerable: true,
|
|
1488
|
+
get: function() {
|
|
1489
|
+
return computeTargetDimensions;
|
|
1490
|
+
}
|
|
1506
1491
|
});
|
|
1507
|
-
Object.defineProperty(exports,
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1492
|
+
Object.defineProperty(exports, "extractText", {
|
|
1493
|
+
enumerable: true,
|
|
1494
|
+
get: function() {
|
|
1495
|
+
return extractText;
|
|
1496
|
+
}
|
|
1512
1497
|
});
|
|
1513
|
-
Object.defineProperty(exports,
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1498
|
+
Object.defineProperty(exports, "extractTextWithPositions", {
|
|
1499
|
+
enumerable: true,
|
|
1500
|
+
get: function() {
|
|
1501
|
+
return extractTextWithPositions;
|
|
1502
|
+
}
|
|
1518
1503
|
});
|
|
1519
|
-
Object.defineProperty(exports,
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1504
|
+
Object.defineProperty(exports, "parseContentStream", {
|
|
1505
|
+
enumerable: true,
|
|
1506
|
+
get: function() {
|
|
1507
|
+
return parseContentStream;
|
|
1508
|
+
}
|
|
1524
1509
|
});
|
|
1525
|
-
|
|
1510
|
+
|
|
1511
|
+
//# sourceMappingURL=compressionAnalysis-Djv-Zvcd.cjs.map
|