@chialab/pdfjs-lib 1.0.0-alpha.0 → 1.0.0-alpha.10
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/{chunk-DYHYQ33L.js → chunk-AK2AE3GS.js} +177 -43
- package/dist/browser/index.js +921 -1009
- package/dist/browser/worker.js +5827 -5389
- package/dist/index.d.ts +1 -0
- package/dist/lib/AnnotationData.d.ts +2 -1
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/SvgCanvasContext.d.ts +3 -2
- package/dist/lib/TextLayer.d.ts +0 -6
- package/dist/lib/utils.d.ts +9 -1
- package/dist/node/{chunk-KTTVPO2G.js → chunk-WL32POZ2.js} +177 -43
- package/dist/node/index.js +927 -1002
- package/dist/node/worker.js +5827 -5389
- package/dist/pdf.js/src/display/api.d.ts +30 -5
- package/dist/pdf.js/src/display/canvas.d.ts +19 -27
- package/dist/pdf.js/src/display/display_utils.d.ts +10 -0
- package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/ink.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -2
- package/dist/pdf.js/src/display/editor/tools.d.ts +0 -6
- package/dist/pdf.js/src/display/pattern_helper.d.ts +4 -2
- package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
- package/dist/pdf.js/src/pdf.d.ts +3 -1
- package/dist/pdf.js/src/shared/util.d.ts +111 -95
- package/package.json +7 -5
- package/dist/browser/LiberationMono-Regular-UUOCTXY2.js +0 -9
- package/dist/browser/LiberationSerif-Regular-ASQ2LI3D.js +0 -9
- package/dist/node/LiberationMono-Regular-KMFXXO3B.js +0 -9
- package/dist/node/LiberationSerif-Regular-WAOWR76G.js +0 -9
package/dist/node/index.js
CHANGED
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
AnnotationPrefix,
|
|
9
9
|
AnnotationType,
|
|
10
10
|
BaseException,
|
|
11
|
+
DrawOPS,
|
|
11
12
|
FONT_IDENTITY_MATRIX,
|
|
12
13
|
FeatureTest,
|
|
13
14
|
FormatError,
|
|
14
|
-
IDENTITY_MATRIX,
|
|
15
15
|
ImageKind,
|
|
16
16
|
InvalidPDFException,
|
|
17
17
|
LINE_FACTOR,
|
|
18
|
+
MathClamp,
|
|
18
19
|
MessageHandler,
|
|
19
20
|
MurmurHash3_64,
|
|
20
21
|
OPS,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
TextRenderingMode,
|
|
26
27
|
Util,
|
|
27
28
|
VerbosityLevel,
|
|
29
|
+
_isValidExplicitDest,
|
|
28
30
|
assert,
|
|
29
31
|
convertBlackAndWhiteToRGBA,
|
|
30
32
|
createValidAbsoluteUrl,
|
|
@@ -43,7 +45,7 @@ import {
|
|
|
43
45
|
unreachable,
|
|
44
46
|
warn,
|
|
45
47
|
wrapReason
|
|
46
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-WL32POZ2.js";
|
|
47
49
|
import {
|
|
48
50
|
__privateAdd,
|
|
49
51
|
__privateGet,
|
|
@@ -237,7 +239,9 @@ var PageViewport = class _PageViewport {
|
|
|
237
239
|
* @see {@link convertToViewportRectangle}
|
|
238
240
|
*/
|
|
239
241
|
convertToViewportPoint(x, y) {
|
|
240
|
-
|
|
242
|
+
const p = [x, y];
|
|
243
|
+
Util.applyTransform(p, this.transform);
|
|
244
|
+
return p;
|
|
241
245
|
}
|
|
242
246
|
/**
|
|
243
247
|
* Converts PDF rectangle to the viewport coordinates.
|
|
@@ -247,8 +251,10 @@ var PageViewport = class _PageViewport {
|
|
|
247
251
|
* @see {@link convertToViewportPoint}
|
|
248
252
|
*/
|
|
249
253
|
convertToViewportRectangle(rect) {
|
|
250
|
-
const topLeft =
|
|
251
|
-
|
|
254
|
+
const topLeft = [rect[0], rect[1]];
|
|
255
|
+
Util.applyTransform(topLeft, this.transform);
|
|
256
|
+
const bottomRight = [rect[2], rect[3]];
|
|
257
|
+
Util.applyTransform(bottomRight, this.transform);
|
|
252
258
|
return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
|
|
253
259
|
}
|
|
254
260
|
/**
|
|
@@ -261,7 +267,9 @@ var PageViewport = class _PageViewport {
|
|
|
261
267
|
* @see {@link convertToViewportPoint}
|
|
262
268
|
*/
|
|
263
269
|
convertToPdfPoint(x, y) {
|
|
264
|
-
|
|
270
|
+
const p = [x, y];
|
|
271
|
+
Util.applyInverseTransform(p, this.transform);
|
|
272
|
+
return p;
|
|
265
273
|
}
|
|
266
274
|
};
|
|
267
275
|
var RenderingCancelledException = class extends BaseException {
|
|
@@ -491,9 +499,9 @@ function setLayerDimensions(div, viewport, mustFlip = false, mustRotate = true)
|
|
|
491
499
|
div.setAttribute("data-main-rotation", viewport.rotation);
|
|
492
500
|
}
|
|
493
501
|
}
|
|
494
|
-
var OutputScale = class {
|
|
502
|
+
var OutputScale = class _OutputScale {
|
|
495
503
|
constructor() {
|
|
496
|
-
const pixelRatio =
|
|
504
|
+
const { pixelRatio } = _OutputScale;
|
|
497
505
|
this.sx = pixelRatio;
|
|
498
506
|
this.sy = pixelRatio;
|
|
499
507
|
}
|
|
@@ -503,9 +511,37 @@ var OutputScale = class {
|
|
|
503
511
|
get scaled() {
|
|
504
512
|
return this.sx !== 1 || this.sy !== 1;
|
|
505
513
|
}
|
|
514
|
+
/**
|
|
515
|
+
* @type {boolean} Returns `true` when scaling is symmetric,
|
|
516
|
+
* `false` otherwise.
|
|
517
|
+
*/
|
|
506
518
|
get symmetric() {
|
|
507
519
|
return this.sx === this.sy;
|
|
508
520
|
}
|
|
521
|
+
/**
|
|
522
|
+
* @returns {boolean} Returns `true` if scaling was limited,
|
|
523
|
+
* `false` otherwise.
|
|
524
|
+
*/
|
|
525
|
+
limitCanvas(width, height, maxPixels, maxDim) {
|
|
526
|
+
let maxAreaScale = Infinity, maxWidthScale = Infinity, maxHeightScale = Infinity;
|
|
527
|
+
if (maxPixels > 0) {
|
|
528
|
+
maxAreaScale = Math.sqrt(maxPixels / (width * height));
|
|
529
|
+
}
|
|
530
|
+
if (maxDim !== -1) {
|
|
531
|
+
maxWidthScale = maxDim / width;
|
|
532
|
+
maxHeightScale = maxDim / height;
|
|
533
|
+
}
|
|
534
|
+
const maxScale = Math.min(maxAreaScale, maxWidthScale, maxHeightScale);
|
|
535
|
+
if (this.sx > maxScale || this.sy > maxScale) {
|
|
536
|
+
this.sx = maxScale;
|
|
537
|
+
this.sy = maxScale;
|
|
538
|
+
return true;
|
|
539
|
+
}
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
542
|
+
static get pixelRatio() {
|
|
543
|
+
return globalThis.devicePixelRatio || 1;
|
|
544
|
+
}
|
|
509
545
|
};
|
|
510
546
|
var SupportedImageMimeTypes = [
|
|
511
547
|
"image/apng",
|
|
@@ -3169,7 +3205,7 @@ setState_fn = async function() {
|
|
|
3169
3205
|
if (!tooltip.parentNode) {
|
|
3170
3206
|
button.append(tooltip);
|
|
3171
3207
|
}
|
|
3172
|
-
const element = __privateGet(this, _editor2).
|
|
3208
|
+
const element = __privateGet(this, _editor2).getElementForAltText();
|
|
3173
3209
|
element?.setAttribute("aria-describedby", tooltip.id);
|
|
3174
3210
|
};
|
|
3175
3211
|
__privateAdd(_AltText, _l10nNewButton, null);
|
|
@@ -3214,12 +3250,12 @@ var _TouchManager = class _TouchManager {
|
|
|
3214
3250
|
signal: __privateGet(this, _signal)
|
|
3215
3251
|
});
|
|
3216
3252
|
}
|
|
3253
|
+
/**
|
|
3254
|
+
* NOTE: Don't shadow this value since `devicePixelRatio` may change if the
|
|
3255
|
+
* window resolution changes, e.g. if the viewer is moved to another monitor.
|
|
3256
|
+
*/
|
|
3217
3257
|
get MIN_TOUCH_DISTANCE_TO_PINCH() {
|
|
3218
|
-
return
|
|
3219
|
-
this,
|
|
3220
|
-
"MIN_TOUCH_DISTANCE_TO_PINCH",
|
|
3221
|
-
35 / (window.devicePixelRatio || 1)
|
|
3222
|
-
);
|
|
3258
|
+
return 35 / OutputScale.pixelRatio;
|
|
3223
3259
|
}
|
|
3224
3260
|
destroy() {
|
|
3225
3261
|
__privateGet(this, _touchManagerAC)?.abort();
|
|
@@ -3801,20 +3837,20 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3801
3837
|
if (this._mustFixPosition) {
|
|
3802
3838
|
switch (rotation) {
|
|
3803
3839
|
case 0:
|
|
3804
|
-
x =
|
|
3805
|
-
y =
|
|
3840
|
+
x = MathClamp(x, 0, pageWidth - width);
|
|
3841
|
+
y = MathClamp(y, 0, pageHeight - height);
|
|
3806
3842
|
break;
|
|
3807
3843
|
case 90:
|
|
3808
|
-
x =
|
|
3809
|
-
y =
|
|
3844
|
+
x = MathClamp(x, 0, pageWidth - height);
|
|
3845
|
+
y = MathClamp(y, width, pageHeight);
|
|
3810
3846
|
break;
|
|
3811
3847
|
case 180:
|
|
3812
|
-
x =
|
|
3813
|
-
y =
|
|
3848
|
+
x = MathClamp(x, width, pageWidth);
|
|
3849
|
+
y = MathClamp(y, height, pageHeight);
|
|
3814
3850
|
break;
|
|
3815
3851
|
case 270:
|
|
3816
|
-
x =
|
|
3817
|
-
y =
|
|
3852
|
+
x = MathClamp(x, height, pageWidth);
|
|
3853
|
+
y = MathClamp(y, 0, pageHeight - width);
|
|
3818
3854
|
break;
|
|
3819
3855
|
}
|
|
3820
3856
|
}
|
|
@@ -3991,29 +4027,35 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
3991
4027
|
* @returns {HTMLDivElement | null}
|
|
3992
4028
|
*/
|
|
3993
4029
|
render() {
|
|
3994
|
-
this.div = document.createElement("div");
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
4030
|
+
const div = this.div = document.createElement("div");
|
|
4031
|
+
div.setAttribute("data-editor-rotation", (360 - this.rotation) % 360);
|
|
4032
|
+
div.className = this.name;
|
|
4033
|
+
div.setAttribute("id", this.id);
|
|
4034
|
+
div.tabIndex = __privateGet(this, _disabled) ? -1 : 0;
|
|
4035
|
+
div.setAttribute("role", "application");
|
|
4036
|
+
if (this.defaultL10nId) {
|
|
4037
|
+
div.setAttribute("data-l10n-id", this.defaultL10nId);
|
|
4038
|
+
}
|
|
3999
4039
|
if (!this._isVisible) {
|
|
4000
|
-
|
|
4040
|
+
div.classList.add("hidden");
|
|
4001
4041
|
}
|
|
4002
4042
|
this.setInForeground();
|
|
4003
4043
|
__privateMethod(this, _AnnotationEditor_instances, addFocusListeners_fn).call(this);
|
|
4004
4044
|
const [parentWidth, parentHeight] = this.parentDimensions;
|
|
4005
4045
|
if (this.parentRotation % 180 !== 0) {
|
|
4006
|
-
|
|
4046
|
+
div.style.maxWidth = `${(100 * parentHeight / parentWidth).toFixed(
|
|
4047
|
+
2
|
|
4048
|
+
)}%`;
|
|
4049
|
+
div.style.maxHeight = `${(100 * parentWidth / parentHeight).toFixed(
|
|
4007
4050
|
2
|
|
4008
4051
|
)}%`;
|
|
4009
|
-
this.div.style.maxHeight = `${(100 * parentWidth / parentHeight).toFixed(2)}%`;
|
|
4010
4052
|
}
|
|
4011
4053
|
const [tx, ty] = this.getInitialTranslation();
|
|
4012
4054
|
this.translate(tx, ty);
|
|
4013
|
-
bindEvents(this,
|
|
4055
|
+
bindEvents(this, div, ["keydown", "pointerdown"]);
|
|
4014
4056
|
if (this.isResizable && this._uiManager._supportsPinchToZoom) {
|
|
4015
4057
|
__privateGet(this, _touchManager) || __privateSet(this, _touchManager, new TouchManager({
|
|
4016
|
-
container:
|
|
4058
|
+
container: div,
|
|
4017
4059
|
isPinchingDisabled: () => !this.isSelected,
|
|
4018
4060
|
onPinchStart: __privateMethod(this, _AnnotationEditor_instances, touchPinchStartCallback_fn).bind(this),
|
|
4019
4061
|
onPinching: __privateMethod(this, _AnnotationEditor_instances, touchPinchCallback_fn).bind(this),
|
|
@@ -4022,7 +4064,7 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4022
4064
|
}));
|
|
4023
4065
|
}
|
|
4024
4066
|
this._uiManager._editorUndoBar?.hide();
|
|
4025
|
-
return
|
|
4067
|
+
return div;
|
|
4026
4068
|
}
|
|
4027
4069
|
/**
|
|
4028
4070
|
* Onpointerdown callback.
|
|
@@ -4312,7 +4354,6 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4312
4354
|
if (this.isResizable) {
|
|
4313
4355
|
__privateMethod(this, _AnnotationEditor_instances, createResizers_fn).call(this);
|
|
4314
4356
|
__privateGet(this, _resizersDiv).classList.remove("hidden");
|
|
4315
|
-
bindEvents(this, this.div, ["keydown"]);
|
|
4316
4357
|
}
|
|
4317
4358
|
}
|
|
4318
4359
|
get toolbarPosition() {
|
|
@@ -4454,8 +4495,8 @@ var _AnnotationEditor = class _AnnotationEditor {
|
|
|
4454
4495
|
/**
|
|
4455
4496
|
* @returns {HTMLElement | null} the element requiring an alt text.
|
|
4456
4497
|
*/
|
|
4457
|
-
|
|
4458
|
-
return
|
|
4498
|
+
getElementForAltText() {
|
|
4499
|
+
return this.div;
|
|
4459
4500
|
}
|
|
4460
4501
|
/**
|
|
4461
4502
|
* Get the div which really contains the displayed content.
|
|
@@ -4859,14 +4900,12 @@ resizerPointermove_fn = function(name, event) {
|
|
|
4859
4900
|
minHeight / savedHeight
|
|
4860
4901
|
);
|
|
4861
4902
|
} else if (isHorizontal) {
|
|
4862
|
-
ratioX = Math.
|
|
4863
|
-
minWidth,
|
|
4864
|
-
Math.min(1, Math.abs(oppositePoint[0] - point[0] - deltaX))
|
|
4865
|
-
) / savedWidth;
|
|
4903
|
+
ratioX = MathClamp(Math.abs(oppositePoint[0] - point[0] - deltaX), minWidth, 1) / savedWidth;
|
|
4866
4904
|
} else {
|
|
4867
|
-
ratioY =
|
|
4905
|
+
ratioY = MathClamp(
|
|
4906
|
+
Math.abs(oppositePoint[1] - point[1] - deltaY),
|
|
4868
4907
|
minHeight,
|
|
4869
|
-
|
|
4908
|
+
1
|
|
4870
4909
|
) / savedHeight;
|
|
4871
4910
|
}
|
|
4872
4911
|
const newWidth = _AnnotationEditor._round(savedWidth * ratioX);
|
|
@@ -5332,7 +5371,10 @@ var PrintAnnotationStorage = class extends AnnotationStorage {
|
|
|
5332
5371
|
_serializable = new WeakMap();
|
|
5333
5372
|
|
|
5334
5373
|
// src/lib/NodeCanvas.ts
|
|
5374
|
+
import { writeFile } from "node:fs/promises";
|
|
5335
5375
|
import { createRequire } from "node:module";
|
|
5376
|
+
import { dirname, join } from "node:path";
|
|
5377
|
+
import { fileURLToPath } from "node:url";
|
|
5336
5378
|
var require2 = createRequire(import.meta.url);
|
|
5337
5379
|
var {
|
|
5338
5380
|
createCanvas: create,
|
|
@@ -5340,32 +5382,23 @@ var {
|
|
|
5340
5382
|
Path2D
|
|
5341
5383
|
} = require2("@napi-rs/canvas");
|
|
5342
5384
|
async function createCanvas(width, height) {
|
|
5385
|
+
await loadDefaultFonts();
|
|
5343
5386
|
return create(width, height);
|
|
5344
5387
|
}
|
|
5388
|
+
var loadingFontPromise = null;
|
|
5345
5389
|
async function loadDefaultFonts() {
|
|
5346
|
-
|
|
5347
|
-
import("./
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
(
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
)
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
Buffer.from(monoBuffer),
|
|
5359
|
-
"Liberation Mono"
|
|
5360
|
-
);
|
|
5361
|
-
GlobalFonts.register(
|
|
5362
|
-
Buffer.from(sansBuffer),
|
|
5363
|
-
"Liberation Sans"
|
|
5364
|
-
);
|
|
5365
|
-
GlobalFonts.register(
|
|
5366
|
-
Buffer.from(serifBuffer),
|
|
5367
|
-
"Liberation Serif"
|
|
5368
|
-
);
|
|
5390
|
+
if (loadingFontPromise === null) {
|
|
5391
|
+
loadingFontPromise = import("./LiberationSans-Regular-CDMMZL5S.js").then((module) => module.default).then(async (sansBuffer) => {
|
|
5392
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
5393
|
+
const fileName = join(currentDir, "LiberationSans-Regular.ttf");
|
|
5394
|
+
await writeFile(fileName, sansBuffer);
|
|
5395
|
+
GlobalFonts.registerFromPath(
|
|
5396
|
+
fileName,
|
|
5397
|
+
"Liberation Sans"
|
|
5398
|
+
);
|
|
5399
|
+
});
|
|
5400
|
+
}
|
|
5401
|
+
return loadingFontPromise;
|
|
5369
5402
|
}
|
|
5370
5403
|
|
|
5371
5404
|
// src/lib/Path2D.ts
|
|
@@ -6701,6 +6734,9 @@ var BaseShadingPattern = class {
|
|
|
6701
6734
|
unreachable("Cannot initialize BaseShadingPattern.");
|
|
6702
6735
|
}
|
|
6703
6736
|
}
|
|
6737
|
+
isModifyingCurrentTransform() {
|
|
6738
|
+
return false;
|
|
6739
|
+
}
|
|
6704
6740
|
getPattern() {
|
|
6705
6741
|
unreachable("Abstract method `getPattern` called.");
|
|
6706
6742
|
}
|
|
@@ -6999,17 +7035,22 @@ var MeshShadingPattern = class extends BaseShadingPattern {
|
|
|
6999
7035
|
scaleY
|
|
7000
7036
|
};
|
|
7001
7037
|
}
|
|
7038
|
+
isModifyingCurrentTransform() {
|
|
7039
|
+
return true;
|
|
7040
|
+
}
|
|
7002
7041
|
getPattern(ctx, owner, inverse, pathType) {
|
|
7003
7042
|
applyBoundingBox(ctx, this._bbox);
|
|
7004
|
-
|
|
7043
|
+
const scale = new Float32Array(2);
|
|
7005
7044
|
if (pathType === PathType.SHADING) {
|
|
7006
|
-
|
|
7045
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(ctx), scale);
|
|
7046
|
+
} else if (this.matrix) {
|
|
7047
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
7048
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
7049
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
7050
|
+
scale[0] *= matrixScaleX;
|
|
7051
|
+
scale[1] *= matrixScaleY;
|
|
7007
7052
|
} else {
|
|
7008
|
-
|
|
7009
|
-
if (this.matrix) {
|
|
7010
|
-
const matrixScale = Util.singularValueDecompose2dScale(this.matrix);
|
|
7011
|
-
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
|
|
7012
|
-
}
|
|
7053
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
7013
7054
|
}
|
|
7014
7055
|
const temporaryPatternCanvas = this._createMeshCanvas(
|
|
7015
7056
|
scale,
|
|
@@ -7051,7 +7092,8 @@ var PaintType = {
|
|
|
7051
7092
|
UNCOLORED: 2
|
|
7052
7093
|
};
|
|
7053
7094
|
var _TilingPattern = class _TilingPattern {
|
|
7054
|
-
constructor(IR,
|
|
7095
|
+
constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {
|
|
7096
|
+
this.color = IR[1];
|
|
7055
7097
|
this.operatorList = IR[2];
|
|
7056
7098
|
this.matrix = IR[3];
|
|
7057
7099
|
this.bbox = IR[4];
|
|
@@ -7059,7 +7101,6 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7059
7101
|
this.ystep = IR[6];
|
|
7060
7102
|
this.paintType = IR[7];
|
|
7061
7103
|
this.tilingType = IR[8];
|
|
7062
|
-
this.color = color;
|
|
7063
7104
|
this.ctx = ctx;
|
|
7064
7105
|
this.canvasGraphicsFactory = canvasGraphicsFactory;
|
|
7065
7106
|
this.baseTransform = baseTransform;
|
|
@@ -7080,12 +7121,12 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7080
7121
|
const x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
|
7081
7122
|
const width = x1 - x0;
|
|
7082
7123
|
const height = y1 - y0;
|
|
7083
|
-
const
|
|
7084
|
-
|
|
7085
|
-
|
|
7086
|
-
);
|
|
7087
|
-
const combinedScaleX =
|
|
7088
|
-
const combinedScaleY =
|
|
7124
|
+
const scale = new Float32Array(2);
|
|
7125
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
7126
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
7127
|
+
Util.singularValueDecompose2dScale(this.baseTransform, scale);
|
|
7128
|
+
const combinedScaleX = matrixScaleX * scale[0];
|
|
7129
|
+
const combinedScaleY = matrixScaleY * scale[1];
|
|
7089
7130
|
let canvasWidth = width, canvasHeight = height, redrawHorizontally = false, redrawVertically = false;
|
|
7090
7131
|
const xScaledStep = Math.ceil(xstep * combinedScaleX);
|
|
7091
7132
|
const yScaledStep = Math.ceil(ystep * combinedScaleY);
|
|
@@ -7201,12 +7242,11 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7201
7242
|
const bboxWidth = x1 - x0;
|
|
7202
7243
|
const bboxHeight = y1 - y0;
|
|
7203
7244
|
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
|
|
7204
|
-
|
|
7205
|
-
x0,
|
|
7206
|
-
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
]);
|
|
7245
|
+
Util.axialAlignedBoundingBox(
|
|
7246
|
+
[x0, y0, x1, y1],
|
|
7247
|
+
getCurrentTransform(graphics.ctx),
|
|
7248
|
+
graphics.current.minMax
|
|
7249
|
+
);
|
|
7210
7250
|
graphics.clip();
|
|
7211
7251
|
graphics.endPath();
|
|
7212
7252
|
}
|
|
@@ -7231,6 +7271,9 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7231
7271
|
throw new FormatError(`Unsupported paint type: ${paintType}`);
|
|
7232
7272
|
}
|
|
7233
7273
|
}
|
|
7274
|
+
isModifyingCurrentTransform() {
|
|
7275
|
+
return false;
|
|
7276
|
+
}
|
|
7234
7277
|
getPattern(ctx, owner, inverse, pathType) {
|
|
7235
7278
|
let matrix = inverse;
|
|
7236
7279
|
if (pathType !== PathType.SHADING) {
|
|
@@ -7263,8 +7306,15 @@ var MIN_FONT_SIZE = 16;
|
|
|
7263
7306
|
var MAX_FONT_SIZE = 100;
|
|
7264
7307
|
var EXECUTION_TIME = 15;
|
|
7265
7308
|
var EXECUTION_STEPS = 10;
|
|
7266
|
-
var MAX_SIZE_TO_COMPILE = 1e3;
|
|
7267
7309
|
var FULL_CHUNK_HEIGHT = 16;
|
|
7310
|
+
var SCALE_MATRIX = new DOMMatrix();
|
|
7311
|
+
var XY = new Float32Array(2);
|
|
7312
|
+
var MIN_MAX_INIT = new Float32Array([
|
|
7313
|
+
Infinity,
|
|
7314
|
+
Infinity,
|
|
7315
|
+
-Infinity,
|
|
7316
|
+
-Infinity
|
|
7317
|
+
]);
|
|
7268
7318
|
function mirrorContextOperations(ctx, destCtx) {
|
|
7269
7319
|
if (ctx._removeMirroring) {
|
|
7270
7320
|
throw new Error("Context is already forwarding operations.");
|
|
@@ -7302,39 +7352,39 @@ function mirrorContextOperations(ctx, destCtx) {
|
|
|
7302
7352
|
ctx.beginPath = ctx.__originalBeginPath;
|
|
7303
7353
|
delete ctx._removeMirroring;
|
|
7304
7354
|
};
|
|
7305
|
-
ctx.save = function
|
|
7355
|
+
ctx.save = function() {
|
|
7306
7356
|
destCtx.save();
|
|
7307
7357
|
this.__originalSave();
|
|
7308
7358
|
};
|
|
7309
|
-
ctx.restore = function
|
|
7359
|
+
ctx.restore = function() {
|
|
7310
7360
|
destCtx.restore();
|
|
7311
7361
|
this.__originalRestore();
|
|
7312
7362
|
};
|
|
7313
|
-
ctx.translate = function
|
|
7363
|
+
ctx.translate = function(x, y) {
|
|
7314
7364
|
destCtx.translate(x, y);
|
|
7315
7365
|
this.__originalTranslate(x, y);
|
|
7316
7366
|
};
|
|
7317
|
-
ctx.scale = function
|
|
7367
|
+
ctx.scale = function(x, y) {
|
|
7318
7368
|
destCtx.scale(x, y);
|
|
7319
7369
|
this.__originalScale(x, y);
|
|
7320
7370
|
};
|
|
7321
|
-
ctx.transform = function
|
|
7371
|
+
ctx.transform = function(a, b, c, d, e, f) {
|
|
7322
7372
|
destCtx.transform(a, b, c, d, e, f);
|
|
7323
7373
|
this.__originalTransform(a, b, c, d, e, f);
|
|
7324
7374
|
};
|
|
7325
|
-
ctx.setTransform = function
|
|
7375
|
+
ctx.setTransform = function(a, b, c, d, e, f) {
|
|
7326
7376
|
destCtx.setTransform(a, b, c, d, e, f);
|
|
7327
7377
|
this.__originalSetTransform(a, b, c, d, e, f);
|
|
7328
7378
|
};
|
|
7329
|
-
ctx.resetTransform = function
|
|
7379
|
+
ctx.resetTransform = function() {
|
|
7330
7380
|
destCtx.resetTransform();
|
|
7331
7381
|
this.__originalResetTransform();
|
|
7332
7382
|
};
|
|
7333
|
-
ctx.rotate = function
|
|
7383
|
+
ctx.rotate = function(angle) {
|
|
7334
7384
|
destCtx.rotate(angle);
|
|
7335
7385
|
this.__originalRotate(angle);
|
|
7336
7386
|
};
|
|
7337
|
-
ctx.clip = function
|
|
7387
|
+
ctx.clip = function(rule) {
|
|
7338
7388
|
destCtx.clip(rule);
|
|
7339
7389
|
this.__originalClip(rule);
|
|
7340
7390
|
};
|
|
@@ -7425,227 +7475,57 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
7425
7475
|
const scaleY = Math.hypot(c, d);
|
|
7426
7476
|
return [scaleX * destW, scaleY * destH];
|
|
7427
7477
|
}
|
|
7428
|
-
function compileType3Glyph(imgData) {
|
|
7429
|
-
const { width, height } = imgData;
|
|
7430
|
-
if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
7431
|
-
return null;
|
|
7432
|
-
}
|
|
7433
|
-
const POINT_TO_PROCESS_LIMIT = 1e3;
|
|
7434
|
-
const POINT_TYPES = new Uint8Array([
|
|
7435
|
-
0,
|
|
7436
|
-
2,
|
|
7437
|
-
4,
|
|
7438
|
-
0,
|
|
7439
|
-
1,
|
|
7440
|
-
0,
|
|
7441
|
-
5,
|
|
7442
|
-
4,
|
|
7443
|
-
8,
|
|
7444
|
-
10,
|
|
7445
|
-
0,
|
|
7446
|
-
8,
|
|
7447
|
-
0,
|
|
7448
|
-
2,
|
|
7449
|
-
1,
|
|
7450
|
-
0
|
|
7451
|
-
]);
|
|
7452
|
-
const width1 = width + 1;
|
|
7453
|
-
let points = new Uint8Array(width1 * (height + 1));
|
|
7454
|
-
let i, j, j0;
|
|
7455
|
-
const lineSize = width + 7 & ~7;
|
|
7456
|
-
let data = new Uint8Array(lineSize * height), pos = 0;
|
|
7457
|
-
for (const elem of imgData.data) {
|
|
7458
|
-
let mask = 128;
|
|
7459
|
-
while (mask > 0) {
|
|
7460
|
-
data[pos++] = elem & mask ? 0 : 255;
|
|
7461
|
-
mask >>= 1;
|
|
7462
|
-
}
|
|
7463
|
-
}
|
|
7464
|
-
let count = 0;
|
|
7465
|
-
pos = 0;
|
|
7466
|
-
if (data[pos] !== 0) {
|
|
7467
|
-
points[0] = 1;
|
|
7468
|
-
++count;
|
|
7469
|
-
}
|
|
7470
|
-
for (j = 1; j < width; j++) {
|
|
7471
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7472
|
-
points[j] = data[pos] ? 2 : 1;
|
|
7473
|
-
++count;
|
|
7474
|
-
}
|
|
7475
|
-
pos++;
|
|
7476
|
-
}
|
|
7477
|
-
if (data[pos] !== 0) {
|
|
7478
|
-
points[j] = 2;
|
|
7479
|
-
++count;
|
|
7480
|
-
}
|
|
7481
|
-
for (i = 1; i < height; i++) {
|
|
7482
|
-
pos = i * lineSize;
|
|
7483
|
-
j0 = i * width1;
|
|
7484
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7485
|
-
points[j0] = data[pos] ? 1 : 8;
|
|
7486
|
-
++count;
|
|
7487
|
-
}
|
|
7488
|
-
let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
|
7489
|
-
for (j = 1; j < width; j++) {
|
|
7490
|
-
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
|
|
7491
|
-
if (POINT_TYPES[sum]) {
|
|
7492
|
-
points[j0 + j] = POINT_TYPES[sum];
|
|
7493
|
-
++count;
|
|
7494
|
-
}
|
|
7495
|
-
pos++;
|
|
7496
|
-
}
|
|
7497
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7498
|
-
points[j0 + j] = data[pos] ? 2 : 4;
|
|
7499
|
-
++count;
|
|
7500
|
-
}
|
|
7501
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7502
|
-
return null;
|
|
7503
|
-
}
|
|
7504
|
-
}
|
|
7505
|
-
pos = lineSize * (height - 1);
|
|
7506
|
-
j0 = i * width1;
|
|
7507
|
-
if (data[pos] !== 0) {
|
|
7508
|
-
points[j0] = 8;
|
|
7509
|
-
++count;
|
|
7510
|
-
}
|
|
7511
|
-
for (j = 1; j < width; j++) {
|
|
7512
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7513
|
-
points[j0 + j] = data[pos] ? 4 : 8;
|
|
7514
|
-
++count;
|
|
7515
|
-
}
|
|
7516
|
-
pos++;
|
|
7517
|
-
}
|
|
7518
|
-
if (data[pos] !== 0) {
|
|
7519
|
-
points[j0 + j] = 4;
|
|
7520
|
-
++count;
|
|
7521
|
-
}
|
|
7522
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7523
|
-
return null;
|
|
7524
|
-
}
|
|
7525
|
-
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
7526
|
-
const path = new SvgPath2D();
|
|
7527
|
-
for (i = 0; count && i <= height; i++) {
|
|
7528
|
-
let p = i * width1;
|
|
7529
|
-
const end = p + width;
|
|
7530
|
-
while (p < end && !points[p]) {
|
|
7531
|
-
p++;
|
|
7532
|
-
}
|
|
7533
|
-
if (p === end) {
|
|
7534
|
-
continue;
|
|
7535
|
-
}
|
|
7536
|
-
path.moveTo(p % width1, i);
|
|
7537
|
-
const p0 = p;
|
|
7538
|
-
let type = points[p];
|
|
7539
|
-
do {
|
|
7540
|
-
const step = steps[type];
|
|
7541
|
-
do {
|
|
7542
|
-
p += step;
|
|
7543
|
-
} while (!points[p]);
|
|
7544
|
-
const pp = points[p];
|
|
7545
|
-
if (pp !== 5 && pp !== 10) {
|
|
7546
|
-
type = pp;
|
|
7547
|
-
points[p] = 0;
|
|
7548
|
-
} else {
|
|
7549
|
-
type = pp & 51 * type >> 4;
|
|
7550
|
-
points[p] &= type >> 2 | type << 2;
|
|
7551
|
-
}
|
|
7552
|
-
path.lineTo(p % width1, p / width1 | 0);
|
|
7553
|
-
if (!points[p]) {
|
|
7554
|
-
--count;
|
|
7555
|
-
}
|
|
7556
|
-
} while (p0 !== p);
|
|
7557
|
-
--i;
|
|
7558
|
-
}
|
|
7559
|
-
data = null;
|
|
7560
|
-
points = null;
|
|
7561
|
-
const drawOutline = function(c) {
|
|
7562
|
-
c.save();
|
|
7563
|
-
c.scale(1 / width, -1 / height);
|
|
7564
|
-
c.translate(0, -height);
|
|
7565
|
-
c.fill(path);
|
|
7566
|
-
c.beginPath();
|
|
7567
|
-
c.restore();
|
|
7568
|
-
};
|
|
7569
|
-
return drawOutline;
|
|
7570
|
-
}
|
|
7571
7478
|
var CanvasExtraState = class {
|
|
7572
7479
|
constructor(width, height) {
|
|
7573
|
-
|
|
7574
|
-
this
|
|
7575
|
-
this
|
|
7576
|
-
this
|
|
7577
|
-
this
|
|
7578
|
-
this
|
|
7579
|
-
this
|
|
7580
|
-
this
|
|
7581
|
-
|
|
7582
|
-
this
|
|
7583
|
-
this
|
|
7584
|
-
|
|
7585
|
-
this
|
|
7586
|
-
this
|
|
7587
|
-
|
|
7588
|
-
this
|
|
7589
|
-
this
|
|
7590
|
-
this
|
|
7591
|
-
this
|
|
7592
|
-
this
|
|
7593
|
-
|
|
7594
|
-
this
|
|
7595
|
-
this
|
|
7596
|
-
this
|
|
7597
|
-
this
|
|
7598
|
-
|
|
7480
|
+
// Are soft masks and alpha values shapes or opacities?
|
|
7481
|
+
__publicField(this, "alphaIsShape", false);
|
|
7482
|
+
__publicField(this, "fontSize", 0);
|
|
7483
|
+
__publicField(this, "fontSizeScale", 1);
|
|
7484
|
+
__publicField(this, "textMatrix", null);
|
|
7485
|
+
__publicField(this, "textMatrixScale", 1);
|
|
7486
|
+
__publicField(this, "fontMatrix", FONT_IDENTITY_MATRIX);
|
|
7487
|
+
__publicField(this, "leading", 0);
|
|
7488
|
+
// Current point (in user coordinates)
|
|
7489
|
+
__publicField(this, "x", 0);
|
|
7490
|
+
__publicField(this, "y", 0);
|
|
7491
|
+
// Start of text line (in text coordinates)
|
|
7492
|
+
__publicField(this, "lineX", 0);
|
|
7493
|
+
__publicField(this, "lineY", 0);
|
|
7494
|
+
// Character and word spacing
|
|
7495
|
+
__publicField(this, "charSpacing", 0);
|
|
7496
|
+
__publicField(this, "wordSpacing", 0);
|
|
7497
|
+
__publicField(this, "textHScale", 1);
|
|
7498
|
+
__publicField(this, "textRenderingMode", TextRenderingMode.FILL);
|
|
7499
|
+
__publicField(this, "textRise", 0);
|
|
7500
|
+
// Default fore and background colors
|
|
7501
|
+
__publicField(this, "fillColor", "#000000");
|
|
7502
|
+
__publicField(this, "strokeColor", "#000000");
|
|
7503
|
+
__publicField(this, "patternFill", false);
|
|
7504
|
+
__publicField(this, "patternStroke", false);
|
|
7505
|
+
// Note: fill alpha applies to all non-stroking operations
|
|
7506
|
+
__publicField(this, "fillAlpha", 1);
|
|
7507
|
+
__publicField(this, "strokeAlpha", 1);
|
|
7508
|
+
__publicField(this, "lineWidth", 1);
|
|
7509
|
+
__publicField(this, "activeSMask", null);
|
|
7510
|
+
__publicField(this, "transferMaps", "none");
|
|
7511
|
+
this.clipBox = new Float32Array([0, 0, width, height]);
|
|
7512
|
+
this.minMax = MIN_MAX_INIT.slice();
|
|
7599
7513
|
}
|
|
7600
7514
|
clone() {
|
|
7601
7515
|
const clone = Object.create(this);
|
|
7602
7516
|
clone.clipBox = this.clipBox.slice();
|
|
7517
|
+
clone.minMax = this.minMax.slice();
|
|
7603
7518
|
return clone;
|
|
7604
7519
|
}
|
|
7605
|
-
setCurrentPoint(x, y) {
|
|
7606
|
-
this.x = x;
|
|
7607
|
-
this.y = y;
|
|
7608
|
-
}
|
|
7609
|
-
updatePathMinMax(transform, x, y) {
|
|
7610
|
-
[x, y] = Util.applyTransform([x, y], transform);
|
|
7611
|
-
this.minX = Math.min(this.minX, x);
|
|
7612
|
-
this.minY = Math.min(this.minY, y);
|
|
7613
|
-
this.maxX = Math.max(this.maxX, x);
|
|
7614
|
-
this.maxY = Math.max(this.maxY, y);
|
|
7615
|
-
}
|
|
7616
|
-
updateRectMinMax(transform, rect) {
|
|
7617
|
-
const p1 = Util.applyTransform(rect, transform);
|
|
7618
|
-
const p2 = Util.applyTransform(rect.slice(2), transform);
|
|
7619
|
-
const p3 = Util.applyTransform([rect[0], rect[3]], transform);
|
|
7620
|
-
const p4 = Util.applyTransform([rect[2], rect[1]], transform);
|
|
7621
|
-
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
|
7622
|
-
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
|
7623
|
-
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
|
7624
|
-
this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
|
|
7625
|
-
}
|
|
7626
|
-
updateScalingPathMinMax(transform, minMax) {
|
|
7627
|
-
Util.scaleMinMax(transform, minMax);
|
|
7628
|
-
this.minX = Math.min(this.minX, minMax[0]);
|
|
7629
|
-
this.minY = Math.min(this.minY, minMax[1]);
|
|
7630
|
-
this.maxX = Math.max(this.maxX, minMax[2]);
|
|
7631
|
-
this.maxY = Math.max(this.maxY, minMax[3]);
|
|
7632
|
-
}
|
|
7633
|
-
updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
7634
|
-
const box = Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax);
|
|
7635
|
-
if (minMax) {
|
|
7636
|
-
return;
|
|
7637
|
-
}
|
|
7638
|
-
this.updateRectMinMax(transform, box);
|
|
7639
|
-
}
|
|
7640
7520
|
getPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
7641
|
-
const box =
|
|
7521
|
+
const box = this.minMax.slice();
|
|
7642
7522
|
if (pathType === PathType.STROKE) {
|
|
7643
7523
|
if (!transform) {
|
|
7644
7524
|
unreachable("Stroke bounding box must include transform.");
|
|
7645
7525
|
}
|
|
7646
|
-
|
|
7647
|
-
const xStrokePad =
|
|
7648
|
-
const yStrokePad =
|
|
7526
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7527
|
+
const xStrokePad = XY[0] * this.lineWidth / 2;
|
|
7528
|
+
const yStrokePad = XY[1] * this.lineWidth / 2;
|
|
7649
7529
|
box[0] -= xStrokePad;
|
|
7650
7530
|
box[1] -= yStrokePad;
|
|
7651
7531
|
box[2] += xStrokePad;
|
|
@@ -7658,14 +7538,11 @@ var CanvasExtraState = class {
|
|
|
7658
7538
|
this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
|
|
7659
7539
|
}
|
|
7660
7540
|
isEmptyClip() {
|
|
7661
|
-
return this.
|
|
7541
|
+
return this.minMax[0] === Infinity;
|
|
7662
7542
|
}
|
|
7663
7543
|
startNewPathAndClipBox(box) {
|
|
7664
|
-
this.clipBox
|
|
7665
|
-
this.
|
|
7666
|
-
this.minY = Infinity;
|
|
7667
|
-
this.maxX = 0;
|
|
7668
|
-
this.maxY = 0;
|
|
7544
|
+
this.clipBox.set(box, 0);
|
|
7545
|
+
this.minMax.set(MIN_MAX_INIT, 0);
|
|
7669
7546
|
}
|
|
7670
7547
|
getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
7671
7548
|
return Util.intersect(
|
|
@@ -7829,24 +7706,20 @@ function resetCtxToDefault(ctx) {
|
|
|
7829
7706
|
ctx.setLineDash([]);
|
|
7830
7707
|
ctx.lineDashOffset = 0;
|
|
7831
7708
|
}
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
ctx.filter = "none";
|
|
7836
|
-
}
|
|
7709
|
+
const { filter } = ctx;
|
|
7710
|
+
if (filter !== "none" && filter !== "") {
|
|
7711
|
+
ctx.filter = "none";
|
|
7837
7712
|
}
|
|
7838
7713
|
}
|
|
7839
7714
|
function getImageSmoothingEnabled(transform, interpolate) {
|
|
7840
7715
|
if (interpolate) {
|
|
7841
7716
|
return true;
|
|
7842
7717
|
}
|
|
7843
|
-
|
|
7844
|
-
scale[0] = Math.fround(scale[0]);
|
|
7845
|
-
scale[1] = Math.fround(scale[1]);
|
|
7718
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7846
7719
|
const actualScale = Math.fround(
|
|
7847
|
-
|
|
7720
|
+
OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS
|
|
7848
7721
|
);
|
|
7849
|
-
return
|
|
7722
|
+
return XY[0] <= actualScale && XY[1] <= actualScale;
|
|
7850
7723
|
}
|
|
7851
7724
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
7852
7725
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
|
@@ -7871,7 +7744,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7871
7744
|
this.canvasFactory = canvasFactory;
|
|
7872
7745
|
this.filterFactory = filterFactory;
|
|
7873
7746
|
this.groupStack = [];
|
|
7874
|
-
this.processingType3 = null;
|
|
7875
7747
|
this.baseTransform = null;
|
|
7876
7748
|
this.baseTransformStack = [];
|
|
7877
7749
|
this.groupLevel = 0;
|
|
@@ -8092,10 +7964,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8092
7964
|
0
|
|
8093
7965
|
]);
|
|
8094
7966
|
maskToCanvas = Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
|
|
8095
|
-
const
|
|
8096
|
-
|
|
8097
|
-
|
|
8098
|
-
);
|
|
7967
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
7968
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], maskToCanvas, minMax);
|
|
7969
|
+
const [minX, minY, maxX, maxY] = minMax;
|
|
8099
7970
|
const drawnWidth = Math.round(maxX - minX) || 1;
|
|
8100
7971
|
const drawnHeight = Math.round(maxY - minY) || 1;
|
|
8101
7972
|
const fillCanvas = this.cachedCanvases.getCanvas(
|
|
@@ -8214,8 +8085,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8214
8085
|
this.current.strokeAlpha = value;
|
|
8215
8086
|
break;
|
|
8216
8087
|
case "ca":
|
|
8217
|
-
this.current.fillAlpha = value;
|
|
8218
|
-
this.ctx.globalAlpha = value;
|
|
8088
|
+
this.ctx.globalAlpha = this.current.fillAlpha = value;
|
|
8219
8089
|
break;
|
|
8220
8090
|
case "BM":
|
|
8221
8091
|
this.ctx.globalCompositeOperation = value;
|
|
@@ -8264,16 +8134,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8264
8134
|
drawnHeight
|
|
8265
8135
|
);
|
|
8266
8136
|
this.suspendedCtx = this.ctx;
|
|
8267
|
-
this.ctx = scratchCanvas.context;
|
|
8268
|
-
|
|
8269
|
-
ctx.setTransform(...getCurrentTransform(this.suspendedCtx));
|
|
8137
|
+
const ctx = this.ctx = scratchCanvas.context;
|
|
8138
|
+
ctx.setTransform(this.suspendedCtx.getTransform());
|
|
8270
8139
|
copyCtxState(this.suspendedCtx, ctx);
|
|
8271
8140
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
8272
|
-
this.setGState([
|
|
8273
|
-
["BM", "source-over"],
|
|
8274
|
-
["ca", 1],
|
|
8275
|
-
["CA", 1]
|
|
8276
|
-
]);
|
|
8141
|
+
this.setGState([["BM", "source-over"]]);
|
|
8277
8142
|
}
|
|
8278
8143
|
endSMaskMode() {
|
|
8279
8144
|
if (!this.inSMaskMode) {
|
|
@@ -8393,31 +8258,28 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8393
8258
|
save() {
|
|
8394
8259
|
if (this.inSMaskMode) {
|
|
8395
8260
|
copyCtxState(this.ctx, this.suspendedCtx);
|
|
8396
|
-
this.suspendedCtx.save();
|
|
8397
|
-
} else {
|
|
8398
|
-
this.ctx.save();
|
|
8399
8261
|
}
|
|
8262
|
+
this.ctx.save();
|
|
8400
8263
|
const old = this.current;
|
|
8401
8264
|
this.stateStack.push(old);
|
|
8402
8265
|
this.current = old.clone();
|
|
8403
8266
|
}
|
|
8404
8267
|
restore() {
|
|
8405
|
-
if (this.stateStack.length === 0
|
|
8406
|
-
this.endSMaskMode();
|
|
8407
|
-
}
|
|
8408
|
-
if (this.stateStack.length !== 0) {
|
|
8409
|
-
this.current = this.stateStack.pop();
|
|
8268
|
+
if (this.stateStack.length === 0) {
|
|
8410
8269
|
if (this.inSMaskMode) {
|
|
8411
|
-
this.
|
|
8412
|
-
copyCtxState(this.suspendedCtx, this.ctx);
|
|
8413
|
-
} else {
|
|
8414
|
-
this.ctx.restore();
|
|
8270
|
+
this.endSMaskMode();
|
|
8415
8271
|
}
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8272
|
+
return;
|
|
8273
|
+
}
|
|
8274
|
+
this.current = this.stateStack.pop();
|
|
8275
|
+
this.ctx.restore();
|
|
8276
|
+
if (this.inSMaskMode) {
|
|
8277
|
+
copyCtxState(this.suspendedCtx, this.ctx);
|
|
8420
8278
|
}
|
|
8279
|
+
this.checkSMaskState();
|
|
8280
|
+
this.pendingClip = null;
|
|
8281
|
+
this._cachedScaleForStroking[0] = -1;
|
|
8282
|
+
this._cachedGetSinglePixelWidth = null;
|
|
8421
8283
|
}
|
|
8422
8284
|
transform(a, b, c, d, e, f) {
|
|
8423
8285
|
this.ctx.transform(a, b, c, d, e, f);
|
|
@@ -8425,145 +8287,60 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8425
8287
|
this._cachedGetSinglePixelWidth = null;
|
|
8426
8288
|
}
|
|
8427
8289
|
// Path
|
|
8428
|
-
constructPath(
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
|
|
8435
|
-
const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
|
|
8436
|
-
for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
|
|
8437
|
-
switch (ops[i] | 0) {
|
|
8438
|
-
case OPS.rectangle:
|
|
8439
|
-
x = args[j++];
|
|
8440
|
-
y = args[j++];
|
|
8441
|
-
const width = args[j++];
|
|
8442
|
-
const height = args[j++];
|
|
8443
|
-
const xw = x + width;
|
|
8444
|
-
const yh = y + height;
|
|
8445
|
-
ctx.moveTo(x, y);
|
|
8446
|
-
if (width === 0 || height === 0) {
|
|
8447
|
-
ctx.lineTo(xw, yh);
|
|
8448
|
-
} else {
|
|
8449
|
-
ctx.lineTo(xw, y);
|
|
8450
|
-
ctx.lineTo(xw, yh);
|
|
8451
|
-
ctx.lineTo(x, yh);
|
|
8452
|
-
}
|
|
8453
|
-
if (!isScalingMatrix) {
|
|
8454
|
-
current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
|
|
8455
|
-
}
|
|
8456
|
-
ctx.closePath();
|
|
8457
|
-
break;
|
|
8458
|
-
case OPS.moveTo:
|
|
8459
|
-
x = args[j++];
|
|
8460
|
-
y = args[j++];
|
|
8461
|
-
ctx.moveTo(x, y);
|
|
8462
|
-
if (!isScalingMatrix) {
|
|
8463
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
8464
|
-
}
|
|
8465
|
-
break;
|
|
8466
|
-
case OPS.lineTo:
|
|
8467
|
-
x = args[j++];
|
|
8468
|
-
y = args[j++];
|
|
8469
|
-
ctx.lineTo(x, y);
|
|
8470
|
-
if (!isScalingMatrix) {
|
|
8471
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
8472
|
-
}
|
|
8473
|
-
break;
|
|
8474
|
-
case OPS.curveTo:
|
|
8475
|
-
startX = x;
|
|
8476
|
-
startY = y;
|
|
8477
|
-
x = args[j + 4];
|
|
8478
|
-
y = args[j + 5];
|
|
8479
|
-
ctx.bezierCurveTo(
|
|
8480
|
-
args[j],
|
|
8481
|
-
args[j + 1],
|
|
8482
|
-
args[j + 2],
|
|
8483
|
-
args[j + 3],
|
|
8484
|
-
x,
|
|
8485
|
-
y
|
|
8486
|
-
);
|
|
8487
|
-
current.updateCurvePathMinMax(
|
|
8488
|
-
currentTransform,
|
|
8489
|
-
startX,
|
|
8490
|
-
startY,
|
|
8491
|
-
args[j],
|
|
8492
|
-
args[j + 1],
|
|
8493
|
-
args[j + 2],
|
|
8494
|
-
args[j + 3],
|
|
8495
|
-
x,
|
|
8496
|
-
y,
|
|
8497
|
-
minMaxForBezier
|
|
8498
|
-
);
|
|
8499
|
-
j += 6;
|
|
8500
|
-
break;
|
|
8501
|
-
case OPS.curveTo2:
|
|
8502
|
-
startX = x;
|
|
8503
|
-
startY = y;
|
|
8504
|
-
ctx.bezierCurveTo(
|
|
8505
|
-
x,
|
|
8506
|
-
y,
|
|
8507
|
-
args[j],
|
|
8508
|
-
args[j + 1],
|
|
8509
|
-
args[j + 2],
|
|
8510
|
-
args[j + 3]
|
|
8511
|
-
);
|
|
8512
|
-
current.updateCurvePathMinMax(
|
|
8513
|
-
currentTransform,
|
|
8514
|
-
startX,
|
|
8515
|
-
startY,
|
|
8516
|
-
x,
|
|
8517
|
-
y,
|
|
8518
|
-
args[j],
|
|
8519
|
-
args[j + 1],
|
|
8520
|
-
args[j + 2],
|
|
8521
|
-
args[j + 3],
|
|
8522
|
-
minMaxForBezier
|
|
8523
|
-
);
|
|
8524
|
-
x = args[j + 2];
|
|
8525
|
-
y = args[j + 3];
|
|
8526
|
-
j += 4;
|
|
8527
|
-
break;
|
|
8528
|
-
case OPS.curveTo3:
|
|
8529
|
-
startX = x;
|
|
8530
|
-
startY = y;
|
|
8531
|
-
x = args[j + 2];
|
|
8532
|
-
y = args[j + 3];
|
|
8533
|
-
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
|
|
8534
|
-
current.updateCurvePathMinMax(
|
|
8535
|
-
currentTransform,
|
|
8536
|
-
startX,
|
|
8537
|
-
startY,
|
|
8538
|
-
args[j],
|
|
8539
|
-
args[j + 1],
|
|
8540
|
-
x,
|
|
8541
|
-
y,
|
|
8542
|
-
x,
|
|
8543
|
-
y,
|
|
8544
|
-
minMaxForBezier
|
|
8545
|
-
);
|
|
8546
|
-
j += 4;
|
|
8547
|
-
break;
|
|
8548
|
-
case OPS.closePath:
|
|
8549
|
-
ctx.closePath();
|
|
8550
|
-
break;
|
|
8551
|
-
}
|
|
8290
|
+
constructPath(op, data, minMax) {
|
|
8291
|
+
let [path] = data;
|
|
8292
|
+
if (!minMax) {
|
|
8293
|
+
path || (path = data[0] = new SvgPath2D());
|
|
8294
|
+
this[op](path);
|
|
8295
|
+
return;
|
|
8552
8296
|
}
|
|
8553
|
-
if (
|
|
8554
|
-
|
|
8297
|
+
if (!(path instanceof SvgPath2D)) {
|
|
8298
|
+
const path2d = data[0] = new SvgPath2D();
|
|
8299
|
+
for (let i = 0, ii = path.length; i < ii; ) {
|
|
8300
|
+
switch (path[i++]) {
|
|
8301
|
+
case DrawOPS.moveTo:
|
|
8302
|
+
path2d.moveTo(path[i++], path[i++]);
|
|
8303
|
+
break;
|
|
8304
|
+
case DrawOPS.lineTo:
|
|
8305
|
+
path2d.lineTo(path[i++], path[i++]);
|
|
8306
|
+
break;
|
|
8307
|
+
case DrawOPS.curveTo:
|
|
8308
|
+
path2d.bezierCurveTo(
|
|
8309
|
+
path[i++],
|
|
8310
|
+
path[i++],
|
|
8311
|
+
path[i++],
|
|
8312
|
+
path[i++],
|
|
8313
|
+
path[i++],
|
|
8314
|
+
path[i++]
|
|
8315
|
+
);
|
|
8316
|
+
break;
|
|
8317
|
+
case DrawOPS.closePath:
|
|
8318
|
+
path2d.closePath();
|
|
8319
|
+
break;
|
|
8320
|
+
default:
|
|
8321
|
+
warn(`Unrecognized drawing path operator: ${path[i - 1]}`);
|
|
8322
|
+
break;
|
|
8323
|
+
}
|
|
8324
|
+
}
|
|
8325
|
+
path = path2d;
|
|
8555
8326
|
}
|
|
8556
|
-
|
|
8327
|
+
Util.axialAlignedBoundingBox(
|
|
8328
|
+
minMax,
|
|
8329
|
+
getCurrentTransform(this.ctx),
|
|
8330
|
+
this.current.minMax
|
|
8331
|
+
);
|
|
8332
|
+
this[op](path);
|
|
8557
8333
|
}
|
|
8558
8334
|
closePath() {
|
|
8559
8335
|
this.ctx.closePath();
|
|
8560
8336
|
}
|
|
8561
|
-
stroke(consumePath = true) {
|
|
8337
|
+
stroke(path, consumePath = true) {
|
|
8562
8338
|
const ctx = this.ctx;
|
|
8563
8339
|
const strokeColor = this.current.strokeColor;
|
|
8564
8340
|
ctx.globalAlpha = this.current.strokeAlpha;
|
|
8565
8341
|
if (this.contentVisible) {
|
|
8566
8342
|
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
|
|
8343
|
+
const baseTransform = strokeColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
8567
8344
|
ctx.save();
|
|
8568
8345
|
ctx.strokeStyle = strokeColor.getPattern(
|
|
8569
8346
|
ctx,
|
|
@@ -8571,33 +8348,49 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8571
8348
|
getCurrentTransformInverse(ctx),
|
|
8572
8349
|
PathType.STROKE
|
|
8573
8350
|
);
|
|
8351
|
+
if (baseTransform) {
|
|
8352
|
+
const newPath = new SvgPath2D();
|
|
8353
|
+
newPath.addPath(
|
|
8354
|
+
path,
|
|
8355
|
+
ctx.getTransform().invertSelf().multiplySelf(baseTransform)
|
|
8356
|
+
);
|
|
8357
|
+
path = newPath;
|
|
8358
|
+
}
|
|
8574
8359
|
this.rescaleAndStroke(
|
|
8360
|
+
path,
|
|
8575
8361
|
/* saveRestore */
|
|
8576
8362
|
false
|
|
8577
8363
|
);
|
|
8578
8364
|
ctx.restore();
|
|
8579
8365
|
} else {
|
|
8580
8366
|
this.rescaleAndStroke(
|
|
8367
|
+
path,
|
|
8581
8368
|
/* saveRestore */
|
|
8582
8369
|
true
|
|
8583
8370
|
);
|
|
8584
8371
|
}
|
|
8585
8372
|
}
|
|
8586
8373
|
if (consumePath) {
|
|
8587
|
-
this.consumePath(
|
|
8374
|
+
this.consumePath(
|
|
8375
|
+
path,
|
|
8376
|
+
this.current.getClippedPathBoundingBox(
|
|
8377
|
+
PathType.STROKE,
|
|
8378
|
+
getCurrentTransform(this.ctx)
|
|
8379
|
+
)
|
|
8380
|
+
);
|
|
8588
8381
|
}
|
|
8589
8382
|
ctx.globalAlpha = this.current.fillAlpha;
|
|
8590
8383
|
}
|
|
8591
|
-
closeStroke() {
|
|
8592
|
-
this.
|
|
8593
|
-
this.stroke();
|
|
8384
|
+
closeStroke(path) {
|
|
8385
|
+
this.stroke(path);
|
|
8594
8386
|
}
|
|
8595
|
-
fill(consumePath = true) {
|
|
8387
|
+
fill(path, consumePath = true) {
|
|
8596
8388
|
const ctx = this.ctx;
|
|
8597
8389
|
const fillColor = this.current.fillColor;
|
|
8598
8390
|
const isPatternFill = this.current.patternFill;
|
|
8599
8391
|
let needRestore = false;
|
|
8600
8392
|
if (isPatternFill) {
|
|
8393
|
+
const baseTransform = fillColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
8601
8394
|
ctx.save();
|
|
8602
8395
|
ctx.fillStyle = fillColor.getPattern(
|
|
8603
8396
|
ctx,
|
|
@@ -8605,48 +8398,57 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8605
8398
|
getCurrentTransformInverse(ctx),
|
|
8606
8399
|
PathType.FILL
|
|
8607
8400
|
);
|
|
8401
|
+
if (baseTransform) {
|
|
8402
|
+
const newPath = new SvgPath2D();
|
|
8403
|
+
newPath.addPath(
|
|
8404
|
+
path,
|
|
8405
|
+
ctx.getTransform().invertSelf().multiplySelf(baseTransform)
|
|
8406
|
+
);
|
|
8407
|
+
path = newPath;
|
|
8408
|
+
}
|
|
8608
8409
|
needRestore = true;
|
|
8609
8410
|
}
|
|
8610
8411
|
const intersect = this.current.getClippedPathBoundingBox();
|
|
8611
8412
|
if (this.contentVisible && intersect !== null) {
|
|
8612
8413
|
if (this.pendingEOFill) {
|
|
8613
|
-
ctx.fill("evenodd");
|
|
8414
|
+
ctx.fill(path, "evenodd");
|
|
8614
8415
|
this.pendingEOFill = false;
|
|
8615
8416
|
} else {
|
|
8616
|
-
ctx.fill();
|
|
8417
|
+
ctx.fill(path);
|
|
8617
8418
|
}
|
|
8618
8419
|
}
|
|
8619
8420
|
if (needRestore) {
|
|
8620
8421
|
ctx.restore();
|
|
8621
8422
|
}
|
|
8622
8423
|
if (consumePath) {
|
|
8623
|
-
this.consumePath(intersect);
|
|
8424
|
+
this.consumePath(path, intersect);
|
|
8624
8425
|
}
|
|
8625
8426
|
}
|
|
8626
|
-
eoFill() {
|
|
8427
|
+
eoFill(path) {
|
|
8627
8428
|
this.pendingEOFill = true;
|
|
8628
|
-
this.fill();
|
|
8429
|
+
this.fill(path);
|
|
8629
8430
|
}
|
|
8630
|
-
fillStroke() {
|
|
8631
|
-
this.fill(false);
|
|
8632
|
-
this.stroke(false);
|
|
8633
|
-
this.consumePath();
|
|
8431
|
+
fillStroke(path) {
|
|
8432
|
+
this.fill(path, false);
|
|
8433
|
+
this.stroke(path, false);
|
|
8434
|
+
this.consumePath(path);
|
|
8634
8435
|
}
|
|
8635
|
-
eoFillStroke() {
|
|
8436
|
+
eoFillStroke(path) {
|
|
8636
8437
|
this.pendingEOFill = true;
|
|
8637
|
-
this.fillStroke();
|
|
8438
|
+
this.fillStroke(path);
|
|
8638
8439
|
}
|
|
8639
|
-
closeFillStroke() {
|
|
8640
|
-
this.
|
|
8641
|
-
this.fillStroke();
|
|
8440
|
+
closeFillStroke(path) {
|
|
8441
|
+
this.fillStroke(path);
|
|
8642
8442
|
}
|
|
8643
|
-
closeEOFillStroke() {
|
|
8443
|
+
closeEOFillStroke(path) {
|
|
8644
8444
|
this.pendingEOFill = true;
|
|
8645
|
-
this.
|
|
8646
|
-
this.fillStroke();
|
|
8445
|
+
this.fillStroke(path);
|
|
8647
8446
|
}
|
|
8648
|
-
endPath() {
|
|
8649
|
-
this.consumePath();
|
|
8447
|
+
endPath(path) {
|
|
8448
|
+
this.consumePath(path);
|
|
8449
|
+
}
|
|
8450
|
+
rawFillPath(path) {
|
|
8451
|
+
this.ctx.fill(path);
|
|
8650
8452
|
}
|
|
8651
8453
|
// Clipping
|
|
8652
8454
|
clip() {
|
|
@@ -8657,7 +8459,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8657
8459
|
}
|
|
8658
8460
|
// Text
|
|
8659
8461
|
beginText() {
|
|
8660
|
-
this.current.textMatrix =
|
|
8462
|
+
this.current.textMatrix = null;
|
|
8661
8463
|
this.current.textMatrixScale = 1;
|
|
8662
8464
|
this.current.x = this.current.lineX = 0;
|
|
8663
8465
|
this.current.y = this.current.lineY = 0;
|
|
@@ -8666,7 +8468,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8666
8468
|
const paths = this.pendingTextPaths;
|
|
8667
8469
|
const ctx = this.ctx;
|
|
8668
8470
|
if (paths === void 0) {
|
|
8669
|
-
ctx.beginPath();
|
|
8670
8471
|
return;
|
|
8671
8472
|
}
|
|
8672
8473
|
const newPath = new SvgPath2D();
|
|
@@ -8678,7 +8479,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8678
8479
|
);
|
|
8679
8480
|
}
|
|
8680
8481
|
ctx.clip(newPath);
|
|
8681
|
-
ctx.beginPath();
|
|
8682
8482
|
delete this.pendingTextPaths;
|
|
8683
8483
|
}
|
|
8684
8484
|
setCharSpacing(spacing) {
|
|
@@ -8746,11 +8546,12 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8746
8546
|
this.setLeading(-y);
|
|
8747
8547
|
this.moveText(x, y);
|
|
8748
8548
|
}
|
|
8749
|
-
setTextMatrix(
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8549
|
+
setTextMatrix(matrix) {
|
|
8550
|
+
const { current } = this;
|
|
8551
|
+
current.textMatrix = matrix;
|
|
8552
|
+
current.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
|
|
8553
|
+
current.x = current.lineX = 0;
|
|
8554
|
+
current.y = current.lineY = 0;
|
|
8754
8555
|
}
|
|
8755
8556
|
nextLine() {
|
|
8756
8557
|
this.moveText(0, this.current.leading);
|
|
@@ -8797,8 +8598,8 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8797
8598
|
[a, b, c, d, 0, 0],
|
|
8798
8599
|
invPatternTransform
|
|
8799
8600
|
);
|
|
8800
|
-
|
|
8801
|
-
ctx.lineWidth *= Math.max(
|
|
8601
|
+
Util.singularValueDecompose2dScale(transf, XY);
|
|
8602
|
+
ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
|
|
8802
8603
|
ctx.stroke(
|
|
8803
8604
|
__privateMethod(this, _CanvasGraphics_instances, getScaledPath_fn).call(this, path, currentTransform, patternStrokeTransform)
|
|
8804
8605
|
);
|
|
@@ -8868,7 +8669,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8868
8669
|
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
|
8869
8670
|
const simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
|
8870
8671
|
ctx.save();
|
|
8871
|
-
|
|
8672
|
+
if (current.textMatrix) {
|
|
8673
|
+
ctx.transform(...current.textMatrix);
|
|
8674
|
+
}
|
|
8872
8675
|
ctx.translate(current.x, current.y + current.textRise);
|
|
8873
8676
|
if (fontDirection > 0) {
|
|
8874
8677
|
ctx.scale(textHScale, -1);
|
|
@@ -9023,7 +8826,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9023
8826
|
this._cachedScaleForStroking[0] = -1;
|
|
9024
8827
|
this._cachedGetSinglePixelWidth = null;
|
|
9025
8828
|
ctx.save();
|
|
9026
|
-
|
|
8829
|
+
if (current.textMatrix) {
|
|
8830
|
+
ctx.transform(...current.textMatrix);
|
|
8831
|
+
}
|
|
9027
8832
|
ctx.translate(current.x, current.y + current.textRise);
|
|
9028
8833
|
ctx.scale(textHScale, fontDirection);
|
|
9029
8834
|
for (i = 0; i < glyphsLength; ++i) {
|
|
@@ -9038,37 +8843,34 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9038
8843
|
const operatorList = font.charProcOperatorList[glyph.operatorListId];
|
|
9039
8844
|
if (!operatorList) {
|
|
9040
8845
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
|
9041
|
-
|
|
9042
|
-
}
|
|
9043
|
-
if (this.contentVisible) {
|
|
9044
|
-
this.processingType3 = glyph;
|
|
8846
|
+
} else if (this.contentVisible) {
|
|
9045
8847
|
this.save();
|
|
9046
8848
|
ctx.scale(fontSize, fontSize);
|
|
9047
8849
|
ctx.transform(...fontMatrix);
|
|
9048
8850
|
this.executeOperatorList(operatorList);
|
|
9049
8851
|
this.restore();
|
|
9050
8852
|
}
|
|
9051
|
-
const
|
|
9052
|
-
|
|
8853
|
+
const p = [glyph.width, 0];
|
|
8854
|
+
Util.applyTransform(p, fontMatrix);
|
|
8855
|
+
width = p[0] * fontSize + spacing;
|
|
9053
8856
|
ctx.translate(width, 0);
|
|
9054
8857
|
current.x += width * textHScale;
|
|
9055
8858
|
}
|
|
9056
8859
|
ctx.restore();
|
|
9057
|
-
this.processingType3 = null;
|
|
9058
8860
|
}
|
|
9059
8861
|
// Type3 fonts
|
|
9060
8862
|
setCharWidth(xWidth, yWidth) {
|
|
9061
8863
|
}
|
|
9062
8864
|
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
9063
|
-
|
|
9064
|
-
|
|
8865
|
+
const clip = new SvgPath2D();
|
|
8866
|
+
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
8867
|
+
this.ctx.clip(clip);
|
|
9065
8868
|
this.endPath();
|
|
9066
8869
|
}
|
|
9067
8870
|
// Color
|
|
9068
8871
|
getColorN_Pattern(IR) {
|
|
9069
8872
|
let pattern;
|
|
9070
8873
|
if (IR[0] === "TilingPattern") {
|
|
9071
|
-
const color = IR[1];
|
|
9072
8874
|
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
|
9073
8875
|
const canvasGraphicsFactory = {
|
|
9074
8876
|
createCanvasGraphics: (ctx) => new _CanvasGraphics(
|
|
@@ -9085,7 +8887,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9085
8887
|
};
|
|
9086
8888
|
pattern = new TilingPattern(
|
|
9087
8889
|
IR,
|
|
9088
|
-
color,
|
|
9089
8890
|
this.ctx,
|
|
9090
8891
|
canvasGraphicsFactory,
|
|
9091
8892
|
baseTransform
|
|
@@ -9152,10 +8953,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9152
8953
|
const inv = getCurrentTransformInverse(ctx);
|
|
9153
8954
|
if (inv) {
|
|
9154
8955
|
const { width, height } = ctx.canvas;
|
|
9155
|
-
const
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
);
|
|
8956
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
8957
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], inv, minMax);
|
|
8958
|
+
const [x0, y0, x1, y1] = minMax;
|
|
9159
8959
|
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
|
|
9160
8960
|
} else {
|
|
9161
8961
|
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
|
|
@@ -9181,11 +8981,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9181
8981
|
}
|
|
9182
8982
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
9183
8983
|
if (bbox) {
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
8984
|
+
Util.axialAlignedBoundingBox(
|
|
8985
|
+
bbox,
|
|
8986
|
+
this.baseTransform,
|
|
8987
|
+
this.current.minMax
|
|
8988
|
+
);
|
|
8989
|
+
const [x0, y0, x1, y1] = bbox;
|
|
8990
|
+
const clip = new SvgPath2D();
|
|
8991
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
8992
|
+
this.ctx.clip(clip);
|
|
9189
8993
|
this.endPath();
|
|
9190
8994
|
}
|
|
9191
8995
|
}
|
|
@@ -9219,9 +9023,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9219
9023
|
if (!group.bbox) {
|
|
9220
9024
|
throw new Error("Bounding box is required.");
|
|
9221
9025
|
}
|
|
9222
|
-
let bounds =
|
|
9026
|
+
let bounds = MIN_MAX_INIT.slice();
|
|
9027
|
+
Util.axialAlignedBoundingBox(
|
|
9223
9028
|
group.bbox,
|
|
9224
|
-
getCurrentTransform(currentCtx)
|
|
9029
|
+
getCurrentTransform(currentCtx),
|
|
9030
|
+
bounds
|
|
9225
9031
|
);
|
|
9226
9032
|
const canvasBounds = [
|
|
9227
9033
|
0,
|
|
@@ -9247,6 +9053,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9247
9053
|
const groupCtx = scratchCanvas.context;
|
|
9248
9054
|
groupCtx.translate(-offsetX, -offsetY);
|
|
9249
9055
|
groupCtx.transform(...currentTransform);
|
|
9056
|
+
let clip = new SvgPath2D();
|
|
9057
|
+
const [x0, y0, x1, y1] = group.bbox;
|
|
9058
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
9059
|
+
if (group.matrix) {
|
|
9060
|
+
const path = new SvgPath2D();
|
|
9061
|
+
path.addPath(clip, new DOMMatrix(group.matrix));
|
|
9062
|
+
clip = path;
|
|
9063
|
+
}
|
|
9064
|
+
groupCtx.clip(clip);
|
|
9250
9065
|
if (group.smask) {
|
|
9251
9066
|
this.smaskStack.push({
|
|
9252
9067
|
canvas: scratchCanvas.canvas,
|
|
@@ -9292,9 +9107,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9292
9107
|
this.restore();
|
|
9293
9108
|
this.ctx.save();
|
|
9294
9109
|
this.ctx.setTransform(...currentMtx);
|
|
9295
|
-
const dirtyBox =
|
|
9110
|
+
const dirtyBox = MIN_MAX_INIT.slice();
|
|
9111
|
+
Util.axialAlignedBoundingBox(
|
|
9296
9112
|
[0, 0, groupCtx.canvas.width, groupCtx.canvas.height],
|
|
9297
|
-
currentMtx
|
|
9113
|
+
currentMtx,
|
|
9114
|
+
dirtyBox
|
|
9298
9115
|
);
|
|
9299
9116
|
this.ctx.drawImage(groupCtx.canvas, 0, 0);
|
|
9300
9117
|
this.ctx.restore();
|
|
@@ -9320,9 +9137,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9320
9137
|
rect[0] = rect[1] = 0;
|
|
9321
9138
|
rect[2] = width;
|
|
9322
9139
|
rect[3] = height;
|
|
9323
|
-
|
|
9324
|
-
getCurrentTransform(this.ctx)
|
|
9325
|
-
);
|
|
9140
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);
|
|
9326
9141
|
const { viewportScale } = this;
|
|
9327
9142
|
const canvasWidth = Math.ceil(
|
|
9328
9143
|
width * this.outputScaleX * viewportScale
|
|
@@ -9339,14 +9154,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9339
9154
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
9340
9155
|
this.ctx = context;
|
|
9341
9156
|
this.ctx.save();
|
|
9342
|
-
this.ctx.setTransform(
|
|
9157
|
+
this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);
|
|
9343
9158
|
resetCtxToDefault(this.ctx);
|
|
9344
9159
|
} else {
|
|
9345
9160
|
resetCtxToDefault(this.ctx);
|
|
9346
9161
|
this.endPath();
|
|
9347
|
-
|
|
9348
|
-
|
|
9349
|
-
this.ctx.
|
|
9162
|
+
const clip = new SvgPath2D();
|
|
9163
|
+
clip.rect(rect[0], rect[1], width, height);
|
|
9164
|
+
this.ctx.clip(clip);
|
|
9350
9165
|
}
|
|
9351
9166
|
}
|
|
9352
9167
|
this.current = new CanvasExtraState(
|
|
@@ -9373,16 +9188,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9373
9188
|
img = this.getObject(img.data, img);
|
|
9374
9189
|
img.count = count;
|
|
9375
9190
|
const ctx = this.ctx;
|
|
9376
|
-
const glyph = this.processingType3;
|
|
9377
|
-
if (glyph) {
|
|
9378
|
-
if (glyph.compiled === void 0) {
|
|
9379
|
-
glyph.compiled = compileType3Glyph(img);
|
|
9380
|
-
}
|
|
9381
|
-
if (glyph.compiled) {
|
|
9382
|
-
glyph.compiled(ctx);
|
|
9383
|
-
return;
|
|
9384
|
-
}
|
|
9385
|
-
}
|
|
9386
9191
|
const mask = this._createMaskCanvas(img);
|
|
9387
9192
|
const maskCanvas = mask.canvas;
|
|
9388
9193
|
ctx.save();
|
|
@@ -9418,8 +9223,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9418
9223
|
positions[i],
|
|
9419
9224
|
positions[i + 1]
|
|
9420
9225
|
]);
|
|
9421
|
-
|
|
9422
|
-
ctx.drawImage(mask.canvas, x, y);
|
|
9226
|
+
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
9423
9227
|
}
|
|
9424
9228
|
ctx.restore();
|
|
9425
9229
|
this.compose();
|
|
@@ -9536,11 +9340,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9536
9340
|
const height = imgData.height;
|
|
9537
9341
|
const ctx = this.ctx;
|
|
9538
9342
|
this.save();
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
ctx.filter = "none";
|
|
9543
|
-
}
|
|
9343
|
+
const { filter } = ctx;
|
|
9344
|
+
if (filter !== "none" && filter !== "") {
|
|
9345
|
+
ctx.filter = "none";
|
|
9544
9346
|
}
|
|
9545
9347
|
ctx.scale(1 / width, -1 / height);
|
|
9546
9348
|
let imgToPaint;
|
|
@@ -9656,7 +9458,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9656
9458
|
endCompat() {
|
|
9657
9459
|
}
|
|
9658
9460
|
// Helper functions
|
|
9659
|
-
consumePath(clipBox) {
|
|
9461
|
+
consumePath(path, clipBox) {
|
|
9660
9462
|
const isEmpty = this.current.isEmptyClip();
|
|
9661
9463
|
if (this.pendingClip) {
|
|
9662
9464
|
this.current.updateClipFromPath();
|
|
@@ -9668,15 +9470,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9668
9470
|
if (this.pendingClip) {
|
|
9669
9471
|
if (!isEmpty) {
|
|
9670
9472
|
if (this.pendingClip === EO_CLIP) {
|
|
9671
|
-
ctx.clip("evenodd");
|
|
9473
|
+
ctx.clip(path, "evenodd");
|
|
9672
9474
|
} else {
|
|
9673
|
-
ctx.clip();
|
|
9475
|
+
ctx.clip(path);
|
|
9674
9476
|
}
|
|
9675
9477
|
}
|
|
9676
9478
|
this.pendingClip = null;
|
|
9677
9479
|
}
|
|
9678
9480
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
9679
|
-
ctx.beginPath();
|
|
9680
9481
|
}
|
|
9681
9482
|
getSinglePixelWidth() {
|
|
9682
9483
|
if (!this._cachedGetSinglePixelWidth) {
|
|
@@ -9736,13 +9537,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9736
9537
|
}
|
|
9737
9538
|
// Rescale before stroking in order to have a final lineWidth
|
|
9738
9539
|
// with both thicknesses greater or equal to 1.
|
|
9739
|
-
rescaleAndStroke(saveRestore) {
|
|
9740
|
-
const {
|
|
9741
|
-
|
|
9540
|
+
rescaleAndStroke(path, saveRestore) {
|
|
9541
|
+
const {
|
|
9542
|
+
ctx,
|
|
9543
|
+
current: { lineWidth }
|
|
9544
|
+
} = this;
|
|
9742
9545
|
const [scaleX, scaleY] = this.getScaleForStroking();
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
ctx.stroke();
|
|
9546
|
+
if (scaleX === scaleY) {
|
|
9547
|
+
ctx.lineWidth = (lineWidth || 1) * scaleX;
|
|
9548
|
+
ctx.stroke(path);
|
|
9746
9549
|
return;
|
|
9747
9550
|
}
|
|
9748
9551
|
const dashes = ctx.getLineDash();
|
|
@@ -9750,12 +9553,17 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9750
9553
|
ctx.save();
|
|
9751
9554
|
}
|
|
9752
9555
|
ctx.scale(scaleX, scaleY);
|
|
9556
|
+
SCALE_MATRIX.a = 1 / scaleX;
|
|
9557
|
+
SCALE_MATRIX.d = 1 / scaleY;
|
|
9558
|
+
const newPath = new SvgPath2D();
|
|
9559
|
+
newPath.addPath(path, SCALE_MATRIX);
|
|
9753
9560
|
if (dashes.length > 0) {
|
|
9754
9561
|
const scale = Math.max(scaleX, scaleY);
|
|
9755
9562
|
ctx.setLineDash(dashes.map((x) => x / scale));
|
|
9756
9563
|
ctx.lineDashOffset /= scale;
|
|
9757
9564
|
}
|
|
9758
|
-
ctx.
|
|
9565
|
+
ctx.lineWidth = lineWidth || 1;
|
|
9566
|
+
ctx.stroke(newPath);
|
|
9759
9567
|
if (saveRestore) {
|
|
9760
9568
|
ctx.restore();
|
|
9761
9569
|
}
|
|
@@ -11458,7 +11266,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11458
11266
|
throw new Error('No "textContentSource" parameter specified.');
|
|
11459
11267
|
}
|
|
11460
11268
|
__privateSet(this, _container3, __privateSet(this, _rootContainer, container));
|
|
11461
|
-
__privateSet(this, _scale, viewport.scale *
|
|
11269
|
+
__privateSet(this, _scale, viewport.scale * OutputScale.pixelRatio);
|
|
11462
11270
|
__privateSet(this, _rotation, viewport.rotation);
|
|
11463
11271
|
__privateSet(this, _layoutTextParams, {
|
|
11464
11272
|
div: null,
|
|
@@ -11536,7 +11344,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11536
11344
|
*/
|
|
11537
11345
|
update({ viewport, onBefore = null }) {
|
|
11538
11346
|
var _a2;
|
|
11539
|
-
const scale = viewport.scale *
|
|
11347
|
+
const scale = viewport.scale * OutputScale.pixelRatio;
|
|
11540
11348
|
const rotation = viewport.rotation;
|
|
11541
11349
|
if (rotation !== __privateGet(this, _rotation)) {
|
|
11542
11350
|
onBefore?.();
|
|
@@ -11916,6 +11724,7 @@ function getDocument(src = {}) {
|
|
|
11916
11724
|
const cMapUrl = getFactoryUrlProp(src.cMapUrl);
|
|
11917
11725
|
const cMapPacked = src.cMapPacked !== false;
|
|
11918
11726
|
const CMapReaderFactory = src.CMapReaderFactory || (isNodeJS ? NodeCMapReaderFactory : DOMCMapReaderFactory);
|
|
11727
|
+
const iccUrl = getFactoryUrlProp(src.iccUrl);
|
|
11919
11728
|
const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);
|
|
11920
11729
|
const StandardFontDataFactory2 = src.StandardFontDataFactory || (isNodeJS ? NodeStandardFontDataFactory : DOMStandardFontDataFactory);
|
|
11921
11730
|
const wasmUrl = getFactoryUrlProp(src.wasmUrl);
|
|
@@ -11987,6 +11796,7 @@ function getDocument(src = {}) {
|
|
|
11987
11796
|
useWasm,
|
|
11988
11797
|
useWorkerFetch,
|
|
11989
11798
|
cMapUrl,
|
|
11799
|
+
iccUrl,
|
|
11990
11800
|
standardFontDataUrl,
|
|
11991
11801
|
wasmUrl
|
|
11992
11802
|
}
|
|
@@ -12120,19 +11930,54 @@ function getFactoryUrlProp(val) {
|
|
|
12120
11930
|
}
|
|
12121
11931
|
throw new Error(`Invalid factory url: "${val}" must include trailing slash.`);
|
|
12122
11932
|
}
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
11933
|
+
var isRefProxy = (v) => typeof v === "object" && Number.isInteger(v?.num) && v.num >= 0 && Number.isInteger(v?.gen) && v.gen >= 0;
|
|
11934
|
+
var isNameProxy = (v) => typeof v === "object" && typeof v?.name === "string";
|
|
11935
|
+
var isValidExplicitDest = _isValidExplicitDest.bind(
|
|
11936
|
+
null,
|
|
11937
|
+
/* validRef = */
|
|
11938
|
+
isRefProxy,
|
|
11939
|
+
/* validName = */
|
|
11940
|
+
isNameProxy
|
|
11941
|
+
);
|
|
12126
11942
|
var _docId2;
|
|
12127
11943
|
var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
12128
11944
|
constructor() {
|
|
12129
|
-
|
|
12130
|
-
|
|
12131
|
-
|
|
12132
|
-
this
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
11945
|
+
/**
|
|
11946
|
+
* @private
|
|
11947
|
+
*/
|
|
11948
|
+
__publicField(this, "_capability", Promise.withResolvers());
|
|
11949
|
+
/**
|
|
11950
|
+
* @private
|
|
11951
|
+
*/
|
|
11952
|
+
__publicField(this, "_transport", null);
|
|
11953
|
+
/**
|
|
11954
|
+
* @private
|
|
11955
|
+
*/
|
|
11956
|
+
__publicField(this, "_worker", null);
|
|
11957
|
+
/**
|
|
11958
|
+
* Unique identifier for the document loading task.
|
|
11959
|
+
* @type {string}
|
|
11960
|
+
*/
|
|
11961
|
+
__publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask, _docId2)._++}`);
|
|
11962
|
+
/**
|
|
11963
|
+
* Whether the loading task is destroyed or not.
|
|
11964
|
+
* @type {boolean}
|
|
11965
|
+
*/
|
|
11966
|
+
__publicField(this, "destroyed", false);
|
|
11967
|
+
/**
|
|
11968
|
+
* Callback to request a password if a wrong or no password was provided.
|
|
11969
|
+
* The callback receives two parameters: a function that should be called
|
|
11970
|
+
* with the new password, and a reason (see {@link PasswordResponses}).
|
|
11971
|
+
* @type {function}
|
|
11972
|
+
*/
|
|
11973
|
+
__publicField(this, "onPassword", null);
|
|
11974
|
+
/**
|
|
11975
|
+
* Callback to be able to monitor the loading progress of the PDF file
|
|
11976
|
+
* (necessary to implement e.g. a loading bar).
|
|
11977
|
+
* The callback receives an {@link OnProgressParameters} argument.
|
|
11978
|
+
* @type {function}
|
|
11979
|
+
*/
|
|
11980
|
+
__publicField(this, "onProgress", null);
|
|
12136
11981
|
}
|
|
12137
11982
|
/**
|
|
12138
11983
|
* Promise for document loading task completion.
|
|
@@ -12167,6 +12012,15 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
12167
12012
|
this._worker?.destroy();
|
|
12168
12013
|
this._worker = null;
|
|
12169
12014
|
}
|
|
12015
|
+
/**
|
|
12016
|
+
* Attempt to fetch the raw data of the PDF document, when e.g.
|
|
12017
|
+
* - An exception was thrown during document initialization.
|
|
12018
|
+
* - An `onPassword` callback is delaying initialization.
|
|
12019
|
+
* @returns {Promise<Uint8Array>}
|
|
12020
|
+
*/
|
|
12021
|
+
async getData() {
|
|
12022
|
+
return this._transport.getData();
|
|
12023
|
+
}
|
|
12170
12024
|
};
|
|
12171
12025
|
_docId2 = new WeakMap();
|
|
12172
12026
|
__privateAdd(_PDFDocumentLoadingTask, _docId2, 0);
|
|
@@ -13343,6 +13197,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13343
13197
|
}
|
|
13344
13198
|
/**
|
|
13345
13199
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
13200
|
+
* @returns {PDFWorker}
|
|
13346
13201
|
*/
|
|
13347
13202
|
static fromPort(params) {
|
|
13348
13203
|
if (false) {
|
|
@@ -13378,7 +13233,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13378
13233
|
if (__privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13379
13234
|
return __privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get);
|
|
13380
13235
|
}
|
|
13381
|
-
const worker = true ? await import("./worker.js") : await
|
|
13236
|
+
const worker = true ? await import("./worker.js") : await __raw_import__(this.workerSrc);
|
|
13382
13237
|
return worker.WorkerMessageHandler;
|
|
13383
13238
|
};
|
|
13384
13239
|
return shadow(this, "_setupFakeWorkerGlobal", loader());
|
|
@@ -17907,7 +17762,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17907
17762
|
__privateSet(this, _content, `${bufferBefore.join("\n")}${paste}${bufferAfter.join("\n")}`);
|
|
17908
17763
|
__privateMethod(this, _FreeTextEditor_instances, setContent_fn).call(this);
|
|
17909
17764
|
const newRange = new Range();
|
|
17910
|
-
let beforeLength = bufferBefore.
|
|
17765
|
+
let beforeLength = Math.sumPrecise(bufferBefore.map((line) => line.length));
|
|
17911
17766
|
for (const { firstChild } of this.editorDiv.childNodes) {
|
|
17912
17767
|
if (firstChild.nodeType === Node.TEXT_NODE) {
|
|
17913
17768
|
const length = firstChild.nodeValue.length;
|
|
@@ -18757,35 +18612,24 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18757
18612
|
const outline = __privateGet(this, _outline);
|
|
18758
18613
|
let lastX = outline[4];
|
|
18759
18614
|
let lastY = outline[5];
|
|
18760
|
-
|
|
18761
|
-
let minY = lastY;
|
|
18762
|
-
let maxX = lastX;
|
|
18763
|
-
let maxY = lastY;
|
|
18615
|
+
const minMax = [lastX, lastY, lastX, lastY];
|
|
18764
18616
|
let lastPointX = lastX;
|
|
18765
18617
|
let lastPointY = lastY;
|
|
18766
18618
|
const ltrCallback = isLTR ? Math.max : Math.min;
|
|
18767
18619
|
for (let i = 6, ii = outline.length; i < ii; i += 6) {
|
|
18620
|
+
const x = outline[i + 4], y = outline[i + 5];
|
|
18768
18621
|
if (isNaN(outline[i])) {
|
|
18769
|
-
|
|
18770
|
-
|
|
18771
|
-
|
|
18772
|
-
|
|
18773
|
-
if (lastPointY
|
|
18774
|
-
lastPointX =
|
|
18775
|
-
lastPointY = outline[i + 5];
|
|
18776
|
-
} else if (lastPointY === outline[i + 5]) {
|
|
18777
|
-
lastPointX = ltrCallback(lastPointX, outline[i + 4]);
|
|
18622
|
+
Util.pointBoundingBox(x, y, minMax);
|
|
18623
|
+
if (lastPointY < y) {
|
|
18624
|
+
lastPointX = x;
|
|
18625
|
+
lastPointY = y;
|
|
18626
|
+
} else if (lastPointY === y) {
|
|
18627
|
+
lastPointX = ltrCallback(lastPointX, x);
|
|
18778
18628
|
}
|
|
18779
18629
|
} else {
|
|
18780
|
-
const bbox2 =
|
|
18781
|
-
|
|
18782
|
-
|
|
18783
|
-
...outline.slice(i, i + 6)
|
|
18784
|
-
);
|
|
18785
|
-
minX = Math.min(minX, bbox2[0]);
|
|
18786
|
-
minY = Math.min(minY, bbox2[1]);
|
|
18787
|
-
maxX = Math.max(maxX, bbox2[2]);
|
|
18788
|
-
maxY = Math.max(maxY, bbox2[3]);
|
|
18630
|
+
const bbox2 = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18631
|
+
Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6), bbox2);
|
|
18632
|
+
Util.rectBoundingBox(...bbox2, minMax);
|
|
18789
18633
|
if (lastPointY < bbox2[3]) {
|
|
18790
18634
|
lastPointX = bbox2[2];
|
|
18791
18635
|
lastPointY = bbox2[3];
|
|
@@ -18793,14 +18637,14 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18793
18637
|
lastPointX = ltrCallback(lastPointX, bbox2[2]);
|
|
18794
18638
|
}
|
|
18795
18639
|
}
|
|
18796
|
-
lastX =
|
|
18797
|
-
lastY =
|
|
18640
|
+
lastX = x;
|
|
18641
|
+
lastY = y;
|
|
18798
18642
|
}
|
|
18799
18643
|
const bbox = __privateGet(this, _bbox);
|
|
18800
|
-
bbox[0] =
|
|
18801
|
-
bbox[1] =
|
|
18802
|
-
bbox[2] =
|
|
18803
|
-
bbox[3] =
|
|
18644
|
+
bbox[0] = minMax[0] - __privateGet(this, _innerMargin2);
|
|
18645
|
+
bbox[1] = minMax[1] - __privateGet(this, _innerMargin2);
|
|
18646
|
+
bbox[2] = minMax[2] - minMax[0] + 2 * __privateGet(this, _innerMargin2);
|
|
18647
|
+
bbox[3] = minMax[3] - minMax[1] + 2 * __privateGet(this, _innerMargin2);
|
|
18804
18648
|
this.lastPoint = [lastPointX, lastPointY];
|
|
18805
18649
|
};
|
|
18806
18650
|
|
|
@@ -18825,10 +18669,7 @@ var HighlightOutliner = class {
|
|
|
18825
18669
|
__privateAdd(this, _lastPoint);
|
|
18826
18670
|
__privateAdd(this, _verticalEdges, []);
|
|
18827
18671
|
__privateAdd(this, _intervals, []);
|
|
18828
|
-
|
|
18829
|
-
let maxX = -Infinity;
|
|
18830
|
-
let minY = Infinity;
|
|
18831
|
-
let maxY = -Infinity;
|
|
18672
|
+
const minMax = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18832
18673
|
const NUMBER_OF_DIGITS = 4;
|
|
18833
18674
|
const EPSILON = 10 ** -NUMBER_OF_DIGITS;
|
|
18834
18675
|
for (const { x, y, width, height } of boxes) {
|
|
@@ -18839,15 +18680,12 @@ var HighlightOutliner = class {
|
|
|
18839
18680
|
const left = [x1, y1, y2, true];
|
|
18840
18681
|
const right = [x2, y1, y2, false];
|
|
18841
18682
|
__privateGet(this, _verticalEdges).push(left, right);
|
|
18842
|
-
|
|
18843
|
-
|
|
18844
|
-
|
|
18845
|
-
|
|
18846
|
-
|
|
18847
|
-
const
|
|
18848
|
-
const bboxHeight = maxY - minY + 2 * innerMargin;
|
|
18849
|
-
const shiftedMinX = minX - innerMargin;
|
|
18850
|
-
const shiftedMinY = minY - innerMargin;
|
|
18683
|
+
Util.rectBoundingBox(x1, y1, x2, y2, minMax);
|
|
18684
|
+
}
|
|
18685
|
+
const bboxWidth = minMax[2] - minMax[0] + 2 * innerMargin;
|
|
18686
|
+
const bboxHeight = minMax[3] - minMax[1] + 2 * innerMargin;
|
|
18687
|
+
const shiftedMinX = minMax[0] - innerMargin;
|
|
18688
|
+
const shiftedMinY = minMax[1] - innerMargin;
|
|
18851
18689
|
const lastEdge = __privateGet(this, _verticalEdges).at(isLTR ? -1 : -2);
|
|
18852
18690
|
const lastPoint = [lastEdge[0], lastEdge[2]];
|
|
18853
18691
|
for (const edge of __privateGet(this, _verticalEdges)) {
|
|
@@ -19376,6 +19214,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19376
19214
|
__privateSet(this, _methodOfCreation, params.methodOfCreation || "");
|
|
19377
19215
|
__privateSet(this, _text, params.text || "");
|
|
19378
19216
|
this._isDraggable = false;
|
|
19217
|
+
this.defaultL10nId = "pdfjs-editor-highlight-editor";
|
|
19379
19218
|
if (params.highlightId > -1) {
|
|
19380
19219
|
__privateSet(this, _isFreeHighlight, true);
|
|
19381
19220
|
__privateMethod(this, _HighlightEditor_instances, createFreeOutlines_fn).call(this, params);
|
|
@@ -19890,6 +19729,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19890
19729
|
clipPathId
|
|
19891
19730
|
});
|
|
19892
19731
|
__privateMethod(_d = editor, _HighlightEditor_instances, addToDrawLayer_fn).call(_d);
|
|
19732
|
+
editor.rotate(editor.parentRotation);
|
|
19893
19733
|
}
|
|
19894
19734
|
return editor;
|
|
19895
19735
|
}
|
|
@@ -21799,11 +21639,7 @@ computeBbox_fn = function() {
|
|
|
21799
21639
|
for (const { line } of __privateGet(this, _lines2)) {
|
|
21800
21640
|
if (line.length <= 12) {
|
|
21801
21641
|
for (let i = 4, ii = line.length; i < ii; i += 6) {
|
|
21802
|
-
|
|
21803
|
-
bbox[0] = Math.min(bbox[0], x);
|
|
21804
|
-
bbox[1] = Math.min(bbox[1], y);
|
|
21805
|
-
bbox[2] = Math.max(bbox[2], x);
|
|
21806
|
-
bbox[3] = Math.max(bbox[3], y);
|
|
21642
|
+
Util.pointBoundingBox(line[i], line[i + 1], bbox);
|
|
21807
21643
|
}
|
|
21808
21644
|
continue;
|
|
21809
21645
|
}
|
|
@@ -21816,10 +21652,10 @@ computeBbox_fn = function() {
|
|
|
21816
21652
|
}
|
|
21817
21653
|
}
|
|
21818
21654
|
const [marginX, marginY] = __privateMethod(this, _InkDrawOutline_instances, getMarginComponents_fn).call(this);
|
|
21819
|
-
bbox[0] =
|
|
21820
|
-
bbox[1] =
|
|
21821
|
-
bbox[2] =
|
|
21822
|
-
bbox[3] =
|
|
21655
|
+
bbox[0] = MathClamp(bbox[0] - marginX, 0, 1);
|
|
21656
|
+
bbox[1] = MathClamp(bbox[1] - marginY, 0, 1);
|
|
21657
|
+
bbox[2] = MathClamp(bbox[2] + marginX, 0, 1);
|
|
21658
|
+
bbox[3] = MathClamp(bbox[3] + marginY, 0, 1);
|
|
21823
21659
|
bbox[2] -= bbox[0];
|
|
21824
21660
|
bbox[3] -= bbox[1];
|
|
21825
21661
|
};
|
|
@@ -21873,6 +21709,7 @@ var _InkEditor = class _InkEditor extends DrawingEditor {
|
|
|
21873
21709
|
super({ ...params, name: "inkEditor" });
|
|
21874
21710
|
__privateAdd(this, _InkEditor_instances);
|
|
21875
21711
|
this._willKeepAspectRatio = true;
|
|
21712
|
+
this.defaultL10nId = "pdfjs-editor-ink-editor";
|
|
21876
21713
|
}
|
|
21877
21714
|
/** @inheritdoc */
|
|
21878
21715
|
static initialize(l10n, uiManager) {
|
|
@@ -22766,6 +22603,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22766
22603
|
this._willKeepAspectRatio = true;
|
|
22767
22604
|
__privateSet(this, _signatureData, params.signatureData || null);
|
|
22768
22605
|
__privateSet(this, _description, null);
|
|
22606
|
+
this.defaultL10nId = "pdfjs-editor-signature-editor1";
|
|
22769
22607
|
}
|
|
22770
22608
|
/** @inheritdoc */
|
|
22771
22609
|
static initialize(l10n, uiManager) {
|
|
@@ -22829,7 +22667,6 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22829
22667
|
baseY = this.y;
|
|
22830
22668
|
}
|
|
22831
22669
|
super.render();
|
|
22832
|
-
this.div.setAttribute("role", "figure");
|
|
22833
22670
|
if (this._drawId === null) {
|
|
22834
22671
|
if (__privateGet(this, _signatureData)) {
|
|
22835
22672
|
const {
|
|
@@ -22855,6 +22692,10 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22855
22692
|
});
|
|
22856
22693
|
this.addSignature(outline, heightInPage, description, uuid);
|
|
22857
22694
|
} else {
|
|
22695
|
+
this.div.setAttribute(
|
|
22696
|
+
"data-l10n-args",
|
|
22697
|
+
JSON.stringify({ description: "" })
|
|
22698
|
+
);
|
|
22858
22699
|
this.div.hidden = true;
|
|
22859
22700
|
this._uiManager.getSignature(this);
|
|
22860
22701
|
}
|
|
@@ -22921,6 +22762,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22921
22762
|
const { outline } = __privateSet(this, _signatureData, data);
|
|
22922
22763
|
__privateSet(this, _isExtracted, outline instanceof ContourDrawOutline);
|
|
22923
22764
|
__privateSet(this, _description, description);
|
|
22765
|
+
this.div.setAttribute("data-l10n-args", JSON.stringify({ description }));
|
|
22924
22766
|
let drawingOptions;
|
|
22925
22767
|
if (__privateGet(this, _isExtracted)) {
|
|
22926
22768
|
drawingOptions = _SignatureEditor.getDefaultDrawingOptions();
|
|
@@ -23101,6 +22943,7 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23101
22943
|
__privateAdd(this, _hasBeenAddedInUndoStack, false);
|
|
23102
22944
|
__privateSet(this, _bitmapUrl, params.bitmapUrl);
|
|
23103
22945
|
__privateSet(this, _bitmapFile, params.bitmapFile);
|
|
22946
|
+
this.defaultL10nId = "pdfjs-editor-stamp-editor";
|
|
23104
22947
|
}
|
|
23105
22948
|
/** @inheritdoc */
|
|
23106
22949
|
static initialize(l10n, uiManager) {
|
|
@@ -23242,7 +23085,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23242
23085
|
}
|
|
23243
23086
|
super.render();
|
|
23244
23087
|
this.div.hidden = true;
|
|
23245
|
-
this.div.setAttribute("role", "figure");
|
|
23246
23088
|
this.addAltTextButton();
|
|
23247
23089
|
if (!__privateGet(this, _missingCanvas)) {
|
|
23248
23090
|
if (__privateGet(this, _bitmap)) {
|
|
@@ -23390,10 +23232,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23390
23232
|
return { canvas, width, height, imageData };
|
|
23391
23233
|
}
|
|
23392
23234
|
/** @inheritdoc */
|
|
23393
|
-
getImageForAltText() {
|
|
23394
|
-
return __privateGet(this, _canvas);
|
|
23395
|
-
}
|
|
23396
|
-
/** @inheritdoc */
|
|
23397
23235
|
static async deserialize(data, parent, uiManager) {
|
|
23398
23236
|
let initialData = null;
|
|
23399
23237
|
let missingCanvas = false;
|
|
@@ -23709,7 +23547,7 @@ createCanvas_fn = function() {
|
|
|
23709
23547
|
action: "inserted_image"
|
|
23710
23548
|
});
|
|
23711
23549
|
if (__privateGet(this, _bitmapFileName)) {
|
|
23712
|
-
|
|
23550
|
+
this.div.setAttribute("aria-description", __privateGet(this, _bitmapFileName));
|
|
23713
23551
|
}
|
|
23714
23552
|
};
|
|
23715
23553
|
scaleBitmap_fn = function(width, height) {
|
|
@@ -24832,319 +24670,39 @@ if (false) {
|
|
|
24832
24670
|
};
|
|
24833
24671
|
}
|
|
24834
24672
|
|
|
24835
|
-
// src/lib/
|
|
24836
|
-
|
|
24837
|
-
|
|
24838
|
-
|
|
24839
|
-
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
24673
|
+
// src/lib/AnnotationOperatorsList.ts
|
|
24674
|
+
var AnnotationOperatorsList = class {
|
|
24675
|
+
/**
|
|
24676
|
+
* The list of operators to be executed.
|
|
24677
|
+
* @param operatorList The list of operators to be executed.
|
|
24678
|
+
*/
|
|
24679
|
+
constructor(operatorList) {
|
|
24680
|
+
__publicField(this, "map", /* @__PURE__ */ new Map());
|
|
24681
|
+
let currentId = null;
|
|
24682
|
+
let currentList = [];
|
|
24683
|
+
for (const [index, op] of operatorList.fnArray.entries()) {
|
|
24684
|
+
const args = operatorList.argsArray[index];
|
|
24685
|
+
if (op === OPS.beginAnnotation) {
|
|
24686
|
+
currentId = args[0];
|
|
24687
|
+
currentList.push({ fn: op, args });
|
|
24688
|
+
} else if (op === OPS.endAnnotation && currentId) {
|
|
24689
|
+
currentList.push({ fn: op, args });
|
|
24690
|
+
this.map.set(currentId, currentList);
|
|
24691
|
+
currentList = [];
|
|
24692
|
+
} else if (currentId) {
|
|
24693
|
+
currentList.push({ fn: op, args });
|
|
24694
|
+
}
|
|
24843
24695
|
}
|
|
24844
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
24845
24696
|
}
|
|
24846
|
-
|
|
24847
|
-
|
|
24848
|
-
|
|
24849
|
-
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
resolve(reader.result);
|
|
24854
|
-
};
|
|
24855
|
-
reader.readAsDataURL(new Blob([data], { type: "image/png" }));
|
|
24856
|
-
});
|
|
24697
|
+
/**
|
|
24698
|
+
* Get the list of operators for the given annotation id.
|
|
24699
|
+
* @param id The id of the annotation.
|
|
24700
|
+
* @return The list of operators for the given annotation id.
|
|
24701
|
+
*/
|
|
24702
|
+
get(id) {
|
|
24703
|
+
return this.map.get(id) ?? [];
|
|
24857
24704
|
}
|
|
24858
|
-
|
|
24859
|
-
}
|
|
24860
|
-
|
|
24861
|
-
// src/lib/PDFPageProxy.ts
|
|
24862
|
-
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
24863
|
-
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
24864
|
-
const annotations = await getAnnotations.call(this, params);
|
|
24865
|
-
const operatorList = await this.getOperatorList({
|
|
24866
|
-
annotationMode: AnnotationMode.ENABLE_FORMS
|
|
24867
|
-
});
|
|
24868
|
-
const annotationsOperatorList = /* @__PURE__ */ new Map();
|
|
24869
|
-
let currentId = null;
|
|
24870
|
-
let currentList = [];
|
|
24871
|
-
for (const [index, op] of operatorList.fnArray.entries()) {
|
|
24872
|
-
const args = operatorList.argsArray[index];
|
|
24873
|
-
if (op === OPS.beginAnnotation) {
|
|
24874
|
-
currentId = args[0];
|
|
24875
|
-
currentList.push({ fn: op, args });
|
|
24876
|
-
} else if (op === OPS.endAnnotation && currentId) {
|
|
24877
|
-
currentList.push({ fn: op, args });
|
|
24878
|
-
annotationsOperatorList.set(currentId, currentList);
|
|
24879
|
-
currentList = [];
|
|
24880
|
-
} else if (currentId) {
|
|
24881
|
-
currentList.push({ fn: op, args });
|
|
24882
|
-
}
|
|
24883
|
-
}
|
|
24884
|
-
for (const annotation of annotations) {
|
|
24885
|
-
const opList = annotationsOperatorList.get(annotation.id);
|
|
24886
|
-
if (opList) {
|
|
24887
|
-
if (annotation.subtype === "Stamp") {
|
|
24888
|
-
try {
|
|
24889
|
-
const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
|
|
24890
|
-
const scale = 2;
|
|
24891
|
-
const viewport = this.getViewport({ scale });
|
|
24892
|
-
const { context: canvasContext } = canvasFactory.create(
|
|
24893
|
-
viewport.width,
|
|
24894
|
-
viewport.height
|
|
24895
|
-
);
|
|
24896
|
-
const gsx = new CanvasGraphics(
|
|
24897
|
-
canvasContext,
|
|
24898
|
-
this.commonObjs,
|
|
24899
|
-
this.objs,
|
|
24900
|
-
canvasFactory,
|
|
24901
|
-
this.filterFactory,
|
|
24902
|
-
{ optionalContentConfig: null }
|
|
24903
|
-
);
|
|
24904
|
-
gsx.beginDrawing({
|
|
24905
|
-
transform: null,
|
|
24906
|
-
viewport
|
|
24907
|
-
});
|
|
24908
|
-
canvasContext.clearRect(0, 0, viewport.width, viewport.height);
|
|
24909
|
-
gsx.executeOperatorList({
|
|
24910
|
-
fnArray: opList.map((op) => op.fn),
|
|
24911
|
-
argsArray: opList.map((op) => op.args)
|
|
24912
|
-
});
|
|
24913
|
-
const width = annotation.rect[2] - annotation.rect[0];
|
|
24914
|
-
const height = annotation.rect[3] - annotation.rect[1];
|
|
24915
|
-
const { context: croppedCanvasContext } = canvasFactory.create(
|
|
24916
|
-
width * scale,
|
|
24917
|
-
height * scale
|
|
24918
|
-
);
|
|
24919
|
-
croppedCanvasContext.drawImage(
|
|
24920
|
-
canvasContext.canvas,
|
|
24921
|
-
annotation.rect[0] * scale,
|
|
24922
|
-
(this.view[3] - annotation.rect[1] - height) * scale,
|
|
24923
|
-
width * scale,
|
|
24924
|
-
height * scale,
|
|
24925
|
-
0,
|
|
24926
|
-
0,
|
|
24927
|
-
width * scale,
|
|
24928
|
-
height * scale
|
|
24929
|
-
);
|
|
24930
|
-
annotation.graphics = await canvasToData(croppedCanvasContext.canvas);
|
|
24931
|
-
} catch (e) {
|
|
24932
|
-
console.error(e);
|
|
24933
|
-
}
|
|
24934
|
-
} else {
|
|
24935
|
-
let firstStroke = true;
|
|
24936
|
-
let firstFill = true;
|
|
24937
|
-
let currentFillColor = null;
|
|
24938
|
-
let currentLineWidth = null;
|
|
24939
|
-
for (const { fn, args } of opList) {
|
|
24940
|
-
if (fn === OPS.fill) {
|
|
24941
|
-
if (currentFillColor) {
|
|
24942
|
-
annotation.interiorColor = currentFillColor;
|
|
24943
|
-
currentFillColor = null;
|
|
24944
|
-
}
|
|
24945
|
-
firstFill = false;
|
|
24946
|
-
continue;
|
|
24947
|
-
}
|
|
24948
|
-
if (fn === OPS.beginText) {
|
|
24949
|
-
firstFill = false;
|
|
24950
|
-
continue;
|
|
24951
|
-
}
|
|
24952
|
-
if (fn === OPS.stroke) {
|
|
24953
|
-
if (currentLineWidth === null) {
|
|
24954
|
-
annotation.borderStyle.width = 1;
|
|
24955
|
-
}
|
|
24956
|
-
firstStroke = false;
|
|
24957
|
-
currentLineWidth = null;
|
|
24958
|
-
continue;
|
|
24959
|
-
}
|
|
24960
|
-
if (fn === OPS.fillStroke) {
|
|
24961
|
-
if (currentFillColor) {
|
|
24962
|
-
annotation.interiorColor = currentFillColor;
|
|
24963
|
-
currentFillColor = null;
|
|
24964
|
-
}
|
|
24965
|
-
if (currentLineWidth === null) {
|
|
24966
|
-
annotation.borderStyle.width = 1;
|
|
24967
|
-
}
|
|
24968
|
-
firstStroke = false;
|
|
24969
|
-
currentLineWidth = null;
|
|
24970
|
-
break;
|
|
24971
|
-
}
|
|
24972
|
-
if (!firstFill && !firstStroke) {
|
|
24973
|
-
break;
|
|
24974
|
-
}
|
|
24975
|
-
if (fn === OPS.setLineWidth && firstStroke) {
|
|
24976
|
-
currentLineWidth = args[0];
|
|
24977
|
-
annotation.borderStyle.width = currentLineWidth;
|
|
24978
|
-
}
|
|
24979
|
-
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
24980
|
-
if (!annotation.borderStyle.width) {
|
|
24981
|
-
annotation.borderStyle.width = 1;
|
|
24982
|
-
}
|
|
24983
|
-
annotation.color = args;
|
|
24984
|
-
}
|
|
24985
|
-
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
24986
|
-
currentFillColor = args;
|
|
24987
|
-
}
|
|
24988
|
-
if (fn === OPS.setGState) {
|
|
24989
|
-
for (const entry of args[0]) {
|
|
24990
|
-
if (!Array.isArray(entry)) {
|
|
24991
|
-
continue;
|
|
24992
|
-
}
|
|
24993
|
-
if (entry[0] === "ca" && firstFill) {
|
|
24994
|
-
annotation.interiorColorOpacity = entry[1];
|
|
24995
|
-
}
|
|
24996
|
-
if (entry[0] === "CA" && firstStroke) {
|
|
24997
|
-
annotation.borderColorOpacity = entry[1];
|
|
24998
|
-
}
|
|
24999
|
-
}
|
|
25000
|
-
}
|
|
25001
|
-
}
|
|
25002
|
-
}
|
|
25003
|
-
}
|
|
25004
|
-
}
|
|
25005
|
-
return annotations;
|
|
25006
|
-
};
|
|
25007
|
-
|
|
25008
|
-
// src/lib/StandardFontDataFactory.ts
|
|
25009
|
-
var StandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
25010
|
-
constructor() {
|
|
25011
|
-
super({
|
|
25012
|
-
baseUrl: null
|
|
25013
|
-
});
|
|
25014
|
-
}
|
|
25015
|
-
/**
|
|
25016
|
-
* Fetch the corresponding standard font data.
|
|
25017
|
-
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
25018
|
-
*/
|
|
25019
|
-
async fetch({ filename }) {
|
|
25020
|
-
switch (filename) {
|
|
25021
|
-
case "FoxitDingbats.pfb":
|
|
25022
|
-
return import("./FoxitDingbats-65AZ2Z2V.js").then((module) => module.default);
|
|
25023
|
-
case "FoxitFixed.pfb":
|
|
25024
|
-
return import("./FoxitFixed-OZGLVVOQ.js").then(
|
|
25025
|
-
(module) => module.default
|
|
25026
|
-
);
|
|
25027
|
-
case "FoxitFixedBold.pfb":
|
|
25028
|
-
return import("./FoxitFixedBold-37OOYMV7.js").then((module) => module.default);
|
|
25029
|
-
case "FoxitFixedBoldItalic.pfb":
|
|
25030
|
-
return import("./FoxitFixedBoldItalic-XYFHEG2V.js").then((module) => module.default);
|
|
25031
|
-
case "FoxitFixedItalic.pfb":
|
|
25032
|
-
return import("./FoxitFixedItalic-MM7OSGS6.js").then((module) => module.default);
|
|
25033
|
-
case "FoxitSerif.pfb":
|
|
25034
|
-
return import("./FoxitSerif-MLMJQPRP.js").then(
|
|
25035
|
-
(module) => module.default
|
|
25036
|
-
);
|
|
25037
|
-
case "FoxitSerifBold.pfb":
|
|
25038
|
-
return import("./FoxitSerifBold-AC7RJQWJ.js").then((module) => module.default);
|
|
25039
|
-
case "FoxitSerifBoldItalic.pfb":
|
|
25040
|
-
return import("./FoxitSerifBoldItalic-YCQ4CLKE.js").then((module) => module.default);
|
|
25041
|
-
case "FoxitSerifItalic.pfb":
|
|
25042
|
-
return import("./FoxitSerifItalic-CXVTCST4.js").then((module) => module.default);
|
|
25043
|
-
case "FoxitSymbol.pfb":
|
|
25044
|
-
return import("./FoxitSymbol-VUGMZN5C.js").then(
|
|
25045
|
-
(module) => module.default
|
|
25046
|
-
);
|
|
25047
|
-
case "LiberationSans-Bold.ttf":
|
|
25048
|
-
return import("./LiberationSans-Bold-XSHQQBWB.js").then((module) => module.default);
|
|
25049
|
-
case "LiberationSans-BoldItalic.ttf":
|
|
25050
|
-
return import("./LiberationSans-BoldItalic-CTAZRFRL.js").then((module) => module.default);
|
|
25051
|
-
case "LiberationSans-Italic.ttf":
|
|
25052
|
-
return import("./LiberationSans-Italic-WIOTUKLC.js").then((module) => module.default);
|
|
25053
|
-
case "LiberationSans-Regular.ttf":
|
|
25054
|
-
return import("./LiberationSans-Regular-CDMMZL5S.js").then((module) => module.default);
|
|
25055
|
-
}
|
|
25056
|
-
return Uint8Array.from([]);
|
|
25057
|
-
}
|
|
25058
|
-
};
|
|
25059
|
-
|
|
25060
|
-
// src/lib/AnnotationData.ts
|
|
25061
|
-
function isTextAnnotation(annotation) {
|
|
25062
|
-
return annotation.subtype === "Text";
|
|
25063
|
-
}
|
|
25064
|
-
function isLinkAnnotation(annotation) {
|
|
25065
|
-
return annotation.subtype === "Link";
|
|
25066
|
-
}
|
|
25067
|
-
function isFreeTextAnnotation(annotation) {
|
|
25068
|
-
return annotation.subtype === "FreeText";
|
|
25069
|
-
}
|
|
25070
|
-
function isLineAnnotation(annotation) {
|
|
25071
|
-
return annotation.subtype === "Line";
|
|
25072
|
-
}
|
|
25073
|
-
function isSquareAnnotation(annotation) {
|
|
25074
|
-
return annotation.subtype === "Square";
|
|
25075
|
-
}
|
|
25076
|
-
function isCircleAnnotation(annotation) {
|
|
25077
|
-
return annotation.subtype === "Circle";
|
|
25078
|
-
}
|
|
25079
|
-
function isPolygonAnnotation(annotation) {
|
|
25080
|
-
return annotation.subtype === "Polygon";
|
|
25081
|
-
}
|
|
25082
|
-
function isPolylineAnnotation(annotation) {
|
|
25083
|
-
return annotation.subtype === "PolyLine";
|
|
25084
|
-
}
|
|
25085
|
-
function isHighlightAnnotation(annotation) {
|
|
25086
|
-
return annotation.subtype === "Highlight";
|
|
25087
|
-
}
|
|
25088
|
-
function isUnderlineAnnotation(annotation) {
|
|
25089
|
-
return annotation.subtype === "Underline";
|
|
25090
|
-
}
|
|
25091
|
-
function isSquigglyAnnotation(annotation) {
|
|
25092
|
-
return annotation.subtype === "Squiggly";
|
|
25093
|
-
}
|
|
25094
|
-
function isStrikeOutAnnotation(annotation) {
|
|
25095
|
-
return annotation.subtype === "StrikeOut";
|
|
25096
|
-
}
|
|
25097
|
-
function isStampAnnotation(annotation) {
|
|
25098
|
-
return annotation.subtype === "Stamp";
|
|
25099
|
-
}
|
|
25100
|
-
function isCaretAnnotation(annotation) {
|
|
25101
|
-
return annotation.subtype === "Caret";
|
|
25102
|
-
}
|
|
25103
|
-
function isInkAnnotation(annotation) {
|
|
25104
|
-
return annotation.subtype === "Ink";
|
|
25105
|
-
}
|
|
25106
|
-
function isPopupAnnotation(annotation) {
|
|
25107
|
-
return annotation.subtype === "Popup";
|
|
25108
|
-
}
|
|
25109
|
-
function isFileAttachmentAnnotation(annotation) {
|
|
25110
|
-
return annotation.subtype === "FileAttachment";
|
|
25111
|
-
}
|
|
25112
|
-
function isSoundAnnotation(annotation) {
|
|
25113
|
-
return annotation.subtype === "Sound";
|
|
25114
|
-
}
|
|
25115
|
-
function isMovieAnnotation(annotation) {
|
|
25116
|
-
return annotation.subtype === "Movie";
|
|
25117
|
-
}
|
|
25118
|
-
function isWidgetAnnotation(annotation) {
|
|
25119
|
-
return annotation.subtype === "Widget";
|
|
25120
|
-
}
|
|
25121
|
-
function isTextWidgetAnnotation(annotation) {
|
|
25122
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Tx";
|
|
25123
|
-
}
|
|
25124
|
-
function isChoiceWidgetAnnotation(annotation) {
|
|
25125
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Ch";
|
|
25126
|
-
}
|
|
25127
|
-
function isButtonWidgetAnnotation(annotation) {
|
|
25128
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Btn";
|
|
25129
|
-
}
|
|
25130
|
-
function isScreenAnnotation(annotation) {
|
|
25131
|
-
return annotation.subtype === "Screen";
|
|
25132
|
-
}
|
|
25133
|
-
function isPrinterMarkAnnotation(annotation) {
|
|
25134
|
-
return annotation.subtype === "PrinterMark";
|
|
25135
|
-
}
|
|
25136
|
-
function isTrapNetAnnotation(annotation) {
|
|
25137
|
-
return annotation.subtype === "TrapNet";
|
|
25138
|
-
}
|
|
25139
|
-
function isWatermarkAnnotation(annotation) {
|
|
25140
|
-
return annotation.subtype === "Watermark";
|
|
25141
|
-
}
|
|
25142
|
-
function isThreeDAnnotation(annotation) {
|
|
25143
|
-
return annotation.subtype === "3D";
|
|
25144
|
-
}
|
|
25145
|
-
function isRedactAnnotation(annotation) {
|
|
25146
|
-
return annotation.subtype === "Redact";
|
|
25147
|
-
}
|
|
24705
|
+
};
|
|
25148
24706
|
|
|
25149
24707
|
// src/lib/SvgCanvasContext.ts
|
|
25150
24708
|
function parseTransformMatrix(transformString) {
|
|
@@ -25439,19 +24997,33 @@ var SvgCanvasContext = class {
|
|
|
25439
24997
|
this._styleStack.push(this._getStyleState());
|
|
25440
24998
|
this._transformMatrixStack.push(this.getTransform());
|
|
25441
24999
|
}
|
|
25000
|
+
clearRect(x, y, width, height) {
|
|
25001
|
+
if (x !== 0 || y !== 0 || this._width !== width || this._height !== height) {
|
|
25002
|
+
throw new Error("clearRect is not supported in SVG");
|
|
25003
|
+
}
|
|
25004
|
+
this._clearCanvas();
|
|
25005
|
+
}
|
|
25442
25006
|
restore() {
|
|
25443
|
-
|
|
25444
|
-
|
|
25445
|
-
|
|
25446
|
-
|
|
25447
|
-
|
|
25448
|
-
|
|
25007
|
+
if (this._groupStack.length) {
|
|
25008
|
+
const group = this._groupStack.pop();
|
|
25009
|
+
if (!this._isTransformationGroup(this._currentGroup)) {
|
|
25010
|
+
group.children = group.children.filter(
|
|
25011
|
+
(child) => child !== this._currentGroup
|
|
25012
|
+
);
|
|
25013
|
+
group.children.push(...this._currentGroup.children);
|
|
25014
|
+
}
|
|
25015
|
+
this._currentGroup = group;
|
|
25016
|
+
} else {
|
|
25017
|
+
this._currentGroup = this._root;
|
|
25018
|
+
}
|
|
25019
|
+
if (this._styleStack.length) {
|
|
25020
|
+
const state = this._styleStack.pop();
|
|
25021
|
+
this._applyStyleState(state);
|
|
25022
|
+
}
|
|
25023
|
+
if (this._transformMatrixStack.length) {
|
|
25024
|
+
const { a, b, c, d, e, f } = this._transformMatrixStack.pop();
|
|
25025
|
+
this.setTransform(a, b, c, d, e, f);
|
|
25449
25026
|
}
|
|
25450
|
-
this._currentGroup = group;
|
|
25451
|
-
const state = this._styleStack.pop();
|
|
25452
|
-
this._applyStyleState(state);
|
|
25453
|
-
const { a, b, c, d, e, f } = this._transformMatrixStack.pop();
|
|
25454
|
-
this.setTransform(a, b, c, d, e, f);
|
|
25455
25027
|
}
|
|
25456
25028
|
beginPath() {
|
|
25457
25029
|
this._currentPosition = {};
|
|
@@ -25622,8 +25194,25 @@ var SvgCanvasContext = class {
|
|
|
25622
25194
|
);
|
|
25623
25195
|
this._currentPosition = { x: endX, y: endY };
|
|
25624
25196
|
}
|
|
25625
|
-
stroke() {
|
|
25626
|
-
if (
|
|
25197
|
+
stroke(path) {
|
|
25198
|
+
if (path instanceof SvgPath2D) {
|
|
25199
|
+
const d = toCommands(path);
|
|
25200
|
+
if (d && d !== "Z") {
|
|
25201
|
+
const parent = this._currentGroup;
|
|
25202
|
+
const pathElement = {
|
|
25203
|
+
tag: "path",
|
|
25204
|
+
attrs: {
|
|
25205
|
+
d,
|
|
25206
|
+
fill: "none",
|
|
25207
|
+
stroke: "none",
|
|
25208
|
+
"stroke-width": "0"
|
|
25209
|
+
}
|
|
25210
|
+
};
|
|
25211
|
+
this._applyTransformation(pathElement);
|
|
25212
|
+
this._applyStyle(pathElement, "stroke");
|
|
25213
|
+
parent.children.push(pathElement);
|
|
25214
|
+
}
|
|
25215
|
+
} else if (this._currentElement) {
|
|
25627
25216
|
this._applyStyle(this._currentElement, "stroke");
|
|
25628
25217
|
}
|
|
25629
25218
|
}
|
|
@@ -25772,6 +25361,9 @@ var SvgCanvasContext = class {
|
|
|
25772
25361
|
const fillRuleValue = fillRule ?? path;
|
|
25773
25362
|
this._currentStyle.fillRule = fillRuleValue;
|
|
25774
25363
|
}
|
|
25364
|
+
if (path instanceof SvgPath2D && path.commands.length === 0) {
|
|
25365
|
+
return;
|
|
25366
|
+
}
|
|
25775
25367
|
const id = `clip_${crypto.randomUUID()}`;
|
|
25776
25368
|
const clipPath = {
|
|
25777
25369
|
tag: "clipPath",
|
|
@@ -25934,7 +25526,6 @@ var SvgCanvasContext = class {
|
|
|
25934
25526
|
}
|
|
25935
25527
|
} else {
|
|
25936
25528
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25937
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25938
25529
|
if (strokeStyle instanceof SvgPattern) {
|
|
25939
25530
|
const path = transformPath(commands, transform);
|
|
25940
25531
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25965,9 +25556,7 @@ var SvgCanvasContext = class {
|
|
|
25965
25556
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25966
25557
|
}
|
|
25967
25558
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25968
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25969
|
-
} else {
|
|
25970
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25559
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25971
25560
|
}
|
|
25972
25561
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25973
25562
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|
|
@@ -26011,21 +25600,13 @@ var SvgCanvasContext = class {
|
|
|
26011
25600
|
parent.children.push(textElement);
|
|
26012
25601
|
}
|
|
26013
25602
|
_clearCanvas() {
|
|
26014
|
-
const rootGroup = this._root.children[1];
|
|
26015
25603
|
this._defs.children = [];
|
|
26016
|
-
this._root.children = this.
|
|
26017
|
-
|
|
26018
|
-
);
|
|
26019
|
-
this._currentGroup = {
|
|
26020
|
-
tag: "g",
|
|
26021
|
-
attrs: {},
|
|
26022
|
-
children: []
|
|
26023
|
-
};
|
|
26024
|
-
this._root.children.push(this._currentGroup);
|
|
25604
|
+
this._root.children = [this._defs];
|
|
25605
|
+
this._currentGroup = this._root;
|
|
26025
25606
|
this._groupStack = [];
|
|
26026
25607
|
}
|
|
26027
25608
|
};
|
|
26028
|
-
async function
|
|
25609
|
+
async function createSvgContext(width, height) {
|
|
26029
25610
|
const canvas = await createCanvas(width, height);
|
|
26030
25611
|
return new SvgCanvasContext(
|
|
26031
25612
|
width,
|
|
@@ -26040,6 +25621,359 @@ async function toSvgNode(ctx) {
|
|
|
26040
25621
|
return ctx.getNode();
|
|
26041
25622
|
}
|
|
26042
25623
|
|
|
25624
|
+
// src/lib/utils.ts
|
|
25625
|
+
async function canvasToData(canvas) {
|
|
25626
|
+
if ("toBlob" in canvas) {
|
|
25627
|
+
const blob = await new Promise(
|
|
25628
|
+
(resolve) => canvas.toBlob((data) => resolve(data))
|
|
25629
|
+
);
|
|
25630
|
+
if (!blob) {
|
|
25631
|
+
throw new Error("Failed to generate graphics");
|
|
25632
|
+
}
|
|
25633
|
+
return new Uint8Array(await blob.arrayBuffer());
|
|
25634
|
+
}
|
|
25635
|
+
const buffer = await canvas.encode("png");
|
|
25636
|
+
return new Uint8Array(buffer);
|
|
25637
|
+
}
|
|
25638
|
+
async function toDataUrl(data, type = "image/png") {
|
|
25639
|
+
if (typeof FileReader !== "undefined") {
|
|
25640
|
+
return new Promise((resolve) => {
|
|
25641
|
+
const reader = new FileReader();
|
|
25642
|
+
reader.onload = () => {
|
|
25643
|
+
resolve(reader.result);
|
|
25644
|
+
};
|
|
25645
|
+
reader.readAsDataURL(new Blob([data], { type }));
|
|
25646
|
+
});
|
|
25647
|
+
}
|
|
25648
|
+
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
25649
|
+
}
|
|
25650
|
+
function makeSerializable(object) {
|
|
25651
|
+
if (typeof object !== "object" || object === null) {
|
|
25652
|
+
return object;
|
|
25653
|
+
}
|
|
25654
|
+
if (object instanceof Int8Array || object instanceof Uint8Array || object instanceof Uint8ClampedArray || object instanceof Int16Array || object instanceof Uint16Array || object instanceof Int32Array || object instanceof Uint32Array || object instanceof Float32Array || object instanceof Float64Array) {
|
|
25655
|
+
return makeSerializable(Array.from(object));
|
|
25656
|
+
}
|
|
25657
|
+
if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
|
|
25658
|
+
return makeSerializable(Array.from(object));
|
|
25659
|
+
}
|
|
25660
|
+
if (Array.isArray(object)) {
|
|
25661
|
+
return object.map(makeSerializable);
|
|
25662
|
+
}
|
|
25663
|
+
return Object.fromEntries(
|
|
25664
|
+
Object.entries(object).map(([key, value]) => [
|
|
25665
|
+
key,
|
|
25666
|
+
makeSerializable(value)
|
|
25667
|
+
])
|
|
25668
|
+
);
|
|
25669
|
+
}
|
|
25670
|
+
|
|
25671
|
+
// src/lib/PDFPageProxy.ts
|
|
25672
|
+
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
25673
|
+
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
25674
|
+
const annotations = await getAnnotations.call(this, params);
|
|
25675
|
+
const operatorList = await this.getOperatorList({
|
|
25676
|
+
annotationMode: AnnotationMode.ENABLE_FORMS
|
|
25677
|
+
});
|
|
25678
|
+
const annotationOperatorsList = new AnnotationOperatorsList(operatorList);
|
|
25679
|
+
for (const annotation of annotations) {
|
|
25680
|
+
const opList = annotationOperatorsList.get(annotation.id);
|
|
25681
|
+
if (opList) {
|
|
25682
|
+
if (annotation.subtype === "Stamp") {
|
|
25683
|
+
try {
|
|
25684
|
+
const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
|
|
25685
|
+
const scale = 2;
|
|
25686
|
+
const viewport = this.getViewport({ scale });
|
|
25687
|
+
const svgContext = await createSvgContext(
|
|
25688
|
+
viewport.width,
|
|
25689
|
+
viewport.height
|
|
25690
|
+
);
|
|
25691
|
+
const gsx = new CanvasGraphics(
|
|
25692
|
+
svgContext,
|
|
25693
|
+
this.commonObjs,
|
|
25694
|
+
this.objs,
|
|
25695
|
+
canvasFactory,
|
|
25696
|
+
this.filterFactory,
|
|
25697
|
+
{ optionalContentConfig: null }
|
|
25698
|
+
);
|
|
25699
|
+
gsx.beginDrawing({
|
|
25700
|
+
transform: null,
|
|
25701
|
+
viewport
|
|
25702
|
+
});
|
|
25703
|
+
svgContext.clearRect(0, 0, viewport.width, viewport.height);
|
|
25704
|
+
gsx.executeOperatorList({
|
|
25705
|
+
fnArray: opList.map((op) => op.fn),
|
|
25706
|
+
argsArray: opList.map((op) => op.args)
|
|
25707
|
+
});
|
|
25708
|
+
const width = annotation.rect[2] - annotation.rect[0];
|
|
25709
|
+
const height = annotation.rect[3] - annotation.rect[1];
|
|
25710
|
+
annotation.graphics = {
|
|
25711
|
+
tag: "svg",
|
|
25712
|
+
attrs: {
|
|
25713
|
+
version: "1.1",
|
|
25714
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25715
|
+
width: `${width}`,
|
|
25716
|
+
height: `${height}`,
|
|
25717
|
+
viewBox: `0 0 ${width * scale} ${height * scale}`,
|
|
25718
|
+
preserveAspectRatio: "none",
|
|
25719
|
+
"xml:space": "preserve"
|
|
25720
|
+
},
|
|
25721
|
+
children: [
|
|
25722
|
+
{
|
|
25723
|
+
tag: "g",
|
|
25724
|
+
attrs: {
|
|
25725
|
+
transform: `translate(-${annotation.rect[0] * scale}, -${(this.view[3] - annotation.rect[1] - height) * scale})`
|
|
25726
|
+
},
|
|
25727
|
+
children: [await toSvgNode(svgContext)]
|
|
25728
|
+
}
|
|
25729
|
+
]
|
|
25730
|
+
};
|
|
25731
|
+
} catch (e) {
|
|
25732
|
+
console.error(e);
|
|
25733
|
+
}
|
|
25734
|
+
} else {
|
|
25735
|
+
switch (annotation.subtype) {
|
|
25736
|
+
case "Square":
|
|
25737
|
+
case "Circle":
|
|
25738
|
+
case "Polygon":
|
|
25739
|
+
case "Line":
|
|
25740
|
+
case "PolyLine":
|
|
25741
|
+
case "FreeText":
|
|
25742
|
+
case "Ink": {
|
|
25743
|
+
let firstStroke = true;
|
|
25744
|
+
let firstFill = true;
|
|
25745
|
+
let firstText = true;
|
|
25746
|
+
let currentFillColor = null;
|
|
25747
|
+
let currentLineWidth = null;
|
|
25748
|
+
for (const { fn, args } of opList) {
|
|
25749
|
+
const finalFn = fn === OPS.constructPath ? args[0] : fn;
|
|
25750
|
+
if (finalFn === OPS.fill) {
|
|
25751
|
+
if (currentFillColor && firstFill) {
|
|
25752
|
+
annotation.interiorColor = currentFillColor;
|
|
25753
|
+
currentFillColor = null;
|
|
25754
|
+
}
|
|
25755
|
+
firstFill = false;
|
|
25756
|
+
continue;
|
|
25757
|
+
}
|
|
25758
|
+
if (fn === OPS.beginText) {
|
|
25759
|
+
if (firstFill) {
|
|
25760
|
+
annotation.interiorColor = null;
|
|
25761
|
+
}
|
|
25762
|
+
firstFill = false;
|
|
25763
|
+
currentFillColor = null;
|
|
25764
|
+
continue;
|
|
25765
|
+
}
|
|
25766
|
+
if (finalFn === OPS.stroke || finalFn === OPS.closeStroke) {
|
|
25767
|
+
if (currentLineWidth === null && firstStroke) {
|
|
25768
|
+
annotation.borderStyle.width = 1;
|
|
25769
|
+
}
|
|
25770
|
+
firstStroke = false;
|
|
25771
|
+
currentLineWidth = null;
|
|
25772
|
+
continue;
|
|
25773
|
+
}
|
|
25774
|
+
if (finalFn === OPS.fillStroke || finalFn === OPS.closeFillStroke) {
|
|
25775
|
+
if (currentFillColor && firstFill) {
|
|
25776
|
+
annotation.interiorColor = currentFillColor;
|
|
25777
|
+
}
|
|
25778
|
+
if (currentLineWidth === null && firstStroke) {
|
|
25779
|
+
annotation.borderStyle.width = 1;
|
|
25780
|
+
}
|
|
25781
|
+
firstFill = false;
|
|
25782
|
+
firstStroke = false;
|
|
25783
|
+
currentFillColor = null;
|
|
25784
|
+
currentLineWidth = null;
|
|
25785
|
+
break;
|
|
25786
|
+
}
|
|
25787
|
+
if (!firstFill && !firstStroke) {
|
|
25788
|
+
break;
|
|
25789
|
+
}
|
|
25790
|
+
if (fn === OPS.setLineWidth && firstStroke) {
|
|
25791
|
+
currentLineWidth = args[0];
|
|
25792
|
+
annotation.borderStyle.width = currentLineWidth;
|
|
25793
|
+
}
|
|
25794
|
+
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
25795
|
+
annotation.color = args;
|
|
25796
|
+
}
|
|
25797
|
+
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
25798
|
+
currentFillColor = args;
|
|
25799
|
+
}
|
|
25800
|
+
if (fn === OPS.setGState) {
|
|
25801
|
+
for (const entry of args[0]) {
|
|
25802
|
+
if (!Array.isArray(entry)) {
|
|
25803
|
+
continue;
|
|
25804
|
+
}
|
|
25805
|
+
if (entry[0] === "ca" && firstFill) {
|
|
25806
|
+
annotation.interiorColorOpacity = entry[1];
|
|
25807
|
+
}
|
|
25808
|
+
if (entry[0] === "CA" && firstStroke) {
|
|
25809
|
+
annotation.borderColorOpacity = entry[1];
|
|
25810
|
+
}
|
|
25811
|
+
}
|
|
25812
|
+
}
|
|
25813
|
+
if (fn === OPS.setFont && firstText) {
|
|
25814
|
+
const fontName = args[0];
|
|
25815
|
+
const font = fontName.startsWith("g_") ? this.commonObjs.get(fontName) : this.objs.get(fontName);
|
|
25816
|
+
if (font) {
|
|
25817
|
+
annotation.defaultAppearanceData.fontName = font.fallbackName;
|
|
25818
|
+
}
|
|
25819
|
+
}
|
|
25820
|
+
if (fn === OPS.endText) {
|
|
25821
|
+
firstText = false;
|
|
25822
|
+
}
|
|
25823
|
+
}
|
|
25824
|
+
if (firstStroke) {
|
|
25825
|
+
annotation.borderStyle.width = 0;
|
|
25826
|
+
}
|
|
25827
|
+
break;
|
|
25828
|
+
}
|
|
25829
|
+
}
|
|
25830
|
+
}
|
|
25831
|
+
}
|
|
25832
|
+
}
|
|
25833
|
+
return makeSerializable(annotations);
|
|
25834
|
+
};
|
|
25835
|
+
|
|
25836
|
+
// src/lib/StandardFontDataFactory.ts
|
|
25837
|
+
var StandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
25838
|
+
constructor() {
|
|
25839
|
+
super({
|
|
25840
|
+
baseUrl: null
|
|
25841
|
+
});
|
|
25842
|
+
}
|
|
25843
|
+
/**
|
|
25844
|
+
* Fetch the corresponding standard font data.
|
|
25845
|
+
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
25846
|
+
*/
|
|
25847
|
+
async fetch({ filename }) {
|
|
25848
|
+
switch (filename) {
|
|
25849
|
+
case "FoxitDingbats.pfb":
|
|
25850
|
+
return import("./FoxitDingbats-65AZ2Z2V.js").then((module) => module.default);
|
|
25851
|
+
case "FoxitFixed.pfb":
|
|
25852
|
+
return import("./FoxitFixed-OZGLVVOQ.js").then(
|
|
25853
|
+
(module) => module.default
|
|
25854
|
+
);
|
|
25855
|
+
case "FoxitFixedBold.pfb":
|
|
25856
|
+
return import("./FoxitFixedBold-37OOYMV7.js").then((module) => module.default);
|
|
25857
|
+
case "FoxitFixedBoldItalic.pfb":
|
|
25858
|
+
return import("./FoxitFixedBoldItalic-XYFHEG2V.js").then((module) => module.default);
|
|
25859
|
+
case "FoxitFixedItalic.pfb":
|
|
25860
|
+
return import("./FoxitFixedItalic-MM7OSGS6.js").then((module) => module.default);
|
|
25861
|
+
case "FoxitSerif.pfb":
|
|
25862
|
+
return import("./FoxitSerif-MLMJQPRP.js").then(
|
|
25863
|
+
(module) => module.default
|
|
25864
|
+
);
|
|
25865
|
+
case "FoxitSerifBold.pfb":
|
|
25866
|
+
return import("./FoxitSerifBold-AC7RJQWJ.js").then((module) => module.default);
|
|
25867
|
+
case "FoxitSerifBoldItalic.pfb":
|
|
25868
|
+
return import("./FoxitSerifBoldItalic-YCQ4CLKE.js").then((module) => module.default);
|
|
25869
|
+
case "FoxitSerifItalic.pfb":
|
|
25870
|
+
return import("./FoxitSerifItalic-CXVTCST4.js").then((module) => module.default);
|
|
25871
|
+
case "FoxitSymbol.pfb":
|
|
25872
|
+
return import("./FoxitSymbol-VUGMZN5C.js").then(
|
|
25873
|
+
(module) => module.default
|
|
25874
|
+
);
|
|
25875
|
+
case "LiberationSans-Bold.ttf":
|
|
25876
|
+
return import("./LiberationSans-Bold-XSHQQBWB.js").then((module) => module.default);
|
|
25877
|
+
case "LiberationSans-BoldItalic.ttf":
|
|
25878
|
+
return import("./LiberationSans-BoldItalic-CTAZRFRL.js").then((module) => module.default);
|
|
25879
|
+
case "LiberationSans-Italic.ttf":
|
|
25880
|
+
return import("./LiberationSans-Italic-WIOTUKLC.js").then((module) => module.default);
|
|
25881
|
+
case "LiberationSans-Regular.ttf":
|
|
25882
|
+
return import("./LiberationSans-Regular-CDMMZL5S.js").then((module) => module.default);
|
|
25883
|
+
}
|
|
25884
|
+
return Uint8Array.from([]);
|
|
25885
|
+
}
|
|
25886
|
+
};
|
|
25887
|
+
|
|
25888
|
+
// src/lib/AnnotationData.ts
|
|
25889
|
+
function isTextAnnotation(annotation) {
|
|
25890
|
+
return annotation.subtype === "Text";
|
|
25891
|
+
}
|
|
25892
|
+
function isLinkAnnotation(annotation) {
|
|
25893
|
+
return annotation.subtype === "Link";
|
|
25894
|
+
}
|
|
25895
|
+
function isFreeTextAnnotation(annotation) {
|
|
25896
|
+
return annotation.subtype === "FreeText";
|
|
25897
|
+
}
|
|
25898
|
+
function isLineAnnotation(annotation) {
|
|
25899
|
+
return annotation.subtype === "Line";
|
|
25900
|
+
}
|
|
25901
|
+
function isSquareAnnotation(annotation) {
|
|
25902
|
+
return annotation.subtype === "Square";
|
|
25903
|
+
}
|
|
25904
|
+
function isCircleAnnotation(annotation) {
|
|
25905
|
+
return annotation.subtype === "Circle";
|
|
25906
|
+
}
|
|
25907
|
+
function isPolygonAnnotation(annotation) {
|
|
25908
|
+
return annotation.subtype === "Polygon";
|
|
25909
|
+
}
|
|
25910
|
+
function isPolylineAnnotation(annotation) {
|
|
25911
|
+
return annotation.subtype === "PolyLine";
|
|
25912
|
+
}
|
|
25913
|
+
function isHighlightAnnotation(annotation) {
|
|
25914
|
+
return annotation.subtype === "Highlight";
|
|
25915
|
+
}
|
|
25916
|
+
function isUnderlineAnnotation(annotation) {
|
|
25917
|
+
return annotation.subtype === "Underline";
|
|
25918
|
+
}
|
|
25919
|
+
function isSquigglyAnnotation(annotation) {
|
|
25920
|
+
return annotation.subtype === "Squiggly";
|
|
25921
|
+
}
|
|
25922
|
+
function isStrikeOutAnnotation(annotation) {
|
|
25923
|
+
return annotation.subtype === "StrikeOut";
|
|
25924
|
+
}
|
|
25925
|
+
function isStampAnnotation(annotation) {
|
|
25926
|
+
return annotation.subtype === "Stamp";
|
|
25927
|
+
}
|
|
25928
|
+
function isCaretAnnotation(annotation) {
|
|
25929
|
+
return annotation.subtype === "Caret";
|
|
25930
|
+
}
|
|
25931
|
+
function isInkAnnotation(annotation) {
|
|
25932
|
+
return annotation.subtype === "Ink";
|
|
25933
|
+
}
|
|
25934
|
+
function isPopupAnnotation(annotation) {
|
|
25935
|
+
return annotation.subtype === "Popup";
|
|
25936
|
+
}
|
|
25937
|
+
function isFileAttachmentAnnotation(annotation) {
|
|
25938
|
+
return annotation.subtype === "FileAttachment";
|
|
25939
|
+
}
|
|
25940
|
+
function isSoundAnnotation(annotation) {
|
|
25941
|
+
return annotation.subtype === "Sound";
|
|
25942
|
+
}
|
|
25943
|
+
function isMovieAnnotation(annotation) {
|
|
25944
|
+
return annotation.subtype === "Movie";
|
|
25945
|
+
}
|
|
25946
|
+
function isWidgetAnnotation(annotation) {
|
|
25947
|
+
return annotation.subtype === "Widget";
|
|
25948
|
+
}
|
|
25949
|
+
function isTextWidgetAnnotation(annotation) {
|
|
25950
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Tx";
|
|
25951
|
+
}
|
|
25952
|
+
function isChoiceWidgetAnnotation(annotation) {
|
|
25953
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Ch";
|
|
25954
|
+
}
|
|
25955
|
+
function isButtonWidgetAnnotation(annotation) {
|
|
25956
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Btn";
|
|
25957
|
+
}
|
|
25958
|
+
function isScreenAnnotation(annotation) {
|
|
25959
|
+
return annotation.subtype === "Screen";
|
|
25960
|
+
}
|
|
25961
|
+
function isPrinterMarkAnnotation(annotation) {
|
|
25962
|
+
return annotation.subtype === "PrinterMark";
|
|
25963
|
+
}
|
|
25964
|
+
function isTrapNetAnnotation(annotation) {
|
|
25965
|
+
return annotation.subtype === "TrapNet";
|
|
25966
|
+
}
|
|
25967
|
+
function isWatermarkAnnotation(annotation) {
|
|
25968
|
+
return annotation.subtype === "Watermark";
|
|
25969
|
+
}
|
|
25970
|
+
function isThreeDAnnotation(annotation) {
|
|
25971
|
+
return annotation.subtype === "3D";
|
|
25972
|
+
}
|
|
25973
|
+
function isRedactAnnotation(annotation) {
|
|
25974
|
+
return annotation.subtype === "Redact";
|
|
25975
|
+
}
|
|
25976
|
+
|
|
26043
25977
|
// src/lib/TextLayer.ts
|
|
26044
25978
|
function isTextNode(node) {
|
|
26045
25979
|
return node.role === "text";
|
|
@@ -26054,17 +25988,6 @@ var MAX_TEXT_DIVS_TO_RENDER2 = 1e5;
|
|
|
26054
25988
|
var DEFAULT_FONT_SIZE3 = 30;
|
|
26055
25989
|
var DEFAULT_FONT_ASCENT = 0.8;
|
|
26056
25990
|
var HYPHEN_REGEX = /-\n+$/;
|
|
26057
|
-
function getDefaultFontFamily(type) {
|
|
26058
|
-
switch (type) {
|
|
26059
|
-
case "serif":
|
|
26060
|
-
return "Liberation Serif";
|
|
26061
|
-
case "monospace":
|
|
26062
|
-
return "Liberation Mono";
|
|
26063
|
-
default:
|
|
26064
|
-
return "Liberation Sans";
|
|
26065
|
-
}
|
|
26066
|
-
}
|
|
26067
|
-
var loadingFontsPromise = null;
|
|
26068
25991
|
async function createTextLayer(page, {
|
|
26069
25992
|
canvasFactory,
|
|
26070
25993
|
viewport = page.getViewport({ scale: 1 }),
|
|
@@ -26204,7 +26127,7 @@ async function createTextLayer(page, {
|
|
|
26204
26127
|
}
|
|
26205
26128
|
if (shouldScaleText) {
|
|
26206
26129
|
if (canvasContext) {
|
|
26207
|
-
canvasContext.font =
|
|
26130
|
+
canvasContext.font = `400 ${fontHeight * outputScale}px 'Liberation Sans'`;
|
|
26208
26131
|
const { width } = canvasContext.measureText(geom.str);
|
|
26209
26132
|
if (width > 0) {
|
|
26210
26133
|
textDiv.scale = (style.vertical ? geom.height : geom.width) * outputScale / width;
|
|
@@ -26217,10 +26140,6 @@ async function createTextLayer(page, {
|
|
|
26217
26140
|
const lang = inputLang || "";
|
|
26218
26141
|
let canvasContext2 = canvasCache.get(lang);
|
|
26219
26142
|
if (!canvasContext2) {
|
|
26220
|
-
if (!loadingFontsPromise) {
|
|
26221
|
-
loadingFontsPromise = loadDefaultFonts();
|
|
26222
|
-
}
|
|
26223
|
-
await loadingFontsPromise;
|
|
26224
26143
|
const { context } = await canvasFactory.create(100, 100);
|
|
26225
26144
|
context.canvas.lang = lang;
|
|
26226
26145
|
canvasContext2 = context;
|
|
@@ -26238,7 +26157,7 @@ async function createTextLayer(page, {
|
|
|
26238
26157
|
}
|
|
26239
26158
|
const savedFont = canvasContext.font;
|
|
26240
26159
|
canvasContext.canvas.width = canvasContext.canvas.height = DEFAULT_FONT_SIZE3;
|
|
26241
|
-
canvasContext.font =
|
|
26160
|
+
canvasContext.font = `400 ${DEFAULT_FONT_SIZE3}px 'Liberation Sans'`;
|
|
26242
26161
|
const metrics = canvasContext.measureText(" ");
|
|
26243
26162
|
let ascent = metrics.fontBoundingBoxAscent;
|
|
26244
26163
|
let descent = Math.abs(metrics.fontBoundingBoxDescent);
|
|
@@ -26510,6 +26429,7 @@ async function createTextLayer(page, {
|
|
|
26510
26429
|
}
|
|
26511
26430
|
return null;
|
|
26512
26431
|
};
|
|
26432
|
+
await loadDefaultFonts();
|
|
26513
26433
|
const reader = textContentSource.getReader();
|
|
26514
26434
|
while (true) {
|
|
26515
26435
|
const { value, done } = await reader.read();
|
|
@@ -26543,12 +26463,14 @@ export {
|
|
|
26543
26463
|
GlobalWorkerOptions,
|
|
26544
26464
|
ImageKind,
|
|
26545
26465
|
InvalidPDFException,
|
|
26466
|
+
MathClamp,
|
|
26546
26467
|
OPS,
|
|
26547
26468
|
OutputScale,
|
|
26548
26469
|
PDFDataRangeTransport,
|
|
26549
26470
|
PDFDateString,
|
|
26550
26471
|
PDFWorker,
|
|
26551
26472
|
PasswordResponses,
|
|
26473
|
+
Path2D,
|
|
26552
26474
|
PermissionFlag,
|
|
26553
26475
|
PixelsPerInch,
|
|
26554
26476
|
RenderingCancelledException,
|
|
@@ -26564,11 +26486,11 @@ export {
|
|
|
26564
26486
|
XfaLayer,
|
|
26565
26487
|
build,
|
|
26566
26488
|
canvasToData,
|
|
26567
|
-
|
|
26489
|
+
createCanvas,
|
|
26490
|
+
createSvgContext,
|
|
26568
26491
|
createTextLayer,
|
|
26569
26492
|
createValidAbsoluteUrl,
|
|
26570
26493
|
fetchData,
|
|
26571
|
-
getDefaultFontFamily,
|
|
26572
26494
|
getDocument,
|
|
26573
26495
|
getFilenameFromUrl,
|
|
26574
26496
|
getPdfFilenameFromUrl,
|
|
@@ -26608,8 +26530,11 @@ export {
|
|
|
26608
26530
|
isThreeDAnnotation,
|
|
26609
26531
|
isTrapNetAnnotation,
|
|
26610
26532
|
isUnderlineAnnotation,
|
|
26533
|
+
isValidExplicitDest,
|
|
26611
26534
|
isWatermarkAnnotation,
|
|
26612
26535
|
isWidgetAnnotation,
|
|
26536
|
+
loadDefaultFonts,
|
|
26537
|
+
makeSerializable,
|
|
26613
26538
|
noContextMenu,
|
|
26614
26539
|
normalizeUnicode,
|
|
26615
26540
|
setLayerDimensions,
|