@chialab/pdfjs-lib 1.0.0-alpha.2 → 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/README.md +15 -7
- package/dist/browser/NodeUtilsStabs-MUAXKISB.js +19 -0
- package/dist/browser/chunk-3ZTAZS2X.js +25 -0
- package/dist/browser/{chunk-DYHYQ33L.js → chunk-W3YEFTNG.js} +289 -75
- package/dist/browser/index.js +2788 -2149
- package/dist/browser/openjpeg-K2XBCFFN.js +9 -0
- package/dist/browser/qcms_bg-Q7BRLLZG.js +9 -0
- package/dist/browser/worker.js +7298 -6450
- package/dist/index.d.ts +3 -0
- package/dist/lib/AnnotationData.d.ts +8 -8
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/CanvasGraphics.d.ts +1 -0
- package/dist/lib/NodeCanvasFactory.d.ts +9 -0
- package/dist/lib/NodeFilterFactory.d.ts +10 -0
- package/dist/lib/NodeUtils.d.ts +24 -0
- package/dist/lib/Path2D.d.ts +1 -1
- package/dist/lib/StandardFontDataFactory.d.ts +2 -2
- package/dist/lib/Svg.d.ts +143 -0
- package/dist/lib/SvgCanvasContext.d.ts +31 -22
- package/dist/lib/TextLayer.d.ts +12 -5
- package/dist/lib/WasmFactory.d.ts +5 -0
- package/dist/lib/utils.d.ts +29 -3
- package/dist/node/NodeUtils-EDBNTTIR.js +20 -0
- package/dist/node/chunk-K6VD27AD.js +1640 -0
- package/dist/node/chunk-XMKSLA4K.js +1207 -0
- package/dist/node/chunk-ZKUTXCS2.js +801 -0
- package/dist/node/index.js +2586 -3213
- package/dist/node/openjpeg-B2WN24QZ.js +9 -0
- package/dist/node/qcms_bg-T4RSHPOQ.js +9 -0
- package/dist/node/worker.js +7307 -6457
- package/dist/pdf.js/src/display/annotation_layer.d.ts +1 -2
- package/dist/pdf.js/src/display/annotation_storage.d.ts +1 -8
- package/dist/pdf.js/src/display/api.d.ts +37 -71
- package/dist/pdf.js/src/display/api_utils.d.ts +13 -0
- package/dist/pdf.js/src/display/canvas.d.ts +21 -29
- package/dist/pdf.js/src/display/display_utils.d.ts +12 -1
- package/dist/pdf.js/src/display/draw_layer.d.ts +2 -2
- package/dist/pdf.js/src/display/editor/alt_text.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/annotation_editor_layer.d.ts +5 -5
- package/dist/pdf.js/src/display/editor/color_picker.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/draw.d.ts +7 -7
- package/dist/pdf.js/src/display/editor/drawers/freedraw.d.ts +3 -3
- package/dist/pdf.js/src/display/editor/drawers/signaturedraw.d.ts +13 -13
- package/dist/pdf.js/src/display/editor/editor.d.ts +30 -6
- package/dist/pdf.js/src/display/editor/freetext.d.ts +4 -7
- package/dist/pdf.js/src/display/editor/highlight.d.ts +6 -3
- package/dist/pdf.js/src/display/editor/ink.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +3 -0
- package/dist/pdf.js/src/display/editor/stamp.d.ts +4 -3
- package/dist/pdf.js/src/display/editor/toolbar.d.ts +4 -2
- package/dist/pdf.js/src/display/editor/tools.d.ts +7 -9
- package/dist/pdf.js/src/display/metadata.d.ts +1 -2
- package/dist/pdf.js/src/display/optional_content_config.d.ts +1 -1
- package/dist/pdf.js/src/display/pattern_helper.d.ts +4 -2
- package/dist/pdf.js/src/display/pdf_objects.d.ts +40 -0
- package/dist/pdf.js/src/display/text_layer.d.ts +9 -9
- package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
- package/dist/pdf.js/src/display/worker_options.d.ts +2 -2
- package/dist/pdf.js/src/pdf.d.ts +4 -1
- package/dist/pdf.js/src/shared/scripting_utils.d.ts +2 -0
- package/dist/pdf.js/src/shared/util.d.ts +123 -100
- package/dist/pdf.js/web/text_accessibility.d.ts +1 -1
- package/package.json +7 -4
- package/dist/node/chunk-KTTVPO2G.js +0 -1775
- package/dist/pdf.js/src/display/node_utils.d.ts +0 -32
package/README.md
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
## Features
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
- Browser and Node (and Bun) optimized builds using ES modules
|
|
11
|
+
- Bundler-friendly
|
|
12
|
+
- Polyfills included
|
|
13
|
+
- Extended annotation models support
|
|
14
|
+
- SVG renderer for PDF pages
|
|
15
|
+
- Improved TextLayer extraction with structure information
|
|
16
16
|
|
|
17
17
|
## Install
|
|
18
18
|
|
|
@@ -26,4 +26,12 @@ yarn add @chialab/pdfjs-lib
|
|
|
26
26
|
|
|
27
27
|
```
|
|
28
28
|
pnpm add @chialab/pdfjs-lib
|
|
29
|
-
```
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Before building
|
|
32
|
+
|
|
33
|
+
Before building the library:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
git submodule init && git submodule update
|
|
37
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NodeCMapReaderFactory,
|
|
3
|
+
NodeCanvasFactory,
|
|
4
|
+
NodeFileReaderFactory,
|
|
5
|
+
NodeFilterFactory,
|
|
6
|
+
NodeSVGFactory,
|
|
7
|
+
NodeStandardFontDataFactory,
|
|
8
|
+
NodeWasmFactory
|
|
9
|
+
} from "./chunk-3ZTAZS2X.js";
|
|
10
|
+
import "./chunk-O4UKW7AD.js";
|
|
11
|
+
export {
|
|
12
|
+
NodeCMapReaderFactory,
|
|
13
|
+
NodeCanvasFactory,
|
|
14
|
+
NodeFileReaderFactory,
|
|
15
|
+
NodeFilterFactory,
|
|
16
|
+
NodeSVGFactory,
|
|
17
|
+
NodeStandardFontDataFactory,
|
|
18
|
+
NodeWasmFactory
|
|
19
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/lib/NodeUtilsStabs.ts
|
|
2
|
+
var NodeCanvasFactory = class {
|
|
3
|
+
};
|
|
4
|
+
var NodeCMapReaderFactory = class {
|
|
5
|
+
};
|
|
6
|
+
var NodeFileReaderFactory = class {
|
|
7
|
+
};
|
|
8
|
+
var NodeStandardFontDataFactory = class {
|
|
9
|
+
};
|
|
10
|
+
var NodeSVGFactory = class {
|
|
11
|
+
};
|
|
12
|
+
var NodeFilterFactory = class {
|
|
13
|
+
};
|
|
14
|
+
var NodeWasmFactory = class {
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
NodeCanvasFactory,
|
|
19
|
+
NodeCMapReaderFactory,
|
|
20
|
+
NodeFileReaderFactory,
|
|
21
|
+
NodeStandardFontDataFactory,
|
|
22
|
+
NodeSVGFactory,
|
|
23
|
+
NodeFilterFactory,
|
|
24
|
+
NodeWasmFactory
|
|
25
|
+
};
|
|
@@ -48,7 +48,6 @@ if (!("try" in Promise)) {
|
|
|
48
48
|
|
|
49
49
|
// src/pdf.js/src/shared/util.js
|
|
50
50
|
var isNodeJS = typeof process === "object" && process + "" === "[object process]" && !process.versions.nw && !(process.versions.electron && process.type && process.type !== "browser");
|
|
51
|
-
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
|
52
51
|
var FONT_IDENTITY_MATRIX = [1e-3, 0, 0, 1e-3, 0, 0];
|
|
53
52
|
var LINE_FACTOR = 1.35;
|
|
54
53
|
var LINE_DESCENT_FACTOR = 0.35;
|
|
@@ -324,7 +323,14 @@ var OPS = {
|
|
|
324
323
|
paintSolidColorImageMask: 90,
|
|
325
324
|
constructPath: 91,
|
|
326
325
|
setStrokeTransparent: 92,
|
|
327
|
-
setFillTransparent: 93
|
|
326
|
+
setFillTransparent: 93,
|
|
327
|
+
rawFillPath: 94
|
|
328
|
+
};
|
|
329
|
+
var DrawOPS = {
|
|
330
|
+
moveTo: 0,
|
|
331
|
+
lineTo: 1,
|
|
332
|
+
curveTo: 2,
|
|
333
|
+
closePath: 3
|
|
328
334
|
};
|
|
329
335
|
var PasswordResponses = {
|
|
330
336
|
NEED_PASSWORD: 1,
|
|
@@ -390,6 +396,17 @@ function createValidAbsoluteUrl(url, baseUrl = null, options = null) {
|
|
|
390
396
|
const absoluteUrl = baseUrl ? URL.parse(url, baseUrl) : URL.parse(url);
|
|
391
397
|
return _isValidProtocol(absoluteUrl) ? absoluteUrl : null;
|
|
392
398
|
}
|
|
399
|
+
function updateUrlHash(url, hash, allowRel = false) {
|
|
400
|
+
const res = URL.parse(url);
|
|
401
|
+
if (res) {
|
|
402
|
+
res.hash = hash;
|
|
403
|
+
return res.href;
|
|
404
|
+
}
|
|
405
|
+
if (allowRel && createValidAbsoluteUrl(url, "http://example.com")) {
|
|
406
|
+
return url.split("#", 1)[0] + `${hash ? `#${hash}` : ""}`;
|
|
407
|
+
}
|
|
408
|
+
return "";
|
|
409
|
+
}
|
|
393
410
|
function shadow(obj, prop, value, nonSerializable = false) {
|
|
394
411
|
if (false) {
|
|
395
412
|
assert(
|
|
@@ -405,7 +422,7 @@ function shadow(obj, prop, value, nonSerializable = false) {
|
|
|
405
422
|
});
|
|
406
423
|
return value;
|
|
407
424
|
}
|
|
408
|
-
var BaseException = function BaseExceptionClosure() {
|
|
425
|
+
var BaseException = (function BaseExceptionClosure() {
|
|
409
426
|
function BaseException2(message, name) {
|
|
410
427
|
if (false) {
|
|
411
428
|
unreachable("Cannot initialize BaseException.");
|
|
@@ -416,7 +433,7 @@ var BaseException = function BaseExceptionClosure() {
|
|
|
416
433
|
BaseException2.prototype = new Error();
|
|
417
434
|
BaseException2.constructor = BaseException2;
|
|
418
435
|
return BaseException2;
|
|
419
|
-
}();
|
|
436
|
+
})();
|
|
420
437
|
var PasswordException = class extends BaseException {
|
|
421
438
|
constructor(msg, code) {
|
|
422
439
|
super(msg, "PasswordException");
|
|
@@ -496,13 +513,6 @@ function string32(value) {
|
|
|
496
513
|
function objectSize(obj) {
|
|
497
514
|
return Object.keys(obj).length;
|
|
498
515
|
}
|
|
499
|
-
function objectFromMap(map) {
|
|
500
|
-
const obj = /* @__PURE__ */ Object.create(null);
|
|
501
|
-
for (const [key, value] of map) {
|
|
502
|
-
obj[key] = value;
|
|
503
|
-
}
|
|
504
|
-
return obj;
|
|
505
|
-
}
|
|
506
516
|
function isLittleEndian() {
|
|
507
517
|
const buffer8 = new Uint8Array(4);
|
|
508
518
|
buffer8[0] = 1;
|
|
@@ -539,22 +549,13 @@ var FeatureTest = class {
|
|
|
539
549
|
);
|
|
540
550
|
}
|
|
541
551
|
static get platform() {
|
|
542
|
-
|
|
543
|
-
const { platform, userAgent } = navigator;
|
|
544
|
-
return shadow(this, "platform", {
|
|
545
|
-
isAndroid: userAgent.includes("Android"),
|
|
546
|
-
isLinux: platform.includes("Linux"),
|
|
547
|
-
isMac: platform.includes("Mac"),
|
|
548
|
-
isWindows: platform.includes("Win"),
|
|
549
|
-
isFirefox: userAgent.includes("Firefox")
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
+
const { platform, userAgent } = navigator;
|
|
552
553
|
return shadow(this, "platform", {
|
|
553
|
-
isAndroid:
|
|
554
|
-
isLinux:
|
|
555
|
-
isMac:
|
|
556
|
-
isWindows:
|
|
557
|
-
isFirefox:
|
|
554
|
+
isAndroid: userAgent.includes("Android"),
|
|
555
|
+
isLinux: platform.includes("Linux"),
|
|
556
|
+
isMac: platform.includes("Mac"),
|
|
557
|
+
isWindows: platform.includes("Win"),
|
|
558
|
+
isFirefox: userAgent.includes("Firefox")
|
|
558
559
|
});
|
|
559
560
|
}
|
|
560
561
|
static get isCSSRoundSupported() {
|
|
@@ -633,30 +634,72 @@ var Util = class {
|
|
|
633
634
|
];
|
|
634
635
|
}
|
|
635
636
|
// For 2d affine transforms
|
|
636
|
-
static applyTransform(p, m) {
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
|
|
637
|
+
static applyTransform(p, m, pos = 0) {
|
|
638
|
+
const p0 = p[pos];
|
|
639
|
+
const p1 = p[pos + 1];
|
|
640
|
+
p[pos] = p0 * m[0] + p1 * m[2] + m[4];
|
|
641
|
+
p[pos + 1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
642
|
+
}
|
|
643
|
+
static applyTransformToBezier(p, transform, pos = 0) {
|
|
644
|
+
const m0 = transform[0];
|
|
645
|
+
const m1 = transform[1];
|
|
646
|
+
const m2 = transform[2];
|
|
647
|
+
const m3 = transform[3];
|
|
648
|
+
const m4 = transform[4];
|
|
649
|
+
const m5 = transform[5];
|
|
650
|
+
for (let i = 0; i < 6; i += 2) {
|
|
651
|
+
const pI = p[pos + i];
|
|
652
|
+
const pI1 = p[pos + i + 1];
|
|
653
|
+
p[pos + i] = pI * m0 + pI1 * m2 + m4;
|
|
654
|
+
p[pos + i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
655
|
+
}
|
|
640
656
|
}
|
|
641
657
|
static applyInverseTransform(p, m) {
|
|
658
|
+
const p0 = p[0];
|
|
659
|
+
const p1 = p[1];
|
|
642
660
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
return [xt, yt];
|
|
661
|
+
p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
|
|
662
|
+
p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
|
|
646
663
|
}
|
|
647
664
|
// Applies the transform to the rectangle and finds the minimum axially
|
|
648
665
|
// aligned bounding box.
|
|
649
|
-
static
|
|
650
|
-
const
|
|
651
|
-
const
|
|
652
|
-
const
|
|
653
|
-
const
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
];
|
|
666
|
+
static axialAlignedBoundingBox(rect, transform, output) {
|
|
667
|
+
const m0 = transform[0];
|
|
668
|
+
const m1 = transform[1];
|
|
669
|
+
const m2 = transform[2];
|
|
670
|
+
const m3 = transform[3];
|
|
671
|
+
const m4 = transform[4];
|
|
672
|
+
const m5 = transform[5];
|
|
673
|
+
const r0 = rect[0];
|
|
674
|
+
const r1 = rect[1];
|
|
675
|
+
const r2 = rect[2];
|
|
676
|
+
const r3 = rect[3];
|
|
677
|
+
let a0 = m0 * r0 + m4;
|
|
678
|
+
let a2 = a0;
|
|
679
|
+
let a1 = m0 * r2 + m4;
|
|
680
|
+
let a3 = a1;
|
|
681
|
+
let b0 = m3 * r1 + m5;
|
|
682
|
+
let b2 = b0;
|
|
683
|
+
let b1 = m3 * r3 + m5;
|
|
684
|
+
let b3 = b1;
|
|
685
|
+
if (m1 !== 0 || m2 !== 0) {
|
|
686
|
+
const m1r0 = m1 * r0;
|
|
687
|
+
const m1r2 = m1 * r2;
|
|
688
|
+
const m2r1 = m2 * r1;
|
|
689
|
+
const m2r3 = m2 * r3;
|
|
690
|
+
a0 += m2r1;
|
|
691
|
+
a3 += m2r1;
|
|
692
|
+
a1 += m2r3;
|
|
693
|
+
a2 += m2r3;
|
|
694
|
+
b0 += m1r0;
|
|
695
|
+
b3 += m1r0;
|
|
696
|
+
b1 += m1r2;
|
|
697
|
+
b2 += m1r2;
|
|
698
|
+
}
|
|
699
|
+
output[0] = Math.min(output[0], a0, a1, a2, a3);
|
|
700
|
+
output[1] = Math.min(output[1], b0, b1, b2, b3);
|
|
701
|
+
output[2] = Math.max(output[2], a0, a1, a2, a3);
|
|
702
|
+
output[3] = Math.max(output[3], b0, b1, b2, b3);
|
|
660
703
|
}
|
|
661
704
|
static inverseTransform(m) {
|
|
662
705
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
@@ -672,17 +715,18 @@ var Util = class {
|
|
|
672
715
|
// This calculation uses Singular Value Decomposition.
|
|
673
716
|
// The SVD can be represented with formula A = USV. We are interested in the
|
|
674
717
|
// matrix S here because it represents the scale values.
|
|
675
|
-
static singularValueDecompose2dScale(
|
|
676
|
-
const
|
|
677
|
-
const
|
|
678
|
-
const
|
|
679
|
-
const
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
const
|
|
683
|
-
const
|
|
684
|
-
const
|
|
685
|
-
|
|
718
|
+
static singularValueDecompose2dScale(matrix, output) {
|
|
719
|
+
const m0 = matrix[0];
|
|
720
|
+
const m1 = matrix[1];
|
|
721
|
+
const m2 = matrix[2];
|
|
722
|
+
const m3 = matrix[3];
|
|
723
|
+
const a = m0 ** 2 + m1 ** 2;
|
|
724
|
+
const b = m0 * m2 + m1 * m3;
|
|
725
|
+
const c = m2 ** 2 + m3 ** 2;
|
|
726
|
+
const first = (a + c) / 2;
|
|
727
|
+
const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
|
|
728
|
+
output[0] = Math.sqrt(first + second || 1);
|
|
729
|
+
output[1] = Math.sqrt(first - second || 1);
|
|
686
730
|
}
|
|
687
731
|
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
|
688
732
|
// For coordinate systems whose origin lies in the bottom-left, this
|
|
@@ -728,24 +772,26 @@ var Util = class {
|
|
|
728
772
|
}
|
|
729
773
|
return [xLow, yLow, xHigh, yHigh];
|
|
730
774
|
}
|
|
775
|
+
static pointBoundingBox(x, y, minMax) {
|
|
776
|
+
minMax[0] = Math.min(minMax[0], x);
|
|
777
|
+
minMax[1] = Math.min(minMax[1], y);
|
|
778
|
+
minMax[2] = Math.max(minMax[2], x);
|
|
779
|
+
minMax[3] = Math.max(minMax[3], y);
|
|
780
|
+
}
|
|
781
|
+
static rectBoundingBox(x0, y0, x1, y1, minMax) {
|
|
782
|
+
minMax[0] = Math.min(minMax[0], x0, x1);
|
|
783
|
+
minMax[1] = Math.min(minMax[1], y0, y1);
|
|
784
|
+
minMax[2] = Math.max(minMax[2], x0, x1);
|
|
785
|
+
minMax[3] = Math.max(minMax[3], y0, y1);
|
|
786
|
+
}
|
|
731
787
|
// From https://github.com/adobe-webplatform/Snap.svg/blob/b365287722a72526000ac4bfcf0ce4cac2faa015/src/path.js#L852
|
|
732
788
|
static bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
minMax[3] = Math.max(minMax[3], y0, y3);
|
|
738
|
-
} else {
|
|
739
|
-
minMax = [
|
|
740
|
-
Math.min(x0, x3),
|
|
741
|
-
Math.min(y0, y3),
|
|
742
|
-
Math.max(x0, x3),
|
|
743
|
-
Math.max(y0, y3)
|
|
744
|
-
];
|
|
745
|
-
}
|
|
789
|
+
minMax[0] = Math.min(minMax[0], x0, x3);
|
|
790
|
+
minMax[1] = Math.min(minMax[1], y0, y3);
|
|
791
|
+
minMax[2] = Math.max(minMax[2], x0, x3);
|
|
792
|
+
minMax[3] = Math.max(minMax[3], y0, y3);
|
|
746
793
|
__privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-x0 + 3 * (x1 - x2) + x3), 6 * (x0 - 2 * x1 + x2), 3 * (x1 - x0), minMax);
|
|
747
794
|
__privateMethod(this, _Util_static, getExtremum_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, 3 * (-y0 + 3 * (y1 - y2) + y3), 6 * (y0 - 2 * y1 + y2), 3 * (y1 - y0), minMax);
|
|
748
|
-
return minMax;
|
|
749
795
|
}
|
|
750
796
|
};
|
|
751
797
|
_Util_static = new WeakSet();
|
|
@@ -943,7 +989,7 @@ var PDFStringTranslateTable = [
|
|
|
943
989
|
0,
|
|
944
990
|
8364
|
|
945
991
|
];
|
|
946
|
-
function stringToPDFString(str) {
|
|
992
|
+
function stringToPDFString(str, keepEscapeSequence = false) {
|
|
947
993
|
if (str[0] >= "\xEF") {
|
|
948
994
|
let encoding;
|
|
949
995
|
if (str[0] === "\xFE" && str[1] === "\xFF") {
|
|
@@ -964,7 +1010,7 @@ function stringToPDFString(str) {
|
|
|
964
1010
|
const decoder = new TextDecoder(encoding, { fatal: true });
|
|
965
1011
|
const buffer = stringToBytes(str);
|
|
966
1012
|
const decoded = decoder.decode(buffer);
|
|
967
|
-
if (!decoded.includes("\x1B")) {
|
|
1013
|
+
if (keepEscapeSequence || !decoded.includes("\x1B")) {
|
|
968
1014
|
return decoded;
|
|
969
1015
|
}
|
|
970
1016
|
return decoded.replaceAll(/\x1b[^\x1b]*(?:\x1b|$)/g, "");
|
|
@@ -976,7 +1022,7 @@ function stringToPDFString(str) {
|
|
|
976
1022
|
const strBuf = [];
|
|
977
1023
|
for (let i = 0, ii = str.length; i < ii; i++) {
|
|
978
1024
|
const charCode = str.charCodeAt(i);
|
|
979
|
-
if (charCode === 27) {
|
|
1025
|
+
if (!keepEscapeSequence && charCode === 27) {
|
|
980
1026
|
while (++i < ii && str.charCodeAt(i) !== 27) {
|
|
981
1027
|
}
|
|
982
1028
|
continue;
|
|
@@ -1035,6 +1081,56 @@ function getUuid() {
|
|
|
1035
1081
|
return bytesToString(buf);
|
|
1036
1082
|
}
|
|
1037
1083
|
var AnnotationPrefix = "pdfjs_internal_id_";
|
|
1084
|
+
function _isValidExplicitDest(validRef, validName, dest) {
|
|
1085
|
+
if (!Array.isArray(dest) || dest.length < 2) {
|
|
1086
|
+
return false;
|
|
1087
|
+
}
|
|
1088
|
+
const [page, zoom, ...args] = dest;
|
|
1089
|
+
if (!validRef(page) && !Number.isInteger(page)) {
|
|
1090
|
+
return false;
|
|
1091
|
+
}
|
|
1092
|
+
if (!validName(zoom)) {
|
|
1093
|
+
return false;
|
|
1094
|
+
}
|
|
1095
|
+
const argsLen = args.length;
|
|
1096
|
+
let allowNull = true;
|
|
1097
|
+
switch (zoom.name) {
|
|
1098
|
+
case "XYZ":
|
|
1099
|
+
if (argsLen < 2 || argsLen > 3) {
|
|
1100
|
+
return false;
|
|
1101
|
+
}
|
|
1102
|
+
break;
|
|
1103
|
+
case "Fit":
|
|
1104
|
+
case "FitB":
|
|
1105
|
+
return argsLen === 0;
|
|
1106
|
+
case "FitH":
|
|
1107
|
+
case "FitBH":
|
|
1108
|
+
case "FitV":
|
|
1109
|
+
case "FitBV":
|
|
1110
|
+
if (argsLen > 1) {
|
|
1111
|
+
return false;
|
|
1112
|
+
}
|
|
1113
|
+
break;
|
|
1114
|
+
case "FitR":
|
|
1115
|
+
if (argsLen !== 4) {
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
allowNull = false;
|
|
1119
|
+
break;
|
|
1120
|
+
default:
|
|
1121
|
+
return false;
|
|
1122
|
+
}
|
|
1123
|
+
for (const arg of args) {
|
|
1124
|
+
if (typeof arg === "number" || allowNull && arg === null) {
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
return false;
|
|
1128
|
+
}
|
|
1129
|
+
return true;
|
|
1130
|
+
}
|
|
1131
|
+
function MathClamp(v, min, max) {
|
|
1132
|
+
return Math.min(Math.max(v, min), max);
|
|
1133
|
+
}
|
|
1038
1134
|
function toHexUtil(arr) {
|
|
1039
1135
|
if (Uint8Array.prototype.toHex) {
|
|
1040
1136
|
return arr.toHex();
|
|
@@ -1060,6 +1156,34 @@ if (false) {
|
|
|
1060
1156
|
});
|
|
1061
1157
|
};
|
|
1062
1158
|
}
|
|
1159
|
+
if (typeof Math.sumPrecise !== "function") {
|
|
1160
|
+
Math.sumPrecise = function(numbers) {
|
|
1161
|
+
return numbers.reduce((a, b) => a + b, 0);
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
if (false) {
|
|
1165
|
+
AbortSignal.any = function(iterable) {
|
|
1166
|
+
const ac = new AbortController();
|
|
1167
|
+
const { signal } = ac;
|
|
1168
|
+
for (const s of iterable) {
|
|
1169
|
+
if (s.aborted) {
|
|
1170
|
+
ac.abort(s.reason);
|
|
1171
|
+
return signal;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
for (const s of iterable) {
|
|
1175
|
+
s.addEventListener(
|
|
1176
|
+
"abort",
|
|
1177
|
+
() => {
|
|
1178
|
+
ac.abort(s.reason);
|
|
1179
|
+
},
|
|
1180
|
+
{ signal }
|
|
1181
|
+
// Automatically remove the listener.
|
|
1182
|
+
);
|
|
1183
|
+
}
|
|
1184
|
+
return signal;
|
|
1185
|
+
};
|
|
1186
|
+
}
|
|
1063
1187
|
|
|
1064
1188
|
// src/pdf.js/src/shared/message_handler.js
|
|
1065
1189
|
var CallbackKind = {
|
|
@@ -1516,6 +1640,91 @@ deleteStreamController_fn = async function(streamController, streamId) {
|
|
|
1516
1640
|
delete this.streamControllers[streamId];
|
|
1517
1641
|
};
|
|
1518
1642
|
|
|
1643
|
+
// src/pdf.js/src/shared/scripting_utils.js
|
|
1644
|
+
function makeColorComp(n) {
|
|
1645
|
+
return Math.floor(Math.max(0, Math.min(1, n)) * 255).toString(16).padStart(2, "0");
|
|
1646
|
+
}
|
|
1647
|
+
function scaleAndClamp(x) {
|
|
1648
|
+
return Math.max(0, Math.min(255, 255 * x));
|
|
1649
|
+
}
|
|
1650
|
+
var ColorConverters = class {
|
|
1651
|
+
static CMYK_G([c, y, m, k]) {
|
|
1652
|
+
return ["G", 1 - Math.min(1, 0.3 * c + 0.59 * m + 0.11 * y + k)];
|
|
1653
|
+
}
|
|
1654
|
+
static G_CMYK([g]) {
|
|
1655
|
+
return ["CMYK", 0, 0, 0, 1 - g];
|
|
1656
|
+
}
|
|
1657
|
+
static G_RGB([g]) {
|
|
1658
|
+
return ["RGB", g, g, g];
|
|
1659
|
+
}
|
|
1660
|
+
static G_rgb([g]) {
|
|
1661
|
+
g = scaleAndClamp(g);
|
|
1662
|
+
return [g, g, g];
|
|
1663
|
+
}
|
|
1664
|
+
static G_HTML([g]) {
|
|
1665
|
+
const G = makeColorComp(g);
|
|
1666
|
+
return `#${G}${G}${G}`;
|
|
1667
|
+
}
|
|
1668
|
+
static RGB_G([r, g, b]) {
|
|
1669
|
+
return ["G", 0.3 * r + 0.59 * g + 0.11 * b];
|
|
1670
|
+
}
|
|
1671
|
+
static RGB_rgb(color) {
|
|
1672
|
+
return color.map(scaleAndClamp);
|
|
1673
|
+
}
|
|
1674
|
+
static RGB_HTML(color) {
|
|
1675
|
+
return `#${color.map(makeColorComp).join("")}`;
|
|
1676
|
+
}
|
|
1677
|
+
static T_HTML() {
|
|
1678
|
+
return "#00000000";
|
|
1679
|
+
}
|
|
1680
|
+
static T_rgb() {
|
|
1681
|
+
return [null];
|
|
1682
|
+
}
|
|
1683
|
+
static CMYK_RGB([c, y, m, k]) {
|
|
1684
|
+
return [
|
|
1685
|
+
"RGB",
|
|
1686
|
+
1 - Math.min(1, c + k),
|
|
1687
|
+
1 - Math.min(1, m + k),
|
|
1688
|
+
1 - Math.min(1, y + k)
|
|
1689
|
+
];
|
|
1690
|
+
}
|
|
1691
|
+
static CMYK_rgb([c, y, m, k]) {
|
|
1692
|
+
return [
|
|
1693
|
+
scaleAndClamp(1 - Math.min(1, c + k)),
|
|
1694
|
+
scaleAndClamp(1 - Math.min(1, m + k)),
|
|
1695
|
+
scaleAndClamp(1 - Math.min(1, y + k))
|
|
1696
|
+
];
|
|
1697
|
+
}
|
|
1698
|
+
static CMYK_HTML(components) {
|
|
1699
|
+
const rgb = this.CMYK_RGB(components).slice(1);
|
|
1700
|
+
return this.RGB_HTML(rgb);
|
|
1701
|
+
}
|
|
1702
|
+
static RGB_CMYK([r, g, b]) {
|
|
1703
|
+
const c = 1 - r;
|
|
1704
|
+
const m = 1 - g;
|
|
1705
|
+
const y = 1 - b;
|
|
1706
|
+
const k = Math.min(c, m, y);
|
|
1707
|
+
return ["CMYK", c, m, y, k];
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
var DateFormats = [
|
|
1711
|
+
"m/d",
|
|
1712
|
+
"m/d/yy",
|
|
1713
|
+
"mm/dd/yy",
|
|
1714
|
+
"mm/yy",
|
|
1715
|
+
"d-mmm",
|
|
1716
|
+
"d-mmm-yy",
|
|
1717
|
+
"dd-mmm-yy",
|
|
1718
|
+
"yy-mm-dd",
|
|
1719
|
+
"mmm-yy",
|
|
1720
|
+
"mmmm-yy",
|
|
1721
|
+
"mmm d, yyyy",
|
|
1722
|
+
"mmmm d, yyyy",
|
|
1723
|
+
"m/d/yy h:MM tt",
|
|
1724
|
+
"m/d/yy HH:MM"
|
|
1725
|
+
];
|
|
1726
|
+
var TimeFormats = ["HH:MM", "h:MM tt", "HH:MM:ss", "h:MM:ss tt"];
|
|
1727
|
+
|
|
1519
1728
|
// src/pdf.js/src/shared/murmurhash3.js
|
|
1520
1729
|
var SEED = 3285377520;
|
|
1521
1730
|
var MASK_HIGH = 4294901760;
|
|
@@ -1709,7 +1918,6 @@ function grayToRGBA(src, dest) {
|
|
|
1709
1918
|
|
|
1710
1919
|
export {
|
|
1711
1920
|
isNodeJS,
|
|
1712
|
-
IDENTITY_MATRIX,
|
|
1713
1921
|
FONT_IDENTITY_MATRIX,
|
|
1714
1922
|
LINE_FACTOR,
|
|
1715
1923
|
LINE_DESCENT_FACTOR,
|
|
@@ -1732,6 +1940,7 @@ export {
|
|
|
1732
1940
|
PageActionEventType,
|
|
1733
1941
|
VerbosityLevel,
|
|
1734
1942
|
OPS,
|
|
1943
|
+
DrawOPS,
|
|
1735
1944
|
PasswordResponses,
|
|
1736
1945
|
setVerbosityLevel,
|
|
1737
1946
|
getVerbosityLevel,
|
|
@@ -1740,6 +1949,7 @@ export {
|
|
|
1740
1949
|
unreachable,
|
|
1741
1950
|
assert,
|
|
1742
1951
|
createValidAbsoluteUrl,
|
|
1952
|
+
updateUrlHash,
|
|
1743
1953
|
shadow,
|
|
1744
1954
|
BaseException,
|
|
1745
1955
|
PasswordException,
|
|
@@ -1751,7 +1961,6 @@ export {
|
|
|
1751
1961
|
stringToBytes,
|
|
1752
1962
|
string32,
|
|
1753
1963
|
objectSize,
|
|
1754
|
-
objectFromMap,
|
|
1755
1964
|
FeatureTest,
|
|
1756
1965
|
hexNumbers,
|
|
1757
1966
|
Util,
|
|
@@ -1763,6 +1972,8 @@ export {
|
|
|
1763
1972
|
normalizeUnicode,
|
|
1764
1973
|
getUuid,
|
|
1765
1974
|
AnnotationPrefix,
|
|
1975
|
+
_isValidExplicitDest,
|
|
1976
|
+
MathClamp,
|
|
1766
1977
|
toHexUtil,
|
|
1767
1978
|
toBase64Util,
|
|
1768
1979
|
fromBase64Util,
|
|
@@ -1771,5 +1982,8 @@ export {
|
|
|
1771
1982
|
MessageHandler,
|
|
1772
1983
|
convertToRGBA,
|
|
1773
1984
|
convertBlackAndWhiteToRGBA,
|
|
1774
|
-
grayToRGBA
|
|
1985
|
+
grayToRGBA,
|
|
1986
|
+
ColorConverters,
|
|
1987
|
+
DateFormats,
|
|
1988
|
+
TimeFormats
|
|
1775
1989
|
};
|