@chialab/pdfjs-lib 1.0.0-alpha.20 → 1.0.0-alpha.21
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/browser/NodeUtilsStabs-MUAXKISB.js +19 -0
- package/dist/browser/chunk-3ZTAZS2X.js +25 -0
- package/dist/browser/{chunk-NJUB3B5A.js → chunk-W3YEFTNG.js} +785 -3
- package/dist/browser/index.js +1128 -77
- package/dist/browser/worker.js +10 -12
- package/dist/lib/NodeUtils.d.ts +24 -0
- package/dist/node/NodeUtils-EDBNTTIR.js +20 -0
- package/dist/node/{chunk-3XZOTLLE.js → chunk-K6VD27AD.js} +269 -68
- package/dist/node/index.js +9 -193
- package/dist/pdf.js/src/display/api.d.ts +1 -1
- package/dist/pdf.js/src/display/cmap_reader_factory.d.ts +25 -0
- package/dist/pdf.js/src/display/wasm_factory.d.ts +20 -0
- package/package.json +1 -1
- package/dist/browser/NodeCanvasFactory-ONRE5YYL.js +0 -58
- package/dist/browser/chunk-5IWODJWD.js +0 -801
- package/dist/browser/chunk-ELOUEWKT.js +0 -1142
- package/dist/node/NodeCanvasFactory-YRBSQ5MH.js +0 -8
package/dist/browser/worker.js
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DateFormats,
|
|
3
|
-
MessageHandler,
|
|
4
|
-
MurmurHash3_64,
|
|
5
|
-
TimeFormats,
|
|
6
|
-
convertBlackAndWhiteToRGBA,
|
|
7
|
-
convertToRGBA,
|
|
8
|
-
grayToRGBA,
|
|
9
|
-
wrapReason
|
|
10
|
-
} from "./chunk-5IWODJWD.js";
|
|
11
1
|
import {
|
|
12
2
|
AbortException,
|
|
13
3
|
AnnotationActionEventType,
|
|
@@ -21,6 +11,7 @@ import {
|
|
|
21
11
|
AnnotationType,
|
|
22
12
|
BASELINE_FACTOR,
|
|
23
13
|
BaseException,
|
|
14
|
+
DateFormats,
|
|
24
15
|
DocumentActionEventType,
|
|
25
16
|
DrawOPS,
|
|
26
17
|
FONT_IDENTITY_MATRIX,
|
|
@@ -31,6 +22,8 @@ import {
|
|
|
31
22
|
LINE_DESCENT_FACTOR,
|
|
32
23
|
LINE_FACTOR,
|
|
33
24
|
MathClamp,
|
|
25
|
+
MessageHandler,
|
|
26
|
+
MurmurHash3_64,
|
|
34
27
|
OPS,
|
|
35
28
|
PageActionEventType,
|
|
36
29
|
PasswordException,
|
|
@@ -38,15 +31,19 @@ import {
|
|
|
38
31
|
PermissionFlag,
|
|
39
32
|
RenderingIntentFlag,
|
|
40
33
|
TextRenderingMode,
|
|
34
|
+
TimeFormats,
|
|
41
35
|
Util,
|
|
42
36
|
VerbosityLevel,
|
|
43
37
|
_isValidExplicitDest,
|
|
44
38
|
assert,
|
|
45
39
|
bytesToString,
|
|
40
|
+
convertBlackAndWhiteToRGBA,
|
|
41
|
+
convertToRGBA,
|
|
46
42
|
createValidAbsoluteUrl,
|
|
47
43
|
fromBase64Util,
|
|
48
44
|
getModificationDate,
|
|
49
45
|
getVerbosityLevel,
|
|
46
|
+
grayToRGBA,
|
|
50
47
|
hexNumbers,
|
|
51
48
|
info,
|
|
52
49
|
isArrayEqual,
|
|
@@ -62,8 +59,9 @@ import {
|
|
|
62
59
|
toHexUtil,
|
|
63
60
|
unreachable,
|
|
64
61
|
utf8StringToString,
|
|
65
|
-
warn
|
|
66
|
-
|
|
62
|
+
warn,
|
|
63
|
+
wrapReason
|
|
64
|
+
} from "./chunk-W3YEFTNG.js";
|
|
67
65
|
import {
|
|
68
66
|
__privateAdd,
|
|
69
67
|
__privateGet,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseCMapReaderFactory } from '../pdf.js/src/display/cmap_reader_factory.js';
|
|
2
|
+
import { BaseStandardFontDataFactory } from '../pdf.js/src/display/standard_fontdata_factory.js';
|
|
3
|
+
import { BaseWasmFactory } from '../pdf.js/src/display/wasm_factory.js';
|
|
4
|
+
export declare function fetchData(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
5
|
+
export declare class NodeCMapReaderFactory extends BaseCMapReaderFactory {
|
|
6
|
+
/**
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
10
|
+
}
|
|
11
|
+
export declare class NodeStandardFontDataFactory extends BaseStandardFontDataFactory {
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
*/
|
|
15
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
16
|
+
}
|
|
17
|
+
export declare class NodeWasmFactory extends BaseWasmFactory {
|
|
18
|
+
/**
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
_fetch(url: string): Promise<Uint8Array<ArrayBuffer>>;
|
|
22
|
+
}
|
|
23
|
+
export * from './NodeCanvasFactory.js';
|
|
24
|
+
export * from './NodeFilterFactory.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NodeCMapReaderFactory,
|
|
3
|
+
NodeCanvasFactory,
|
|
4
|
+
NodeFilterFactory,
|
|
5
|
+
NodeStandardFontDataFactory,
|
|
6
|
+
NodeWasmFactory,
|
|
7
|
+
fetchData2 as fetchData,
|
|
8
|
+
filtersRegistry
|
|
9
|
+
} from "./chunk-K6VD27AD.js";
|
|
10
|
+
import "./chunk-XMKSLA4K.js";
|
|
11
|
+
import "./chunk-7MW5RQZ5.js";
|
|
12
|
+
export {
|
|
13
|
+
NodeCMapReaderFactory,
|
|
14
|
+
NodeCanvasFactory,
|
|
15
|
+
NodeFilterFactory,
|
|
16
|
+
NodeStandardFontDataFactory,
|
|
17
|
+
NodeWasmFactory,
|
|
18
|
+
fetchData,
|
|
19
|
+
filtersRegistry
|
|
20
|
+
};
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
FeatureTest,
|
|
4
4
|
Util,
|
|
5
5
|
shadow,
|
|
6
|
+
stringToBytes,
|
|
6
7
|
unreachable,
|
|
7
8
|
updateUrlHash,
|
|
8
9
|
warn
|
|
@@ -16,73 +17,13 @@ import {
|
|
|
16
17
|
__publicField
|
|
17
18
|
} from "./chunk-7MW5RQZ5.js";
|
|
18
19
|
|
|
19
|
-
// src/lib/
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
__privateAdd(this, _enableHWA, false);
|
|
27
|
-
if (false) {
|
|
28
|
-
unreachable("Cannot initialize BaseCanvasFactory.");
|
|
29
|
-
}
|
|
30
|
-
__privateSet(this, _enableHWA, enableHWA);
|
|
31
|
-
}
|
|
32
|
-
create(width, height) {
|
|
33
|
-
if (width <= 0 || height <= 0) {
|
|
34
|
-
throw new Error("Invalid canvas size");
|
|
35
|
-
}
|
|
36
|
-
const canvas = this._createCanvas(width, height);
|
|
37
|
-
return {
|
|
38
|
-
canvas,
|
|
39
|
-
context: canvas.getContext("2d", {
|
|
40
|
-
willReadFrequently: !__privateGet(this, _enableHWA)
|
|
41
|
-
})
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
reset(canvasAndContext, width, height) {
|
|
45
|
-
if (!canvasAndContext.canvas) {
|
|
46
|
-
throw new Error("Canvas is not specified");
|
|
47
|
-
}
|
|
48
|
-
if (width <= 0 || height <= 0) {
|
|
49
|
-
throw new Error("Invalid canvas size");
|
|
50
|
-
}
|
|
51
|
-
canvasAndContext.canvas.width = width;
|
|
52
|
-
canvasAndContext.canvas.height = height;
|
|
53
|
-
}
|
|
54
|
-
destroy(canvasAndContext) {
|
|
55
|
-
if (!canvasAndContext.canvas) {
|
|
56
|
-
throw new Error("Canvas is not specified");
|
|
57
|
-
}
|
|
58
|
-
canvasAndContext.canvas.width = 0;
|
|
59
|
-
canvasAndContext.canvas.height = 0;
|
|
60
|
-
canvasAndContext.canvas = null;
|
|
61
|
-
canvasAndContext.context = null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @ignore
|
|
65
|
-
*/
|
|
66
|
-
_createCanvas(width, height) {
|
|
67
|
-
unreachable("Abstract method `_createCanvas` called.");
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
_enableHWA = new WeakMap();
|
|
71
|
-
var DOMCanvasFactory = class extends BaseCanvasFactory {
|
|
72
|
-
constructor({ ownerDocument = globalThis.document, enableHWA = false }) {
|
|
73
|
-
super({ enableHWA });
|
|
74
|
-
this._document = ownerDocument;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* @ignore
|
|
78
|
-
*/
|
|
79
|
-
_createCanvas(width, height) {
|
|
80
|
-
const canvas = this._document.createElement("canvas");
|
|
81
|
-
canvas.width = width;
|
|
82
|
-
canvas.height = height;
|
|
83
|
-
return canvas;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
20
|
+
// src/lib/NodeUtils.ts
|
|
21
|
+
import {
|
|
22
|
+
DOMMatrix as NodeDOMMatrix,
|
|
23
|
+
DOMPoint as NodeDOMPoint,
|
|
24
|
+
ImageData as NodeImageData,
|
|
25
|
+
Path2D as NodePath2D
|
|
26
|
+
} from "skia-canvas";
|
|
86
27
|
|
|
87
28
|
// src/pdf.js/src/display/display_utils.js
|
|
88
29
|
var SVG_NS = "http://www.w3.org/2000/svg";
|
|
@@ -647,6 +588,207 @@ var SupportedImageMimeTypes = [
|
|
|
647
588
|
"image/x-icon"
|
|
648
589
|
];
|
|
649
590
|
|
|
591
|
+
// src/pdf.js/src/display/cmap_reader_factory.js
|
|
592
|
+
var BaseCMapReaderFactory = class {
|
|
593
|
+
constructor({ baseUrl = null, isCompressed = true }) {
|
|
594
|
+
if (false) {
|
|
595
|
+
unreachable("Cannot initialize BaseCMapReaderFactory.");
|
|
596
|
+
}
|
|
597
|
+
this.baseUrl = baseUrl;
|
|
598
|
+
this.isCompressed = isCompressed;
|
|
599
|
+
}
|
|
600
|
+
async fetch({ name }) {
|
|
601
|
+
if (!this.baseUrl) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
"Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided."
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
if (!name) {
|
|
607
|
+
throw new Error("CMap name must be specified.");
|
|
608
|
+
}
|
|
609
|
+
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
|
610
|
+
return this._fetch(url).then((cMapData) => ({ cMapData, isCompressed: this.isCompressed })).catch((reason) => {
|
|
611
|
+
throw new Error(
|
|
612
|
+
`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`
|
|
613
|
+
);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* @ignore
|
|
618
|
+
* @returns {Promise<Uint8Array>}
|
|
619
|
+
*/
|
|
620
|
+
async _fetch(url) {
|
|
621
|
+
unreachable("Abstract method `_fetch` called.");
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
var DOMCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
625
|
+
/**
|
|
626
|
+
* @ignore
|
|
627
|
+
*/
|
|
628
|
+
async _fetch(url) {
|
|
629
|
+
const data = await fetchData(
|
|
630
|
+
url,
|
|
631
|
+
/* type = */
|
|
632
|
+
this.isCompressed ? "arraybuffer" : "text"
|
|
633
|
+
);
|
|
634
|
+
return data instanceof ArrayBuffer ? new Uint8Array(data) : stringToBytes(data);
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
// src/pdf.js/src/display/standard_fontdata_factory.js
|
|
639
|
+
var BaseStandardFontDataFactory = class {
|
|
640
|
+
constructor({ baseUrl = null }) {
|
|
641
|
+
if (false) {
|
|
642
|
+
unreachable("Cannot initialize BaseStandardFontDataFactory.");
|
|
643
|
+
}
|
|
644
|
+
this.baseUrl = baseUrl;
|
|
645
|
+
}
|
|
646
|
+
async fetch({ filename }) {
|
|
647
|
+
if (!this.baseUrl) {
|
|
648
|
+
throw new Error(
|
|
649
|
+
"Ensure that the `standardFontDataUrl` API parameter is provided."
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
if (!filename) {
|
|
653
|
+
throw new Error("Font filename must be specified.");
|
|
654
|
+
}
|
|
655
|
+
const url = `${this.baseUrl}${filename}`;
|
|
656
|
+
return this._fetch(url).catch((reason) => {
|
|
657
|
+
throw new Error(`Unable to load font data at: ${url}`);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* @ignore
|
|
662
|
+
* @returns {Promise<Uint8Array>}
|
|
663
|
+
*/
|
|
664
|
+
async _fetch(url) {
|
|
665
|
+
unreachable("Abstract method `_fetch` called.");
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
var DOMStandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
669
|
+
/**
|
|
670
|
+
* @ignore
|
|
671
|
+
*/
|
|
672
|
+
async _fetch(url) {
|
|
673
|
+
const data = await fetchData(
|
|
674
|
+
url,
|
|
675
|
+
/* type = */
|
|
676
|
+
"arraybuffer"
|
|
677
|
+
);
|
|
678
|
+
return new Uint8Array(data);
|
|
679
|
+
}
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
// src/pdf.js/src/display/wasm_factory.js
|
|
683
|
+
var BaseWasmFactory = class {
|
|
684
|
+
constructor({ baseUrl = null }) {
|
|
685
|
+
if (false) {
|
|
686
|
+
unreachable("Cannot initialize BaseWasmFactory.");
|
|
687
|
+
}
|
|
688
|
+
this.baseUrl = baseUrl;
|
|
689
|
+
}
|
|
690
|
+
async fetch({ filename }) {
|
|
691
|
+
if (!this.baseUrl) {
|
|
692
|
+
throw new Error("Ensure that the `wasmUrl` API parameter is provided.");
|
|
693
|
+
}
|
|
694
|
+
if (!filename) {
|
|
695
|
+
throw new Error("Wasm filename must be specified.");
|
|
696
|
+
}
|
|
697
|
+
const url = `${this.baseUrl}${filename}`;
|
|
698
|
+
return this._fetch(url).catch((reason) => {
|
|
699
|
+
throw new Error(`Unable to load wasm data at: ${url}`);
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* @ignore
|
|
704
|
+
* @returns {Promise<Uint8Array>}
|
|
705
|
+
*/
|
|
706
|
+
async _fetch(url) {
|
|
707
|
+
unreachable("Abstract method `_fetch` called.");
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
var DOMWasmFactory = class extends BaseWasmFactory {
|
|
711
|
+
/**
|
|
712
|
+
* @ignore
|
|
713
|
+
*/
|
|
714
|
+
async _fetch(url) {
|
|
715
|
+
const data = await fetchData(
|
|
716
|
+
url,
|
|
717
|
+
/* type = */
|
|
718
|
+
"arraybuffer"
|
|
719
|
+
);
|
|
720
|
+
return new Uint8Array(data);
|
|
721
|
+
}
|
|
722
|
+
};
|
|
723
|
+
|
|
724
|
+
// src/lib/NodeCanvasFactory.ts
|
|
725
|
+
import { Canvas } from "skia-canvas";
|
|
726
|
+
|
|
727
|
+
// src/pdf.js/src/display/canvas_factory.js
|
|
728
|
+
var _enableHWA;
|
|
729
|
+
var BaseCanvasFactory = class {
|
|
730
|
+
constructor({ enableHWA = false }) {
|
|
731
|
+
__privateAdd(this, _enableHWA, false);
|
|
732
|
+
if (false) {
|
|
733
|
+
unreachable("Cannot initialize BaseCanvasFactory.");
|
|
734
|
+
}
|
|
735
|
+
__privateSet(this, _enableHWA, enableHWA);
|
|
736
|
+
}
|
|
737
|
+
create(width, height) {
|
|
738
|
+
if (width <= 0 || height <= 0) {
|
|
739
|
+
throw new Error("Invalid canvas size");
|
|
740
|
+
}
|
|
741
|
+
const canvas = this._createCanvas(width, height);
|
|
742
|
+
return {
|
|
743
|
+
canvas,
|
|
744
|
+
context: canvas.getContext("2d", {
|
|
745
|
+
willReadFrequently: !__privateGet(this, _enableHWA)
|
|
746
|
+
})
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
reset(canvasAndContext, width, height) {
|
|
750
|
+
if (!canvasAndContext.canvas) {
|
|
751
|
+
throw new Error("Canvas is not specified");
|
|
752
|
+
}
|
|
753
|
+
if (width <= 0 || height <= 0) {
|
|
754
|
+
throw new Error("Invalid canvas size");
|
|
755
|
+
}
|
|
756
|
+
canvasAndContext.canvas.width = width;
|
|
757
|
+
canvasAndContext.canvas.height = height;
|
|
758
|
+
}
|
|
759
|
+
destroy(canvasAndContext) {
|
|
760
|
+
if (!canvasAndContext.canvas) {
|
|
761
|
+
throw new Error("Canvas is not specified");
|
|
762
|
+
}
|
|
763
|
+
canvasAndContext.canvas.width = 0;
|
|
764
|
+
canvasAndContext.canvas.height = 0;
|
|
765
|
+
canvasAndContext.canvas = null;
|
|
766
|
+
canvasAndContext.context = null;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* @ignore
|
|
770
|
+
*/
|
|
771
|
+
_createCanvas(width, height) {
|
|
772
|
+
unreachable("Abstract method `_createCanvas` called.");
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
_enableHWA = new WeakMap();
|
|
776
|
+
var DOMCanvasFactory = class extends BaseCanvasFactory {
|
|
777
|
+
constructor({ ownerDocument = globalThis.document, enableHWA = false }) {
|
|
778
|
+
super({ enableHWA });
|
|
779
|
+
this._document = ownerDocument;
|
|
780
|
+
}
|
|
781
|
+
/**
|
|
782
|
+
* @ignore
|
|
783
|
+
*/
|
|
784
|
+
_createCanvas(width, height) {
|
|
785
|
+
const canvas = this._document.createElement("canvas");
|
|
786
|
+
canvas.width = width;
|
|
787
|
+
canvas.height = height;
|
|
788
|
+
return canvas;
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
|
|
650
792
|
// src/pdf.js/src/display/filter_factory.js
|
|
651
793
|
var BaseFilterFactory = class {
|
|
652
794
|
constructor() {
|
|
@@ -1402,6 +1544,56 @@ var NodeCanvasFactory = class extends BaseCanvasFactory {
|
|
|
1402
1544
|
}
|
|
1403
1545
|
};
|
|
1404
1546
|
|
|
1547
|
+
// src/lib/NodeUtils.ts
|
|
1548
|
+
if (!globalThis.DOMMatrix) {
|
|
1549
|
+
globalThis.DOMMatrix = NodeDOMMatrix;
|
|
1550
|
+
}
|
|
1551
|
+
if (!globalThis.DOMPoint) {
|
|
1552
|
+
globalThis.DOMPoint = NodeDOMPoint;
|
|
1553
|
+
}
|
|
1554
|
+
if (!globalThis.ImageData) {
|
|
1555
|
+
globalThis.ImageData = NodeImageData;
|
|
1556
|
+
}
|
|
1557
|
+
if (!globalThis.Path2D) {
|
|
1558
|
+
globalThis.Path2D = NodePath2D;
|
|
1559
|
+
}
|
|
1560
|
+
if (!globalThis.navigator?.language) {
|
|
1561
|
+
globalThis.navigator = {
|
|
1562
|
+
language: "en-US",
|
|
1563
|
+
platform: "",
|
|
1564
|
+
userAgent: ""
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1567
|
+
async function fetchData2(url) {
|
|
1568
|
+
const { readFile } = await import("node:fs/promises");
|
|
1569
|
+
const data = await readFile(url);
|
|
1570
|
+
return new Uint8Array(data);
|
|
1571
|
+
}
|
|
1572
|
+
var NodeCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
1573
|
+
/**
|
|
1574
|
+
* @ignore
|
|
1575
|
+
*/
|
|
1576
|
+
async _fetch(url) {
|
|
1577
|
+
return fetchData2(url);
|
|
1578
|
+
}
|
|
1579
|
+
};
|
|
1580
|
+
var NodeStandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
1581
|
+
/**
|
|
1582
|
+
* @ignore
|
|
1583
|
+
*/
|
|
1584
|
+
async _fetch(url) {
|
|
1585
|
+
return fetchData2(url);
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
var NodeWasmFactory = class extends BaseWasmFactory {
|
|
1589
|
+
/**
|
|
1590
|
+
* @ignore
|
|
1591
|
+
*/
|
|
1592
|
+
async _fetch(url) {
|
|
1593
|
+
return fetchData2(url);
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
|
|
1405
1597
|
export {
|
|
1406
1598
|
SVG_NS,
|
|
1407
1599
|
PixelsPerInch,
|
|
@@ -1426,6 +1618,10 @@ export {
|
|
|
1426
1618
|
setLayerDimensions,
|
|
1427
1619
|
OutputScale,
|
|
1428
1620
|
SupportedImageMimeTypes,
|
|
1621
|
+
DOMCMapReaderFactory,
|
|
1622
|
+
BaseStandardFontDataFactory,
|
|
1623
|
+
DOMStandardFontDataFactory,
|
|
1624
|
+
DOMWasmFactory,
|
|
1429
1625
|
DOMCanvasFactory,
|
|
1430
1626
|
DOMFilterFactory,
|
|
1431
1627
|
canvasToData,
|
|
@@ -1434,6 +1630,11 @@ export {
|
|
|
1434
1630
|
colorToRgb,
|
|
1435
1631
|
rgbToHex,
|
|
1436
1632
|
parseRgbaColor,
|
|
1633
|
+
filtersRegistry,
|
|
1437
1634
|
NodeFilterFactory,
|
|
1438
|
-
NodeCanvasFactory
|
|
1635
|
+
NodeCanvasFactory,
|
|
1636
|
+
fetchData2,
|
|
1637
|
+
NodeCMapReaderFactory,
|
|
1638
|
+
NodeStandardFontDataFactory,
|
|
1639
|
+
NodeWasmFactory
|
|
1439
1640
|
};
|
package/dist/node/index.js
CHANGED
|
@@ -6,10 +6,17 @@ import {
|
|
|
6
6
|
wrapReason
|
|
7
7
|
} from "./chunk-ZKUTXCS2.js";
|
|
8
8
|
import {
|
|
9
|
+
BaseStandardFontDataFactory,
|
|
10
|
+
DOMCMapReaderFactory,
|
|
9
11
|
DOMCanvasFactory,
|
|
10
12
|
DOMFilterFactory,
|
|
13
|
+
DOMStandardFontDataFactory,
|
|
14
|
+
DOMWasmFactory,
|
|
15
|
+
NodeCMapReaderFactory,
|
|
11
16
|
NodeCanvasFactory,
|
|
12
17
|
NodeFilterFactory,
|
|
18
|
+
NodeStandardFontDataFactory,
|
|
19
|
+
NodeWasmFactory,
|
|
13
20
|
OutputScale,
|
|
14
21
|
PDFDateString,
|
|
15
22
|
PageViewport,
|
|
@@ -39,7 +46,7 @@ import {
|
|
|
39
46
|
setLayerDimensions,
|
|
40
47
|
stopEvent,
|
|
41
48
|
toDataUrl
|
|
42
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-K6VD27AD.js";
|
|
43
50
|
import {
|
|
44
51
|
AbortException,
|
|
45
52
|
AnnotationBorderStyleType,
|
|
@@ -5799,197 +5806,6 @@ var LoopbackPort = class {
|
|
|
5799
5806
|
_listeners = new WeakMap();
|
|
5800
5807
|
_deferred = new WeakMap();
|
|
5801
5808
|
|
|
5802
|
-
// src/lib/NodeUtils.ts
|
|
5803
|
-
import {
|
|
5804
|
-
DOMMatrix as NodeDOMMatrix,
|
|
5805
|
-
DOMPoint as NodeDOMPoint,
|
|
5806
|
-
ImageData as NodeImageData,
|
|
5807
|
-
Path2D as NodePath2D
|
|
5808
|
-
} from "skia-canvas";
|
|
5809
|
-
|
|
5810
|
-
// src/pdf.js/src/display/cmap_reader_factory.js
|
|
5811
|
-
var BaseCMapReaderFactory = class {
|
|
5812
|
-
constructor({ baseUrl = null, isCompressed = true }) {
|
|
5813
|
-
if (false) {
|
|
5814
|
-
unreachable("Cannot initialize BaseCMapReaderFactory.");
|
|
5815
|
-
}
|
|
5816
|
-
this.baseUrl = baseUrl;
|
|
5817
|
-
this.isCompressed = isCompressed;
|
|
5818
|
-
}
|
|
5819
|
-
async fetch({ name }) {
|
|
5820
|
-
if (!this.baseUrl) {
|
|
5821
|
-
throw new Error(
|
|
5822
|
-
"Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided."
|
|
5823
|
-
);
|
|
5824
|
-
}
|
|
5825
|
-
if (!name) {
|
|
5826
|
-
throw new Error("CMap name must be specified.");
|
|
5827
|
-
}
|
|
5828
|
-
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
|
5829
|
-
return this._fetch(url).then((cMapData) => ({ cMapData, isCompressed: this.isCompressed })).catch((reason) => {
|
|
5830
|
-
throw new Error(
|
|
5831
|
-
`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`
|
|
5832
|
-
);
|
|
5833
|
-
});
|
|
5834
|
-
}
|
|
5835
|
-
/**
|
|
5836
|
-
* @ignore
|
|
5837
|
-
* @returns {Promise<Uint8Array>}
|
|
5838
|
-
*/
|
|
5839
|
-
async _fetch(url) {
|
|
5840
|
-
unreachable("Abstract method `_fetch` called.");
|
|
5841
|
-
}
|
|
5842
|
-
};
|
|
5843
|
-
var DOMCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
5844
|
-
/**
|
|
5845
|
-
* @ignore
|
|
5846
|
-
*/
|
|
5847
|
-
async _fetch(url) {
|
|
5848
|
-
const data = await fetchData(
|
|
5849
|
-
url,
|
|
5850
|
-
/* type = */
|
|
5851
|
-
this.isCompressed ? "arraybuffer" : "text"
|
|
5852
|
-
);
|
|
5853
|
-
return data instanceof ArrayBuffer ? new Uint8Array(data) : stringToBytes(data);
|
|
5854
|
-
}
|
|
5855
|
-
};
|
|
5856
|
-
|
|
5857
|
-
// src/pdf.js/src/display/standard_fontdata_factory.js
|
|
5858
|
-
var BaseStandardFontDataFactory = class {
|
|
5859
|
-
constructor({ baseUrl = null }) {
|
|
5860
|
-
if (false) {
|
|
5861
|
-
unreachable("Cannot initialize BaseStandardFontDataFactory.");
|
|
5862
|
-
}
|
|
5863
|
-
this.baseUrl = baseUrl;
|
|
5864
|
-
}
|
|
5865
|
-
async fetch({ filename }) {
|
|
5866
|
-
if (!this.baseUrl) {
|
|
5867
|
-
throw new Error(
|
|
5868
|
-
"Ensure that the `standardFontDataUrl` API parameter is provided."
|
|
5869
|
-
);
|
|
5870
|
-
}
|
|
5871
|
-
if (!filename) {
|
|
5872
|
-
throw new Error("Font filename must be specified.");
|
|
5873
|
-
}
|
|
5874
|
-
const url = `${this.baseUrl}${filename}`;
|
|
5875
|
-
return this._fetch(url).catch((reason) => {
|
|
5876
|
-
throw new Error(`Unable to load font data at: ${url}`);
|
|
5877
|
-
});
|
|
5878
|
-
}
|
|
5879
|
-
/**
|
|
5880
|
-
* @ignore
|
|
5881
|
-
* @returns {Promise<Uint8Array>}
|
|
5882
|
-
*/
|
|
5883
|
-
async _fetch(url) {
|
|
5884
|
-
unreachable("Abstract method `_fetch` called.");
|
|
5885
|
-
}
|
|
5886
|
-
};
|
|
5887
|
-
var DOMStandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
5888
|
-
/**
|
|
5889
|
-
* @ignore
|
|
5890
|
-
*/
|
|
5891
|
-
async _fetch(url) {
|
|
5892
|
-
const data = await fetchData(
|
|
5893
|
-
url,
|
|
5894
|
-
/* type = */
|
|
5895
|
-
"arraybuffer"
|
|
5896
|
-
);
|
|
5897
|
-
return new Uint8Array(data);
|
|
5898
|
-
}
|
|
5899
|
-
};
|
|
5900
|
-
|
|
5901
|
-
// src/pdf.js/src/display/wasm_factory.js
|
|
5902
|
-
var BaseWasmFactory = class {
|
|
5903
|
-
constructor({ baseUrl = null }) {
|
|
5904
|
-
if (false) {
|
|
5905
|
-
unreachable("Cannot initialize BaseWasmFactory.");
|
|
5906
|
-
}
|
|
5907
|
-
this.baseUrl = baseUrl;
|
|
5908
|
-
}
|
|
5909
|
-
async fetch({ filename }) {
|
|
5910
|
-
if (!this.baseUrl) {
|
|
5911
|
-
throw new Error("Ensure that the `wasmUrl` API parameter is provided.");
|
|
5912
|
-
}
|
|
5913
|
-
if (!filename) {
|
|
5914
|
-
throw new Error("Wasm filename must be specified.");
|
|
5915
|
-
}
|
|
5916
|
-
const url = `${this.baseUrl}${filename}`;
|
|
5917
|
-
return this._fetch(url).catch((reason) => {
|
|
5918
|
-
throw new Error(`Unable to load wasm data at: ${url}`);
|
|
5919
|
-
});
|
|
5920
|
-
}
|
|
5921
|
-
/**
|
|
5922
|
-
* @ignore
|
|
5923
|
-
* @returns {Promise<Uint8Array>}
|
|
5924
|
-
*/
|
|
5925
|
-
async _fetch(url) {
|
|
5926
|
-
unreachable("Abstract method `_fetch` called.");
|
|
5927
|
-
}
|
|
5928
|
-
};
|
|
5929
|
-
var DOMWasmFactory = class extends BaseWasmFactory {
|
|
5930
|
-
/**
|
|
5931
|
-
* @ignore
|
|
5932
|
-
*/
|
|
5933
|
-
async _fetch(url) {
|
|
5934
|
-
const data = await fetchData(
|
|
5935
|
-
url,
|
|
5936
|
-
/* type = */
|
|
5937
|
-
"arraybuffer"
|
|
5938
|
-
);
|
|
5939
|
-
return new Uint8Array(data);
|
|
5940
|
-
}
|
|
5941
|
-
};
|
|
5942
|
-
|
|
5943
|
-
// src/lib/NodeUtils.ts
|
|
5944
|
-
if (!globalThis.DOMMatrix) {
|
|
5945
|
-
globalThis.DOMMatrix = NodeDOMMatrix;
|
|
5946
|
-
}
|
|
5947
|
-
if (!globalThis.DOMPoint) {
|
|
5948
|
-
globalThis.DOMPoint = NodeDOMPoint;
|
|
5949
|
-
}
|
|
5950
|
-
if (!globalThis.ImageData) {
|
|
5951
|
-
globalThis.ImageData = NodeImageData;
|
|
5952
|
-
}
|
|
5953
|
-
if (!globalThis.Path2D) {
|
|
5954
|
-
globalThis.Path2D = NodePath2D;
|
|
5955
|
-
}
|
|
5956
|
-
if (!globalThis.navigator?.language) {
|
|
5957
|
-
globalThis.navigator = {
|
|
5958
|
-
language: "en-US",
|
|
5959
|
-
platform: "",
|
|
5960
|
-
userAgent: ""
|
|
5961
|
-
};
|
|
5962
|
-
}
|
|
5963
|
-
async function fetchData2(url) {
|
|
5964
|
-
const { readFile } = await import("node:fs/promises");
|
|
5965
|
-
const data = await readFile(url);
|
|
5966
|
-
return new Uint8Array(data);
|
|
5967
|
-
}
|
|
5968
|
-
var NodeCMapReaderFactory = class extends BaseCMapReaderFactory {
|
|
5969
|
-
/**
|
|
5970
|
-
* @ignore
|
|
5971
|
-
*/
|
|
5972
|
-
async _fetch(url) {
|
|
5973
|
-
return fetchData2(url);
|
|
5974
|
-
}
|
|
5975
|
-
};
|
|
5976
|
-
var NodeStandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
5977
|
-
/**
|
|
5978
|
-
* @ignore
|
|
5979
|
-
*/
|
|
5980
|
-
async _fetch(url) {
|
|
5981
|
-
return fetchData2(url);
|
|
5982
|
-
}
|
|
5983
|
-
};
|
|
5984
|
-
var NodeWasmFactory = class extends BaseWasmFactory {
|
|
5985
|
-
/**
|
|
5986
|
-
* @ignore
|
|
5987
|
-
*/
|
|
5988
|
-
async _fetch(url) {
|
|
5989
|
-
return fetchData2(url);
|
|
5990
|
-
}
|
|
5991
|
-
};
|
|
5992
|
-
|
|
5993
5809
|
// src/pdf.js/src/display/pattern_helper.js
|
|
5994
5810
|
var PathType = {
|
|
5995
5811
|
FILL: "Fill",
|
|
@@ -25251,7 +25067,7 @@ async function toSvgString(ctx) {
|
|
|
25251
25067
|
|
|
25252
25068
|
// src/lib/PDFPageProxy.ts
|
|
25253
25069
|
async function loadNodeCanvasFactory() {
|
|
25254
|
-
const { NodeCanvasFactory: NodeCanvasFactory2 } = await import("./
|
|
25070
|
+
const { NodeCanvasFactory: NodeCanvasFactory2 } = await import("./NodeUtils-EDBNTTIR.js");
|
|
25255
25071
|
return new NodeCanvasFactory2({});
|
|
25256
25072
|
}
|
|
25257
25073
|
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|