@chialab/pdfjs-lib 1.0.0-alpha.1 → 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 +907 -998
- package/dist/browser/worker.js +5827 -5389
- package/dist/lib/AnnotationData.d.ts +2 -1
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/SvgCanvasContext.d.ts +2 -1
- 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 +914 -992
- 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,
|
|
@@ -5346,27 +5388,14 @@ async function createCanvas(width, height) {
|
|
|
5346
5388
|
var loadingFontPromise = null;
|
|
5347
5389
|
async function loadDefaultFonts() {
|
|
5348
5390
|
if (loadingFontPromise === null) {
|
|
5349
|
-
loadingFontPromise =
|
|
5350
|
-
import
|
|
5351
|
-
|
|
5352
|
-
)
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
(module) => module.default
|
|
5356
|
-
)
|
|
5357
|
-
]).then(([monoBuffer, sansBuffer, serifBuffer]) => {
|
|
5358
|
-
GlobalFonts.register(
|
|
5359
|
-
Buffer.from(monoBuffer),
|
|
5360
|
-
"Liberation Mono"
|
|
5361
|
-
);
|
|
5362
|
-
GlobalFonts.register(
|
|
5363
|
-
Buffer.from(sansBuffer),
|
|
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,
|
|
5364
5397
|
"Liberation Sans"
|
|
5365
5398
|
);
|
|
5366
|
-
GlobalFonts.register(
|
|
5367
|
-
Buffer.from(serifBuffer),
|
|
5368
|
-
"Liberation Serif"
|
|
5369
|
-
);
|
|
5370
5399
|
});
|
|
5371
5400
|
}
|
|
5372
5401
|
return loadingFontPromise;
|
|
@@ -6705,6 +6734,9 @@ var BaseShadingPattern = class {
|
|
|
6705
6734
|
unreachable("Cannot initialize BaseShadingPattern.");
|
|
6706
6735
|
}
|
|
6707
6736
|
}
|
|
6737
|
+
isModifyingCurrentTransform() {
|
|
6738
|
+
return false;
|
|
6739
|
+
}
|
|
6708
6740
|
getPattern() {
|
|
6709
6741
|
unreachable("Abstract method `getPattern` called.");
|
|
6710
6742
|
}
|
|
@@ -7003,17 +7035,22 @@ var MeshShadingPattern = class extends BaseShadingPattern {
|
|
|
7003
7035
|
scaleY
|
|
7004
7036
|
};
|
|
7005
7037
|
}
|
|
7038
|
+
isModifyingCurrentTransform() {
|
|
7039
|
+
return true;
|
|
7040
|
+
}
|
|
7006
7041
|
getPattern(ctx, owner, inverse, pathType) {
|
|
7007
7042
|
applyBoundingBox(ctx, this._bbox);
|
|
7008
|
-
|
|
7043
|
+
const scale = new Float32Array(2);
|
|
7009
7044
|
if (pathType === PathType.SHADING) {
|
|
7010
|
-
|
|
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;
|
|
7011
7052
|
} else {
|
|
7012
|
-
|
|
7013
|
-
if (this.matrix) {
|
|
7014
|
-
const matrixScale = Util.singularValueDecompose2dScale(this.matrix);
|
|
7015
|
-
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
|
|
7016
|
-
}
|
|
7053
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
7017
7054
|
}
|
|
7018
7055
|
const temporaryPatternCanvas = this._createMeshCanvas(
|
|
7019
7056
|
scale,
|
|
@@ -7055,7 +7092,8 @@ var PaintType = {
|
|
|
7055
7092
|
UNCOLORED: 2
|
|
7056
7093
|
};
|
|
7057
7094
|
var _TilingPattern = class _TilingPattern {
|
|
7058
|
-
constructor(IR,
|
|
7095
|
+
constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {
|
|
7096
|
+
this.color = IR[1];
|
|
7059
7097
|
this.operatorList = IR[2];
|
|
7060
7098
|
this.matrix = IR[3];
|
|
7061
7099
|
this.bbox = IR[4];
|
|
@@ -7063,7 +7101,6 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7063
7101
|
this.ystep = IR[6];
|
|
7064
7102
|
this.paintType = IR[7];
|
|
7065
7103
|
this.tilingType = IR[8];
|
|
7066
|
-
this.color = color;
|
|
7067
7104
|
this.ctx = ctx;
|
|
7068
7105
|
this.canvasGraphicsFactory = canvasGraphicsFactory;
|
|
7069
7106
|
this.baseTransform = baseTransform;
|
|
@@ -7084,12 +7121,12 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7084
7121
|
const x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
|
7085
7122
|
const width = x1 - x0;
|
|
7086
7123
|
const height = y1 - y0;
|
|
7087
|
-
const
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
);
|
|
7091
|
-
const combinedScaleX =
|
|
7092
|
-
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];
|
|
7093
7130
|
let canvasWidth = width, canvasHeight = height, redrawHorizontally = false, redrawVertically = false;
|
|
7094
7131
|
const xScaledStep = Math.ceil(xstep * combinedScaleX);
|
|
7095
7132
|
const yScaledStep = Math.ceil(ystep * combinedScaleY);
|
|
@@ -7205,12 +7242,11 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7205
7242
|
const bboxWidth = x1 - x0;
|
|
7206
7243
|
const bboxHeight = y1 - y0;
|
|
7207
7244
|
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
|
|
7208
|
-
|
|
7209
|
-
x0,
|
|
7210
|
-
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
]);
|
|
7245
|
+
Util.axialAlignedBoundingBox(
|
|
7246
|
+
[x0, y0, x1, y1],
|
|
7247
|
+
getCurrentTransform(graphics.ctx),
|
|
7248
|
+
graphics.current.minMax
|
|
7249
|
+
);
|
|
7214
7250
|
graphics.clip();
|
|
7215
7251
|
graphics.endPath();
|
|
7216
7252
|
}
|
|
@@ -7235,6 +7271,9 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7235
7271
|
throw new FormatError(`Unsupported paint type: ${paintType}`);
|
|
7236
7272
|
}
|
|
7237
7273
|
}
|
|
7274
|
+
isModifyingCurrentTransform() {
|
|
7275
|
+
return false;
|
|
7276
|
+
}
|
|
7238
7277
|
getPattern(ctx, owner, inverse, pathType) {
|
|
7239
7278
|
let matrix = inverse;
|
|
7240
7279
|
if (pathType !== PathType.SHADING) {
|
|
@@ -7267,8 +7306,15 @@ var MIN_FONT_SIZE = 16;
|
|
|
7267
7306
|
var MAX_FONT_SIZE = 100;
|
|
7268
7307
|
var EXECUTION_TIME = 15;
|
|
7269
7308
|
var EXECUTION_STEPS = 10;
|
|
7270
|
-
var MAX_SIZE_TO_COMPILE = 1e3;
|
|
7271
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
|
+
]);
|
|
7272
7318
|
function mirrorContextOperations(ctx, destCtx) {
|
|
7273
7319
|
if (ctx._removeMirroring) {
|
|
7274
7320
|
throw new Error("Context is already forwarding operations.");
|
|
@@ -7306,39 +7352,39 @@ function mirrorContextOperations(ctx, destCtx) {
|
|
|
7306
7352
|
ctx.beginPath = ctx.__originalBeginPath;
|
|
7307
7353
|
delete ctx._removeMirroring;
|
|
7308
7354
|
};
|
|
7309
|
-
ctx.save = function
|
|
7355
|
+
ctx.save = function() {
|
|
7310
7356
|
destCtx.save();
|
|
7311
7357
|
this.__originalSave();
|
|
7312
7358
|
};
|
|
7313
|
-
ctx.restore = function
|
|
7359
|
+
ctx.restore = function() {
|
|
7314
7360
|
destCtx.restore();
|
|
7315
7361
|
this.__originalRestore();
|
|
7316
7362
|
};
|
|
7317
|
-
ctx.translate = function
|
|
7363
|
+
ctx.translate = function(x, y) {
|
|
7318
7364
|
destCtx.translate(x, y);
|
|
7319
7365
|
this.__originalTranslate(x, y);
|
|
7320
7366
|
};
|
|
7321
|
-
ctx.scale = function
|
|
7367
|
+
ctx.scale = function(x, y) {
|
|
7322
7368
|
destCtx.scale(x, y);
|
|
7323
7369
|
this.__originalScale(x, y);
|
|
7324
7370
|
};
|
|
7325
|
-
ctx.transform = function
|
|
7371
|
+
ctx.transform = function(a, b, c, d, e, f) {
|
|
7326
7372
|
destCtx.transform(a, b, c, d, e, f);
|
|
7327
7373
|
this.__originalTransform(a, b, c, d, e, f);
|
|
7328
7374
|
};
|
|
7329
|
-
ctx.setTransform = function
|
|
7375
|
+
ctx.setTransform = function(a, b, c, d, e, f) {
|
|
7330
7376
|
destCtx.setTransform(a, b, c, d, e, f);
|
|
7331
7377
|
this.__originalSetTransform(a, b, c, d, e, f);
|
|
7332
7378
|
};
|
|
7333
|
-
ctx.resetTransform = function
|
|
7379
|
+
ctx.resetTransform = function() {
|
|
7334
7380
|
destCtx.resetTransform();
|
|
7335
7381
|
this.__originalResetTransform();
|
|
7336
7382
|
};
|
|
7337
|
-
ctx.rotate = function
|
|
7383
|
+
ctx.rotate = function(angle) {
|
|
7338
7384
|
destCtx.rotate(angle);
|
|
7339
7385
|
this.__originalRotate(angle);
|
|
7340
7386
|
};
|
|
7341
|
-
ctx.clip = function
|
|
7387
|
+
ctx.clip = function(rule) {
|
|
7342
7388
|
destCtx.clip(rule);
|
|
7343
7389
|
this.__originalClip(rule);
|
|
7344
7390
|
};
|
|
@@ -7429,227 +7475,57 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
7429
7475
|
const scaleY = Math.hypot(c, d);
|
|
7430
7476
|
return [scaleX * destW, scaleY * destH];
|
|
7431
7477
|
}
|
|
7432
|
-
function compileType3Glyph(imgData) {
|
|
7433
|
-
const { width, height } = imgData;
|
|
7434
|
-
if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
7435
|
-
return null;
|
|
7436
|
-
}
|
|
7437
|
-
const POINT_TO_PROCESS_LIMIT = 1e3;
|
|
7438
|
-
const POINT_TYPES = new Uint8Array([
|
|
7439
|
-
0,
|
|
7440
|
-
2,
|
|
7441
|
-
4,
|
|
7442
|
-
0,
|
|
7443
|
-
1,
|
|
7444
|
-
0,
|
|
7445
|
-
5,
|
|
7446
|
-
4,
|
|
7447
|
-
8,
|
|
7448
|
-
10,
|
|
7449
|
-
0,
|
|
7450
|
-
8,
|
|
7451
|
-
0,
|
|
7452
|
-
2,
|
|
7453
|
-
1,
|
|
7454
|
-
0
|
|
7455
|
-
]);
|
|
7456
|
-
const width1 = width + 1;
|
|
7457
|
-
let points = new Uint8Array(width1 * (height + 1));
|
|
7458
|
-
let i, j, j0;
|
|
7459
|
-
const lineSize = width + 7 & ~7;
|
|
7460
|
-
let data = new Uint8Array(lineSize * height), pos = 0;
|
|
7461
|
-
for (const elem of imgData.data) {
|
|
7462
|
-
let mask = 128;
|
|
7463
|
-
while (mask > 0) {
|
|
7464
|
-
data[pos++] = elem & mask ? 0 : 255;
|
|
7465
|
-
mask >>= 1;
|
|
7466
|
-
}
|
|
7467
|
-
}
|
|
7468
|
-
let count = 0;
|
|
7469
|
-
pos = 0;
|
|
7470
|
-
if (data[pos] !== 0) {
|
|
7471
|
-
points[0] = 1;
|
|
7472
|
-
++count;
|
|
7473
|
-
}
|
|
7474
|
-
for (j = 1; j < width; j++) {
|
|
7475
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7476
|
-
points[j] = data[pos] ? 2 : 1;
|
|
7477
|
-
++count;
|
|
7478
|
-
}
|
|
7479
|
-
pos++;
|
|
7480
|
-
}
|
|
7481
|
-
if (data[pos] !== 0) {
|
|
7482
|
-
points[j] = 2;
|
|
7483
|
-
++count;
|
|
7484
|
-
}
|
|
7485
|
-
for (i = 1; i < height; i++) {
|
|
7486
|
-
pos = i * lineSize;
|
|
7487
|
-
j0 = i * width1;
|
|
7488
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7489
|
-
points[j0] = data[pos] ? 1 : 8;
|
|
7490
|
-
++count;
|
|
7491
|
-
}
|
|
7492
|
-
let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
|
7493
|
-
for (j = 1; j < width; j++) {
|
|
7494
|
-
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
|
|
7495
|
-
if (POINT_TYPES[sum]) {
|
|
7496
|
-
points[j0 + j] = POINT_TYPES[sum];
|
|
7497
|
-
++count;
|
|
7498
|
-
}
|
|
7499
|
-
pos++;
|
|
7500
|
-
}
|
|
7501
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7502
|
-
points[j0 + j] = data[pos] ? 2 : 4;
|
|
7503
|
-
++count;
|
|
7504
|
-
}
|
|
7505
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7506
|
-
return null;
|
|
7507
|
-
}
|
|
7508
|
-
}
|
|
7509
|
-
pos = lineSize * (height - 1);
|
|
7510
|
-
j0 = i * width1;
|
|
7511
|
-
if (data[pos] !== 0) {
|
|
7512
|
-
points[j0] = 8;
|
|
7513
|
-
++count;
|
|
7514
|
-
}
|
|
7515
|
-
for (j = 1; j < width; j++) {
|
|
7516
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7517
|
-
points[j0 + j] = data[pos] ? 4 : 8;
|
|
7518
|
-
++count;
|
|
7519
|
-
}
|
|
7520
|
-
pos++;
|
|
7521
|
-
}
|
|
7522
|
-
if (data[pos] !== 0) {
|
|
7523
|
-
points[j0 + j] = 4;
|
|
7524
|
-
++count;
|
|
7525
|
-
}
|
|
7526
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7527
|
-
return null;
|
|
7528
|
-
}
|
|
7529
|
-
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
7530
|
-
const path = new SvgPath2D();
|
|
7531
|
-
for (i = 0; count && i <= height; i++) {
|
|
7532
|
-
let p = i * width1;
|
|
7533
|
-
const end = p + width;
|
|
7534
|
-
while (p < end && !points[p]) {
|
|
7535
|
-
p++;
|
|
7536
|
-
}
|
|
7537
|
-
if (p === end) {
|
|
7538
|
-
continue;
|
|
7539
|
-
}
|
|
7540
|
-
path.moveTo(p % width1, i);
|
|
7541
|
-
const p0 = p;
|
|
7542
|
-
let type = points[p];
|
|
7543
|
-
do {
|
|
7544
|
-
const step = steps[type];
|
|
7545
|
-
do {
|
|
7546
|
-
p += step;
|
|
7547
|
-
} while (!points[p]);
|
|
7548
|
-
const pp = points[p];
|
|
7549
|
-
if (pp !== 5 && pp !== 10) {
|
|
7550
|
-
type = pp;
|
|
7551
|
-
points[p] = 0;
|
|
7552
|
-
} else {
|
|
7553
|
-
type = pp & 51 * type >> 4;
|
|
7554
|
-
points[p] &= type >> 2 | type << 2;
|
|
7555
|
-
}
|
|
7556
|
-
path.lineTo(p % width1, p / width1 | 0);
|
|
7557
|
-
if (!points[p]) {
|
|
7558
|
-
--count;
|
|
7559
|
-
}
|
|
7560
|
-
} while (p0 !== p);
|
|
7561
|
-
--i;
|
|
7562
|
-
}
|
|
7563
|
-
data = null;
|
|
7564
|
-
points = null;
|
|
7565
|
-
const drawOutline = function(c) {
|
|
7566
|
-
c.save();
|
|
7567
|
-
c.scale(1 / width, -1 / height);
|
|
7568
|
-
c.translate(0, -height);
|
|
7569
|
-
c.fill(path);
|
|
7570
|
-
c.beginPath();
|
|
7571
|
-
c.restore();
|
|
7572
|
-
};
|
|
7573
|
-
return drawOutline;
|
|
7574
|
-
}
|
|
7575
7478
|
var CanvasExtraState = class {
|
|
7576
7479
|
constructor(width, height) {
|
|
7577
|
-
|
|
7578
|
-
this
|
|
7579
|
-
this
|
|
7580
|
-
this
|
|
7581
|
-
this
|
|
7582
|
-
this
|
|
7583
|
-
this
|
|
7584
|
-
this
|
|
7585
|
-
|
|
7586
|
-
this
|
|
7587
|
-
this
|
|
7588
|
-
|
|
7589
|
-
this
|
|
7590
|
-
this
|
|
7591
|
-
|
|
7592
|
-
this
|
|
7593
|
-
this
|
|
7594
|
-
this
|
|
7595
|
-
this
|
|
7596
|
-
this
|
|
7597
|
-
|
|
7598
|
-
this
|
|
7599
|
-
this
|
|
7600
|
-
this
|
|
7601
|
-
this
|
|
7602
|
-
|
|
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();
|
|
7603
7513
|
}
|
|
7604
7514
|
clone() {
|
|
7605
7515
|
const clone = Object.create(this);
|
|
7606
7516
|
clone.clipBox = this.clipBox.slice();
|
|
7517
|
+
clone.minMax = this.minMax.slice();
|
|
7607
7518
|
return clone;
|
|
7608
7519
|
}
|
|
7609
|
-
setCurrentPoint(x, y) {
|
|
7610
|
-
this.x = x;
|
|
7611
|
-
this.y = y;
|
|
7612
|
-
}
|
|
7613
|
-
updatePathMinMax(transform, x, y) {
|
|
7614
|
-
[x, y] = Util.applyTransform([x, y], transform);
|
|
7615
|
-
this.minX = Math.min(this.minX, x);
|
|
7616
|
-
this.minY = Math.min(this.minY, y);
|
|
7617
|
-
this.maxX = Math.max(this.maxX, x);
|
|
7618
|
-
this.maxY = Math.max(this.maxY, y);
|
|
7619
|
-
}
|
|
7620
|
-
updateRectMinMax(transform, rect) {
|
|
7621
|
-
const p1 = Util.applyTransform(rect, transform);
|
|
7622
|
-
const p2 = Util.applyTransform(rect.slice(2), transform);
|
|
7623
|
-
const p3 = Util.applyTransform([rect[0], rect[3]], transform);
|
|
7624
|
-
const p4 = Util.applyTransform([rect[2], rect[1]], transform);
|
|
7625
|
-
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
|
7626
|
-
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
|
7627
|
-
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
|
7628
|
-
this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
|
|
7629
|
-
}
|
|
7630
|
-
updateScalingPathMinMax(transform, minMax) {
|
|
7631
|
-
Util.scaleMinMax(transform, minMax);
|
|
7632
|
-
this.minX = Math.min(this.minX, minMax[0]);
|
|
7633
|
-
this.minY = Math.min(this.minY, minMax[1]);
|
|
7634
|
-
this.maxX = Math.max(this.maxX, minMax[2]);
|
|
7635
|
-
this.maxY = Math.max(this.maxY, minMax[3]);
|
|
7636
|
-
}
|
|
7637
|
-
updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
7638
|
-
const box = Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax);
|
|
7639
|
-
if (minMax) {
|
|
7640
|
-
return;
|
|
7641
|
-
}
|
|
7642
|
-
this.updateRectMinMax(transform, box);
|
|
7643
|
-
}
|
|
7644
7520
|
getPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
7645
|
-
const box =
|
|
7521
|
+
const box = this.minMax.slice();
|
|
7646
7522
|
if (pathType === PathType.STROKE) {
|
|
7647
7523
|
if (!transform) {
|
|
7648
7524
|
unreachable("Stroke bounding box must include transform.");
|
|
7649
7525
|
}
|
|
7650
|
-
|
|
7651
|
-
const xStrokePad =
|
|
7652
|
-
const yStrokePad =
|
|
7526
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7527
|
+
const xStrokePad = XY[0] * this.lineWidth / 2;
|
|
7528
|
+
const yStrokePad = XY[1] * this.lineWidth / 2;
|
|
7653
7529
|
box[0] -= xStrokePad;
|
|
7654
7530
|
box[1] -= yStrokePad;
|
|
7655
7531
|
box[2] += xStrokePad;
|
|
@@ -7662,14 +7538,11 @@ var CanvasExtraState = class {
|
|
|
7662
7538
|
this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
|
|
7663
7539
|
}
|
|
7664
7540
|
isEmptyClip() {
|
|
7665
|
-
return this.
|
|
7541
|
+
return this.minMax[0] === Infinity;
|
|
7666
7542
|
}
|
|
7667
7543
|
startNewPathAndClipBox(box) {
|
|
7668
|
-
this.clipBox
|
|
7669
|
-
this.
|
|
7670
|
-
this.minY = Infinity;
|
|
7671
|
-
this.maxX = 0;
|
|
7672
|
-
this.maxY = 0;
|
|
7544
|
+
this.clipBox.set(box, 0);
|
|
7545
|
+
this.minMax.set(MIN_MAX_INIT, 0);
|
|
7673
7546
|
}
|
|
7674
7547
|
getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
7675
7548
|
return Util.intersect(
|
|
@@ -7833,24 +7706,20 @@ function resetCtxToDefault(ctx) {
|
|
|
7833
7706
|
ctx.setLineDash([]);
|
|
7834
7707
|
ctx.lineDashOffset = 0;
|
|
7835
7708
|
}
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
ctx.filter = "none";
|
|
7840
|
-
}
|
|
7709
|
+
const { filter } = ctx;
|
|
7710
|
+
if (filter !== "none" && filter !== "") {
|
|
7711
|
+
ctx.filter = "none";
|
|
7841
7712
|
}
|
|
7842
7713
|
}
|
|
7843
7714
|
function getImageSmoothingEnabled(transform, interpolate) {
|
|
7844
7715
|
if (interpolate) {
|
|
7845
7716
|
return true;
|
|
7846
7717
|
}
|
|
7847
|
-
|
|
7848
|
-
scale[0] = Math.fround(scale[0]);
|
|
7849
|
-
scale[1] = Math.fround(scale[1]);
|
|
7718
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7850
7719
|
const actualScale = Math.fround(
|
|
7851
|
-
|
|
7720
|
+
OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS
|
|
7852
7721
|
);
|
|
7853
|
-
return
|
|
7722
|
+
return XY[0] <= actualScale && XY[1] <= actualScale;
|
|
7854
7723
|
}
|
|
7855
7724
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
7856
7725
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
|
@@ -7875,7 +7744,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7875
7744
|
this.canvasFactory = canvasFactory;
|
|
7876
7745
|
this.filterFactory = filterFactory;
|
|
7877
7746
|
this.groupStack = [];
|
|
7878
|
-
this.processingType3 = null;
|
|
7879
7747
|
this.baseTransform = null;
|
|
7880
7748
|
this.baseTransformStack = [];
|
|
7881
7749
|
this.groupLevel = 0;
|
|
@@ -8096,10 +7964,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8096
7964
|
0
|
|
8097
7965
|
]);
|
|
8098
7966
|
maskToCanvas = Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
|
|
8099
|
-
const
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
);
|
|
7967
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
7968
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], maskToCanvas, minMax);
|
|
7969
|
+
const [minX, minY, maxX, maxY] = minMax;
|
|
8103
7970
|
const drawnWidth = Math.round(maxX - minX) || 1;
|
|
8104
7971
|
const drawnHeight = Math.round(maxY - minY) || 1;
|
|
8105
7972
|
const fillCanvas = this.cachedCanvases.getCanvas(
|
|
@@ -8218,8 +8085,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8218
8085
|
this.current.strokeAlpha = value;
|
|
8219
8086
|
break;
|
|
8220
8087
|
case "ca":
|
|
8221
|
-
this.current.fillAlpha = value;
|
|
8222
|
-
this.ctx.globalAlpha = value;
|
|
8088
|
+
this.ctx.globalAlpha = this.current.fillAlpha = value;
|
|
8223
8089
|
break;
|
|
8224
8090
|
case "BM":
|
|
8225
8091
|
this.ctx.globalCompositeOperation = value;
|
|
@@ -8268,16 +8134,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8268
8134
|
drawnHeight
|
|
8269
8135
|
);
|
|
8270
8136
|
this.suspendedCtx = this.ctx;
|
|
8271
|
-
this.ctx = scratchCanvas.context;
|
|
8272
|
-
|
|
8273
|
-
ctx.setTransform(...getCurrentTransform(this.suspendedCtx));
|
|
8137
|
+
const ctx = this.ctx = scratchCanvas.context;
|
|
8138
|
+
ctx.setTransform(this.suspendedCtx.getTransform());
|
|
8274
8139
|
copyCtxState(this.suspendedCtx, ctx);
|
|
8275
8140
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
8276
|
-
this.setGState([
|
|
8277
|
-
["BM", "source-over"],
|
|
8278
|
-
["ca", 1],
|
|
8279
|
-
["CA", 1]
|
|
8280
|
-
]);
|
|
8141
|
+
this.setGState([["BM", "source-over"]]);
|
|
8281
8142
|
}
|
|
8282
8143
|
endSMaskMode() {
|
|
8283
8144
|
if (!this.inSMaskMode) {
|
|
@@ -8397,31 +8258,28 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8397
8258
|
save() {
|
|
8398
8259
|
if (this.inSMaskMode) {
|
|
8399
8260
|
copyCtxState(this.ctx, this.suspendedCtx);
|
|
8400
|
-
this.suspendedCtx.save();
|
|
8401
|
-
} else {
|
|
8402
|
-
this.ctx.save();
|
|
8403
8261
|
}
|
|
8262
|
+
this.ctx.save();
|
|
8404
8263
|
const old = this.current;
|
|
8405
8264
|
this.stateStack.push(old);
|
|
8406
8265
|
this.current = old.clone();
|
|
8407
8266
|
}
|
|
8408
8267
|
restore() {
|
|
8409
|
-
if (this.stateStack.length === 0
|
|
8410
|
-
this.endSMaskMode();
|
|
8411
|
-
}
|
|
8412
|
-
if (this.stateStack.length !== 0) {
|
|
8413
|
-
this.current = this.stateStack.pop();
|
|
8268
|
+
if (this.stateStack.length === 0) {
|
|
8414
8269
|
if (this.inSMaskMode) {
|
|
8415
|
-
this.
|
|
8416
|
-
copyCtxState(this.suspendedCtx, this.ctx);
|
|
8417
|
-
} else {
|
|
8418
|
-
this.ctx.restore();
|
|
8270
|
+
this.endSMaskMode();
|
|
8419
8271
|
}
|
|
8420
|
-
|
|
8421
|
-
|
|
8422
|
-
|
|
8423
|
-
|
|
8272
|
+
return;
|
|
8273
|
+
}
|
|
8274
|
+
this.current = this.stateStack.pop();
|
|
8275
|
+
this.ctx.restore();
|
|
8276
|
+
if (this.inSMaskMode) {
|
|
8277
|
+
copyCtxState(this.suspendedCtx, this.ctx);
|
|
8424
8278
|
}
|
|
8279
|
+
this.checkSMaskState();
|
|
8280
|
+
this.pendingClip = null;
|
|
8281
|
+
this._cachedScaleForStroking[0] = -1;
|
|
8282
|
+
this._cachedGetSinglePixelWidth = null;
|
|
8425
8283
|
}
|
|
8426
8284
|
transform(a, b, c, d, e, f) {
|
|
8427
8285
|
this.ctx.transform(a, b, c, d, e, f);
|
|
@@ -8429,145 +8287,60 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8429
8287
|
this._cachedGetSinglePixelWidth = null;
|
|
8430
8288
|
}
|
|
8431
8289
|
// Path
|
|
8432
|
-
constructPath(
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8438
|
-
const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
|
|
8439
|
-
const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
|
|
8440
|
-
for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
|
|
8441
|
-
switch (ops[i] | 0) {
|
|
8442
|
-
case OPS.rectangle:
|
|
8443
|
-
x = args[j++];
|
|
8444
|
-
y = args[j++];
|
|
8445
|
-
const width = args[j++];
|
|
8446
|
-
const height = args[j++];
|
|
8447
|
-
const xw = x + width;
|
|
8448
|
-
const yh = y + height;
|
|
8449
|
-
ctx.moveTo(x, y);
|
|
8450
|
-
if (width === 0 || height === 0) {
|
|
8451
|
-
ctx.lineTo(xw, yh);
|
|
8452
|
-
} else {
|
|
8453
|
-
ctx.lineTo(xw, y);
|
|
8454
|
-
ctx.lineTo(xw, yh);
|
|
8455
|
-
ctx.lineTo(x, yh);
|
|
8456
|
-
}
|
|
8457
|
-
if (!isScalingMatrix) {
|
|
8458
|
-
current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
|
|
8459
|
-
}
|
|
8460
|
-
ctx.closePath();
|
|
8461
|
-
break;
|
|
8462
|
-
case OPS.moveTo:
|
|
8463
|
-
x = args[j++];
|
|
8464
|
-
y = args[j++];
|
|
8465
|
-
ctx.moveTo(x, y);
|
|
8466
|
-
if (!isScalingMatrix) {
|
|
8467
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
8468
|
-
}
|
|
8469
|
-
break;
|
|
8470
|
-
case OPS.lineTo:
|
|
8471
|
-
x = args[j++];
|
|
8472
|
-
y = args[j++];
|
|
8473
|
-
ctx.lineTo(x, y);
|
|
8474
|
-
if (!isScalingMatrix) {
|
|
8475
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
8476
|
-
}
|
|
8477
|
-
break;
|
|
8478
|
-
case OPS.curveTo:
|
|
8479
|
-
startX = x;
|
|
8480
|
-
startY = y;
|
|
8481
|
-
x = args[j + 4];
|
|
8482
|
-
y = args[j + 5];
|
|
8483
|
-
ctx.bezierCurveTo(
|
|
8484
|
-
args[j],
|
|
8485
|
-
args[j + 1],
|
|
8486
|
-
args[j + 2],
|
|
8487
|
-
args[j + 3],
|
|
8488
|
-
x,
|
|
8489
|
-
y
|
|
8490
|
-
);
|
|
8491
|
-
current.updateCurvePathMinMax(
|
|
8492
|
-
currentTransform,
|
|
8493
|
-
startX,
|
|
8494
|
-
startY,
|
|
8495
|
-
args[j],
|
|
8496
|
-
args[j + 1],
|
|
8497
|
-
args[j + 2],
|
|
8498
|
-
args[j + 3],
|
|
8499
|
-
x,
|
|
8500
|
-
y,
|
|
8501
|
-
minMaxForBezier
|
|
8502
|
-
);
|
|
8503
|
-
j += 6;
|
|
8504
|
-
break;
|
|
8505
|
-
case OPS.curveTo2:
|
|
8506
|
-
startX = x;
|
|
8507
|
-
startY = y;
|
|
8508
|
-
ctx.bezierCurveTo(
|
|
8509
|
-
x,
|
|
8510
|
-
y,
|
|
8511
|
-
args[j],
|
|
8512
|
-
args[j + 1],
|
|
8513
|
-
args[j + 2],
|
|
8514
|
-
args[j + 3]
|
|
8515
|
-
);
|
|
8516
|
-
current.updateCurvePathMinMax(
|
|
8517
|
-
currentTransform,
|
|
8518
|
-
startX,
|
|
8519
|
-
startY,
|
|
8520
|
-
x,
|
|
8521
|
-
y,
|
|
8522
|
-
args[j],
|
|
8523
|
-
args[j + 1],
|
|
8524
|
-
args[j + 2],
|
|
8525
|
-
args[j + 3],
|
|
8526
|
-
minMaxForBezier
|
|
8527
|
-
);
|
|
8528
|
-
x = args[j + 2];
|
|
8529
|
-
y = args[j + 3];
|
|
8530
|
-
j += 4;
|
|
8531
|
-
break;
|
|
8532
|
-
case OPS.curveTo3:
|
|
8533
|
-
startX = x;
|
|
8534
|
-
startY = y;
|
|
8535
|
-
x = args[j + 2];
|
|
8536
|
-
y = args[j + 3];
|
|
8537
|
-
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
|
|
8538
|
-
current.updateCurvePathMinMax(
|
|
8539
|
-
currentTransform,
|
|
8540
|
-
startX,
|
|
8541
|
-
startY,
|
|
8542
|
-
args[j],
|
|
8543
|
-
args[j + 1],
|
|
8544
|
-
x,
|
|
8545
|
-
y,
|
|
8546
|
-
x,
|
|
8547
|
-
y,
|
|
8548
|
-
minMaxForBezier
|
|
8549
|
-
);
|
|
8550
|
-
j += 4;
|
|
8551
|
-
break;
|
|
8552
|
-
case OPS.closePath:
|
|
8553
|
-
ctx.closePath();
|
|
8554
|
-
break;
|
|
8555
|
-
}
|
|
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;
|
|
8556
8296
|
}
|
|
8557
|
-
if (
|
|
8558
|
-
|
|
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;
|
|
8559
8326
|
}
|
|
8560
|
-
|
|
8327
|
+
Util.axialAlignedBoundingBox(
|
|
8328
|
+
minMax,
|
|
8329
|
+
getCurrentTransform(this.ctx),
|
|
8330
|
+
this.current.minMax
|
|
8331
|
+
);
|
|
8332
|
+
this[op](path);
|
|
8561
8333
|
}
|
|
8562
8334
|
closePath() {
|
|
8563
8335
|
this.ctx.closePath();
|
|
8564
8336
|
}
|
|
8565
|
-
stroke(consumePath = true) {
|
|
8337
|
+
stroke(path, consumePath = true) {
|
|
8566
8338
|
const ctx = this.ctx;
|
|
8567
8339
|
const strokeColor = this.current.strokeColor;
|
|
8568
8340
|
ctx.globalAlpha = this.current.strokeAlpha;
|
|
8569
8341
|
if (this.contentVisible) {
|
|
8570
8342
|
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
|
|
8343
|
+
const baseTransform = strokeColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
8571
8344
|
ctx.save();
|
|
8572
8345
|
ctx.strokeStyle = strokeColor.getPattern(
|
|
8573
8346
|
ctx,
|
|
@@ -8575,33 +8348,49 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8575
8348
|
getCurrentTransformInverse(ctx),
|
|
8576
8349
|
PathType.STROKE
|
|
8577
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
|
+
}
|
|
8578
8359
|
this.rescaleAndStroke(
|
|
8360
|
+
path,
|
|
8579
8361
|
/* saveRestore */
|
|
8580
8362
|
false
|
|
8581
8363
|
);
|
|
8582
8364
|
ctx.restore();
|
|
8583
8365
|
} else {
|
|
8584
8366
|
this.rescaleAndStroke(
|
|
8367
|
+
path,
|
|
8585
8368
|
/* saveRestore */
|
|
8586
8369
|
true
|
|
8587
8370
|
);
|
|
8588
8371
|
}
|
|
8589
8372
|
}
|
|
8590
8373
|
if (consumePath) {
|
|
8591
|
-
this.consumePath(
|
|
8374
|
+
this.consumePath(
|
|
8375
|
+
path,
|
|
8376
|
+
this.current.getClippedPathBoundingBox(
|
|
8377
|
+
PathType.STROKE,
|
|
8378
|
+
getCurrentTransform(this.ctx)
|
|
8379
|
+
)
|
|
8380
|
+
);
|
|
8592
8381
|
}
|
|
8593
8382
|
ctx.globalAlpha = this.current.fillAlpha;
|
|
8594
8383
|
}
|
|
8595
|
-
closeStroke() {
|
|
8596
|
-
this.
|
|
8597
|
-
this.stroke();
|
|
8384
|
+
closeStroke(path) {
|
|
8385
|
+
this.stroke(path);
|
|
8598
8386
|
}
|
|
8599
|
-
fill(consumePath = true) {
|
|
8387
|
+
fill(path, consumePath = true) {
|
|
8600
8388
|
const ctx = this.ctx;
|
|
8601
8389
|
const fillColor = this.current.fillColor;
|
|
8602
8390
|
const isPatternFill = this.current.patternFill;
|
|
8603
8391
|
let needRestore = false;
|
|
8604
8392
|
if (isPatternFill) {
|
|
8393
|
+
const baseTransform = fillColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
8605
8394
|
ctx.save();
|
|
8606
8395
|
ctx.fillStyle = fillColor.getPattern(
|
|
8607
8396
|
ctx,
|
|
@@ -8609,48 +8398,57 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8609
8398
|
getCurrentTransformInverse(ctx),
|
|
8610
8399
|
PathType.FILL
|
|
8611
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
|
+
}
|
|
8612
8409
|
needRestore = true;
|
|
8613
8410
|
}
|
|
8614
8411
|
const intersect = this.current.getClippedPathBoundingBox();
|
|
8615
8412
|
if (this.contentVisible && intersect !== null) {
|
|
8616
8413
|
if (this.pendingEOFill) {
|
|
8617
|
-
ctx.fill("evenodd");
|
|
8414
|
+
ctx.fill(path, "evenodd");
|
|
8618
8415
|
this.pendingEOFill = false;
|
|
8619
8416
|
} else {
|
|
8620
|
-
ctx.fill();
|
|
8417
|
+
ctx.fill(path);
|
|
8621
8418
|
}
|
|
8622
8419
|
}
|
|
8623
8420
|
if (needRestore) {
|
|
8624
8421
|
ctx.restore();
|
|
8625
8422
|
}
|
|
8626
8423
|
if (consumePath) {
|
|
8627
|
-
this.consumePath(intersect);
|
|
8424
|
+
this.consumePath(path, intersect);
|
|
8628
8425
|
}
|
|
8629
8426
|
}
|
|
8630
|
-
eoFill() {
|
|
8427
|
+
eoFill(path) {
|
|
8631
8428
|
this.pendingEOFill = true;
|
|
8632
|
-
this.fill();
|
|
8429
|
+
this.fill(path);
|
|
8633
8430
|
}
|
|
8634
|
-
fillStroke() {
|
|
8635
|
-
this.fill(false);
|
|
8636
|
-
this.stroke(false);
|
|
8637
|
-
this.consumePath();
|
|
8431
|
+
fillStroke(path) {
|
|
8432
|
+
this.fill(path, false);
|
|
8433
|
+
this.stroke(path, false);
|
|
8434
|
+
this.consumePath(path);
|
|
8638
8435
|
}
|
|
8639
|
-
eoFillStroke() {
|
|
8436
|
+
eoFillStroke(path) {
|
|
8640
8437
|
this.pendingEOFill = true;
|
|
8641
|
-
this.fillStroke();
|
|
8438
|
+
this.fillStroke(path);
|
|
8642
8439
|
}
|
|
8643
|
-
closeFillStroke() {
|
|
8644
|
-
this.
|
|
8645
|
-
this.fillStroke();
|
|
8440
|
+
closeFillStroke(path) {
|
|
8441
|
+
this.fillStroke(path);
|
|
8646
8442
|
}
|
|
8647
|
-
closeEOFillStroke() {
|
|
8443
|
+
closeEOFillStroke(path) {
|
|
8648
8444
|
this.pendingEOFill = true;
|
|
8649
|
-
this.
|
|
8650
|
-
this.fillStroke();
|
|
8445
|
+
this.fillStroke(path);
|
|
8651
8446
|
}
|
|
8652
|
-
endPath() {
|
|
8653
|
-
this.consumePath();
|
|
8447
|
+
endPath(path) {
|
|
8448
|
+
this.consumePath(path);
|
|
8449
|
+
}
|
|
8450
|
+
rawFillPath(path) {
|
|
8451
|
+
this.ctx.fill(path);
|
|
8654
8452
|
}
|
|
8655
8453
|
// Clipping
|
|
8656
8454
|
clip() {
|
|
@@ -8661,7 +8459,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8661
8459
|
}
|
|
8662
8460
|
// Text
|
|
8663
8461
|
beginText() {
|
|
8664
|
-
this.current.textMatrix =
|
|
8462
|
+
this.current.textMatrix = null;
|
|
8665
8463
|
this.current.textMatrixScale = 1;
|
|
8666
8464
|
this.current.x = this.current.lineX = 0;
|
|
8667
8465
|
this.current.y = this.current.lineY = 0;
|
|
@@ -8670,7 +8468,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8670
8468
|
const paths = this.pendingTextPaths;
|
|
8671
8469
|
const ctx = this.ctx;
|
|
8672
8470
|
if (paths === void 0) {
|
|
8673
|
-
ctx.beginPath();
|
|
8674
8471
|
return;
|
|
8675
8472
|
}
|
|
8676
8473
|
const newPath = new SvgPath2D();
|
|
@@ -8682,7 +8479,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8682
8479
|
);
|
|
8683
8480
|
}
|
|
8684
8481
|
ctx.clip(newPath);
|
|
8685
|
-
ctx.beginPath();
|
|
8686
8482
|
delete this.pendingTextPaths;
|
|
8687
8483
|
}
|
|
8688
8484
|
setCharSpacing(spacing) {
|
|
@@ -8750,11 +8546,12 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8750
8546
|
this.setLeading(-y);
|
|
8751
8547
|
this.moveText(x, y);
|
|
8752
8548
|
}
|
|
8753
|
-
setTextMatrix(
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
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;
|
|
8758
8555
|
}
|
|
8759
8556
|
nextLine() {
|
|
8760
8557
|
this.moveText(0, this.current.leading);
|
|
@@ -8801,8 +8598,8 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8801
8598
|
[a, b, c, d, 0, 0],
|
|
8802
8599
|
invPatternTransform
|
|
8803
8600
|
);
|
|
8804
|
-
|
|
8805
|
-
ctx.lineWidth *= Math.max(
|
|
8601
|
+
Util.singularValueDecompose2dScale(transf, XY);
|
|
8602
|
+
ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
|
|
8806
8603
|
ctx.stroke(
|
|
8807
8604
|
__privateMethod(this, _CanvasGraphics_instances, getScaledPath_fn).call(this, path, currentTransform, patternStrokeTransform)
|
|
8808
8605
|
);
|
|
@@ -8872,7 +8669,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8872
8669
|
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
|
8873
8670
|
const simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
|
8874
8671
|
ctx.save();
|
|
8875
|
-
|
|
8672
|
+
if (current.textMatrix) {
|
|
8673
|
+
ctx.transform(...current.textMatrix);
|
|
8674
|
+
}
|
|
8876
8675
|
ctx.translate(current.x, current.y + current.textRise);
|
|
8877
8676
|
if (fontDirection > 0) {
|
|
8878
8677
|
ctx.scale(textHScale, -1);
|
|
@@ -9027,7 +8826,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9027
8826
|
this._cachedScaleForStroking[0] = -1;
|
|
9028
8827
|
this._cachedGetSinglePixelWidth = null;
|
|
9029
8828
|
ctx.save();
|
|
9030
|
-
|
|
8829
|
+
if (current.textMatrix) {
|
|
8830
|
+
ctx.transform(...current.textMatrix);
|
|
8831
|
+
}
|
|
9031
8832
|
ctx.translate(current.x, current.y + current.textRise);
|
|
9032
8833
|
ctx.scale(textHScale, fontDirection);
|
|
9033
8834
|
for (i = 0; i < glyphsLength; ++i) {
|
|
@@ -9042,37 +8843,34 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9042
8843
|
const operatorList = font.charProcOperatorList[glyph.operatorListId];
|
|
9043
8844
|
if (!operatorList) {
|
|
9044
8845
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
|
9045
|
-
|
|
9046
|
-
}
|
|
9047
|
-
if (this.contentVisible) {
|
|
9048
|
-
this.processingType3 = glyph;
|
|
8846
|
+
} else if (this.contentVisible) {
|
|
9049
8847
|
this.save();
|
|
9050
8848
|
ctx.scale(fontSize, fontSize);
|
|
9051
8849
|
ctx.transform(...fontMatrix);
|
|
9052
8850
|
this.executeOperatorList(operatorList);
|
|
9053
8851
|
this.restore();
|
|
9054
8852
|
}
|
|
9055
|
-
const
|
|
9056
|
-
|
|
8853
|
+
const p = [glyph.width, 0];
|
|
8854
|
+
Util.applyTransform(p, fontMatrix);
|
|
8855
|
+
width = p[0] * fontSize + spacing;
|
|
9057
8856
|
ctx.translate(width, 0);
|
|
9058
8857
|
current.x += width * textHScale;
|
|
9059
8858
|
}
|
|
9060
8859
|
ctx.restore();
|
|
9061
|
-
this.processingType3 = null;
|
|
9062
8860
|
}
|
|
9063
8861
|
// Type3 fonts
|
|
9064
8862
|
setCharWidth(xWidth, yWidth) {
|
|
9065
8863
|
}
|
|
9066
8864
|
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
9067
|
-
|
|
9068
|
-
|
|
8865
|
+
const clip = new SvgPath2D();
|
|
8866
|
+
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
8867
|
+
this.ctx.clip(clip);
|
|
9069
8868
|
this.endPath();
|
|
9070
8869
|
}
|
|
9071
8870
|
// Color
|
|
9072
8871
|
getColorN_Pattern(IR) {
|
|
9073
8872
|
let pattern;
|
|
9074
8873
|
if (IR[0] === "TilingPattern") {
|
|
9075
|
-
const color = IR[1];
|
|
9076
8874
|
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
|
9077
8875
|
const canvasGraphicsFactory = {
|
|
9078
8876
|
createCanvasGraphics: (ctx) => new _CanvasGraphics(
|
|
@@ -9089,7 +8887,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9089
8887
|
};
|
|
9090
8888
|
pattern = new TilingPattern(
|
|
9091
8889
|
IR,
|
|
9092
|
-
color,
|
|
9093
8890
|
this.ctx,
|
|
9094
8891
|
canvasGraphicsFactory,
|
|
9095
8892
|
baseTransform
|
|
@@ -9156,10 +8953,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9156
8953
|
const inv = getCurrentTransformInverse(ctx);
|
|
9157
8954
|
if (inv) {
|
|
9158
8955
|
const { width, height } = ctx.canvas;
|
|
9159
|
-
const
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
);
|
|
8956
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
8957
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], inv, minMax);
|
|
8958
|
+
const [x0, y0, x1, y1] = minMax;
|
|
9163
8959
|
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
|
|
9164
8960
|
} else {
|
|
9165
8961
|
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
|
|
@@ -9185,11 +8981,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9185
8981
|
}
|
|
9186
8982
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
9187
8983
|
if (bbox) {
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
9191
|
-
|
|
9192
|
-
|
|
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);
|
|
9193
8993
|
this.endPath();
|
|
9194
8994
|
}
|
|
9195
8995
|
}
|
|
@@ -9223,9 +9023,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9223
9023
|
if (!group.bbox) {
|
|
9224
9024
|
throw new Error("Bounding box is required.");
|
|
9225
9025
|
}
|
|
9226
|
-
let bounds =
|
|
9026
|
+
let bounds = MIN_MAX_INIT.slice();
|
|
9027
|
+
Util.axialAlignedBoundingBox(
|
|
9227
9028
|
group.bbox,
|
|
9228
|
-
getCurrentTransform(currentCtx)
|
|
9029
|
+
getCurrentTransform(currentCtx),
|
|
9030
|
+
bounds
|
|
9229
9031
|
);
|
|
9230
9032
|
const canvasBounds = [
|
|
9231
9033
|
0,
|
|
@@ -9251,6 +9053,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9251
9053
|
const groupCtx = scratchCanvas.context;
|
|
9252
9054
|
groupCtx.translate(-offsetX, -offsetY);
|
|
9253
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);
|
|
9254
9065
|
if (group.smask) {
|
|
9255
9066
|
this.smaskStack.push({
|
|
9256
9067
|
canvas: scratchCanvas.canvas,
|
|
@@ -9296,9 +9107,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9296
9107
|
this.restore();
|
|
9297
9108
|
this.ctx.save();
|
|
9298
9109
|
this.ctx.setTransform(...currentMtx);
|
|
9299
|
-
const dirtyBox =
|
|
9110
|
+
const dirtyBox = MIN_MAX_INIT.slice();
|
|
9111
|
+
Util.axialAlignedBoundingBox(
|
|
9300
9112
|
[0, 0, groupCtx.canvas.width, groupCtx.canvas.height],
|
|
9301
|
-
currentMtx
|
|
9113
|
+
currentMtx,
|
|
9114
|
+
dirtyBox
|
|
9302
9115
|
);
|
|
9303
9116
|
this.ctx.drawImage(groupCtx.canvas, 0, 0);
|
|
9304
9117
|
this.ctx.restore();
|
|
@@ -9324,9 +9137,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9324
9137
|
rect[0] = rect[1] = 0;
|
|
9325
9138
|
rect[2] = width;
|
|
9326
9139
|
rect[3] = height;
|
|
9327
|
-
|
|
9328
|
-
getCurrentTransform(this.ctx)
|
|
9329
|
-
);
|
|
9140
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);
|
|
9330
9141
|
const { viewportScale } = this;
|
|
9331
9142
|
const canvasWidth = Math.ceil(
|
|
9332
9143
|
width * this.outputScaleX * viewportScale
|
|
@@ -9343,14 +9154,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9343
9154
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
9344
9155
|
this.ctx = context;
|
|
9345
9156
|
this.ctx.save();
|
|
9346
|
-
this.ctx.setTransform(
|
|
9157
|
+
this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);
|
|
9347
9158
|
resetCtxToDefault(this.ctx);
|
|
9348
9159
|
} else {
|
|
9349
9160
|
resetCtxToDefault(this.ctx);
|
|
9350
9161
|
this.endPath();
|
|
9351
|
-
|
|
9352
|
-
|
|
9353
|
-
this.ctx.
|
|
9162
|
+
const clip = new SvgPath2D();
|
|
9163
|
+
clip.rect(rect[0], rect[1], width, height);
|
|
9164
|
+
this.ctx.clip(clip);
|
|
9354
9165
|
}
|
|
9355
9166
|
}
|
|
9356
9167
|
this.current = new CanvasExtraState(
|
|
@@ -9377,16 +9188,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9377
9188
|
img = this.getObject(img.data, img);
|
|
9378
9189
|
img.count = count;
|
|
9379
9190
|
const ctx = this.ctx;
|
|
9380
|
-
const glyph = this.processingType3;
|
|
9381
|
-
if (glyph) {
|
|
9382
|
-
if (glyph.compiled === void 0) {
|
|
9383
|
-
glyph.compiled = compileType3Glyph(img);
|
|
9384
|
-
}
|
|
9385
|
-
if (glyph.compiled) {
|
|
9386
|
-
glyph.compiled(ctx);
|
|
9387
|
-
return;
|
|
9388
|
-
}
|
|
9389
|
-
}
|
|
9390
9191
|
const mask = this._createMaskCanvas(img);
|
|
9391
9192
|
const maskCanvas = mask.canvas;
|
|
9392
9193
|
ctx.save();
|
|
@@ -9422,8 +9223,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9422
9223
|
positions[i],
|
|
9423
9224
|
positions[i + 1]
|
|
9424
9225
|
]);
|
|
9425
|
-
|
|
9426
|
-
ctx.drawImage(mask.canvas, x, y);
|
|
9226
|
+
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
9427
9227
|
}
|
|
9428
9228
|
ctx.restore();
|
|
9429
9229
|
this.compose();
|
|
@@ -9540,11 +9340,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9540
9340
|
const height = imgData.height;
|
|
9541
9341
|
const ctx = this.ctx;
|
|
9542
9342
|
this.save();
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
ctx.filter = "none";
|
|
9547
|
-
}
|
|
9343
|
+
const { filter } = ctx;
|
|
9344
|
+
if (filter !== "none" && filter !== "") {
|
|
9345
|
+
ctx.filter = "none";
|
|
9548
9346
|
}
|
|
9549
9347
|
ctx.scale(1 / width, -1 / height);
|
|
9550
9348
|
let imgToPaint;
|
|
@@ -9660,7 +9458,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9660
9458
|
endCompat() {
|
|
9661
9459
|
}
|
|
9662
9460
|
// Helper functions
|
|
9663
|
-
consumePath(clipBox) {
|
|
9461
|
+
consumePath(path, clipBox) {
|
|
9664
9462
|
const isEmpty = this.current.isEmptyClip();
|
|
9665
9463
|
if (this.pendingClip) {
|
|
9666
9464
|
this.current.updateClipFromPath();
|
|
@@ -9672,15 +9470,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9672
9470
|
if (this.pendingClip) {
|
|
9673
9471
|
if (!isEmpty) {
|
|
9674
9472
|
if (this.pendingClip === EO_CLIP) {
|
|
9675
|
-
ctx.clip("evenodd");
|
|
9473
|
+
ctx.clip(path, "evenodd");
|
|
9676
9474
|
} else {
|
|
9677
|
-
ctx.clip();
|
|
9475
|
+
ctx.clip(path);
|
|
9678
9476
|
}
|
|
9679
9477
|
}
|
|
9680
9478
|
this.pendingClip = null;
|
|
9681
9479
|
}
|
|
9682
9480
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
9683
|
-
ctx.beginPath();
|
|
9684
9481
|
}
|
|
9685
9482
|
getSinglePixelWidth() {
|
|
9686
9483
|
if (!this._cachedGetSinglePixelWidth) {
|
|
@@ -9740,13 +9537,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9740
9537
|
}
|
|
9741
9538
|
// Rescale before stroking in order to have a final lineWidth
|
|
9742
9539
|
// with both thicknesses greater or equal to 1.
|
|
9743
|
-
rescaleAndStroke(saveRestore) {
|
|
9744
|
-
const {
|
|
9745
|
-
|
|
9540
|
+
rescaleAndStroke(path, saveRestore) {
|
|
9541
|
+
const {
|
|
9542
|
+
ctx,
|
|
9543
|
+
current: { lineWidth }
|
|
9544
|
+
} = this;
|
|
9746
9545
|
const [scaleX, scaleY] = this.getScaleForStroking();
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
ctx.stroke();
|
|
9546
|
+
if (scaleX === scaleY) {
|
|
9547
|
+
ctx.lineWidth = (lineWidth || 1) * scaleX;
|
|
9548
|
+
ctx.stroke(path);
|
|
9750
9549
|
return;
|
|
9751
9550
|
}
|
|
9752
9551
|
const dashes = ctx.getLineDash();
|
|
@@ -9754,12 +9553,17 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9754
9553
|
ctx.save();
|
|
9755
9554
|
}
|
|
9756
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);
|
|
9757
9560
|
if (dashes.length > 0) {
|
|
9758
9561
|
const scale = Math.max(scaleX, scaleY);
|
|
9759
9562
|
ctx.setLineDash(dashes.map((x) => x / scale));
|
|
9760
9563
|
ctx.lineDashOffset /= scale;
|
|
9761
9564
|
}
|
|
9762
|
-
ctx.
|
|
9565
|
+
ctx.lineWidth = lineWidth || 1;
|
|
9566
|
+
ctx.stroke(newPath);
|
|
9763
9567
|
if (saveRestore) {
|
|
9764
9568
|
ctx.restore();
|
|
9765
9569
|
}
|
|
@@ -11462,7 +11266,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11462
11266
|
throw new Error('No "textContentSource" parameter specified.');
|
|
11463
11267
|
}
|
|
11464
11268
|
__privateSet(this, _container3, __privateSet(this, _rootContainer, container));
|
|
11465
|
-
__privateSet(this, _scale, viewport.scale *
|
|
11269
|
+
__privateSet(this, _scale, viewport.scale * OutputScale.pixelRatio);
|
|
11466
11270
|
__privateSet(this, _rotation, viewport.rotation);
|
|
11467
11271
|
__privateSet(this, _layoutTextParams, {
|
|
11468
11272
|
div: null,
|
|
@@ -11540,7 +11344,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11540
11344
|
*/
|
|
11541
11345
|
update({ viewport, onBefore = null }) {
|
|
11542
11346
|
var _a2;
|
|
11543
|
-
const scale = viewport.scale *
|
|
11347
|
+
const scale = viewport.scale * OutputScale.pixelRatio;
|
|
11544
11348
|
const rotation = viewport.rotation;
|
|
11545
11349
|
if (rotation !== __privateGet(this, _rotation)) {
|
|
11546
11350
|
onBefore?.();
|
|
@@ -11920,6 +11724,7 @@ function getDocument(src = {}) {
|
|
|
11920
11724
|
const cMapUrl = getFactoryUrlProp(src.cMapUrl);
|
|
11921
11725
|
const cMapPacked = src.cMapPacked !== false;
|
|
11922
11726
|
const CMapReaderFactory = src.CMapReaderFactory || (isNodeJS ? NodeCMapReaderFactory : DOMCMapReaderFactory);
|
|
11727
|
+
const iccUrl = getFactoryUrlProp(src.iccUrl);
|
|
11923
11728
|
const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);
|
|
11924
11729
|
const StandardFontDataFactory2 = src.StandardFontDataFactory || (isNodeJS ? NodeStandardFontDataFactory : DOMStandardFontDataFactory);
|
|
11925
11730
|
const wasmUrl = getFactoryUrlProp(src.wasmUrl);
|
|
@@ -11991,6 +11796,7 @@ function getDocument(src = {}) {
|
|
|
11991
11796
|
useWasm,
|
|
11992
11797
|
useWorkerFetch,
|
|
11993
11798
|
cMapUrl,
|
|
11799
|
+
iccUrl,
|
|
11994
11800
|
standardFontDataUrl,
|
|
11995
11801
|
wasmUrl
|
|
11996
11802
|
}
|
|
@@ -12124,19 +11930,54 @@ function getFactoryUrlProp(val) {
|
|
|
12124
11930
|
}
|
|
12125
11931
|
throw new Error(`Invalid factory url: "${val}" must include trailing slash.`);
|
|
12126
11932
|
}
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
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
|
+
);
|
|
12130
11942
|
var _docId2;
|
|
12131
11943
|
var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
12132
11944
|
constructor() {
|
|
12133
|
-
|
|
12134
|
-
|
|
12135
|
-
|
|
12136
|
-
this
|
|
12137
|
-
|
|
12138
|
-
|
|
12139
|
-
|
|
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);
|
|
12140
11981
|
}
|
|
12141
11982
|
/**
|
|
12142
11983
|
* Promise for document loading task completion.
|
|
@@ -12171,6 +12012,15 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
12171
12012
|
this._worker?.destroy();
|
|
12172
12013
|
this._worker = null;
|
|
12173
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
|
+
}
|
|
12174
12024
|
};
|
|
12175
12025
|
_docId2 = new WeakMap();
|
|
12176
12026
|
__privateAdd(_PDFDocumentLoadingTask, _docId2, 0);
|
|
@@ -13347,6 +13197,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13347
13197
|
}
|
|
13348
13198
|
/**
|
|
13349
13199
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
13200
|
+
* @returns {PDFWorker}
|
|
13350
13201
|
*/
|
|
13351
13202
|
static fromPort(params) {
|
|
13352
13203
|
if (false) {
|
|
@@ -13382,7 +13233,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13382
13233
|
if (__privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13383
13234
|
return __privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get);
|
|
13384
13235
|
}
|
|
13385
|
-
const worker = true ? await import("./worker.js") : await
|
|
13236
|
+
const worker = true ? await import("./worker.js") : await __raw_import__(this.workerSrc);
|
|
13386
13237
|
return worker.WorkerMessageHandler;
|
|
13387
13238
|
};
|
|
13388
13239
|
return shadow(this, "_setupFakeWorkerGlobal", loader());
|
|
@@ -17911,7 +17762,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17911
17762
|
__privateSet(this, _content, `${bufferBefore.join("\n")}${paste}${bufferAfter.join("\n")}`);
|
|
17912
17763
|
__privateMethod(this, _FreeTextEditor_instances, setContent_fn).call(this);
|
|
17913
17764
|
const newRange = new Range();
|
|
17914
|
-
let beforeLength = bufferBefore.
|
|
17765
|
+
let beforeLength = Math.sumPrecise(bufferBefore.map((line) => line.length));
|
|
17915
17766
|
for (const { firstChild } of this.editorDiv.childNodes) {
|
|
17916
17767
|
if (firstChild.nodeType === Node.TEXT_NODE) {
|
|
17917
17768
|
const length = firstChild.nodeValue.length;
|
|
@@ -18761,35 +18612,24 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18761
18612
|
const outline = __privateGet(this, _outline);
|
|
18762
18613
|
let lastX = outline[4];
|
|
18763
18614
|
let lastY = outline[5];
|
|
18764
|
-
|
|
18765
|
-
let minY = lastY;
|
|
18766
|
-
let maxX = lastX;
|
|
18767
|
-
let maxY = lastY;
|
|
18615
|
+
const minMax = [lastX, lastY, lastX, lastY];
|
|
18768
18616
|
let lastPointX = lastX;
|
|
18769
18617
|
let lastPointY = lastY;
|
|
18770
18618
|
const ltrCallback = isLTR ? Math.max : Math.min;
|
|
18771
18619
|
for (let i = 6, ii = outline.length; i < ii; i += 6) {
|
|
18620
|
+
const x = outline[i + 4], y = outline[i + 5];
|
|
18772
18621
|
if (isNaN(outline[i])) {
|
|
18773
|
-
|
|
18774
|
-
|
|
18775
|
-
|
|
18776
|
-
|
|
18777
|
-
if (lastPointY
|
|
18778
|
-
lastPointX =
|
|
18779
|
-
lastPointY = outline[i + 5];
|
|
18780
|
-
} else if (lastPointY === outline[i + 5]) {
|
|
18781
|
-
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);
|
|
18782
18628
|
}
|
|
18783
18629
|
} else {
|
|
18784
|
-
const bbox2 =
|
|
18785
|
-
|
|
18786
|
-
|
|
18787
|
-
...outline.slice(i, i + 6)
|
|
18788
|
-
);
|
|
18789
|
-
minX = Math.min(minX, bbox2[0]);
|
|
18790
|
-
minY = Math.min(minY, bbox2[1]);
|
|
18791
|
-
maxX = Math.max(maxX, bbox2[2]);
|
|
18792
|
-
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);
|
|
18793
18633
|
if (lastPointY < bbox2[3]) {
|
|
18794
18634
|
lastPointX = bbox2[2];
|
|
18795
18635
|
lastPointY = bbox2[3];
|
|
@@ -18797,14 +18637,14 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18797
18637
|
lastPointX = ltrCallback(lastPointX, bbox2[2]);
|
|
18798
18638
|
}
|
|
18799
18639
|
}
|
|
18800
|
-
lastX =
|
|
18801
|
-
lastY =
|
|
18640
|
+
lastX = x;
|
|
18641
|
+
lastY = y;
|
|
18802
18642
|
}
|
|
18803
18643
|
const bbox = __privateGet(this, _bbox);
|
|
18804
|
-
bbox[0] =
|
|
18805
|
-
bbox[1] =
|
|
18806
|
-
bbox[2] =
|
|
18807
|
-
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);
|
|
18808
18648
|
this.lastPoint = [lastPointX, lastPointY];
|
|
18809
18649
|
};
|
|
18810
18650
|
|
|
@@ -18829,10 +18669,7 @@ var HighlightOutliner = class {
|
|
|
18829
18669
|
__privateAdd(this, _lastPoint);
|
|
18830
18670
|
__privateAdd(this, _verticalEdges, []);
|
|
18831
18671
|
__privateAdd(this, _intervals, []);
|
|
18832
|
-
|
|
18833
|
-
let maxX = -Infinity;
|
|
18834
|
-
let minY = Infinity;
|
|
18835
|
-
let maxY = -Infinity;
|
|
18672
|
+
const minMax = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18836
18673
|
const NUMBER_OF_DIGITS = 4;
|
|
18837
18674
|
const EPSILON = 10 ** -NUMBER_OF_DIGITS;
|
|
18838
18675
|
for (const { x, y, width, height } of boxes) {
|
|
@@ -18843,15 +18680,12 @@ var HighlightOutliner = class {
|
|
|
18843
18680
|
const left = [x1, y1, y2, true];
|
|
18844
18681
|
const right = [x2, y1, y2, false];
|
|
18845
18682
|
__privateGet(this, _verticalEdges).push(left, right);
|
|
18846
|
-
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
const
|
|
18852
|
-
const bboxHeight = maxY - minY + 2 * innerMargin;
|
|
18853
|
-
const shiftedMinX = minX - innerMargin;
|
|
18854
|
-
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;
|
|
18855
18689
|
const lastEdge = __privateGet(this, _verticalEdges).at(isLTR ? -1 : -2);
|
|
18856
18690
|
const lastPoint = [lastEdge[0], lastEdge[2]];
|
|
18857
18691
|
for (const edge of __privateGet(this, _verticalEdges)) {
|
|
@@ -19380,6 +19214,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19380
19214
|
__privateSet(this, _methodOfCreation, params.methodOfCreation || "");
|
|
19381
19215
|
__privateSet(this, _text, params.text || "");
|
|
19382
19216
|
this._isDraggable = false;
|
|
19217
|
+
this.defaultL10nId = "pdfjs-editor-highlight-editor";
|
|
19383
19218
|
if (params.highlightId > -1) {
|
|
19384
19219
|
__privateSet(this, _isFreeHighlight, true);
|
|
19385
19220
|
__privateMethod(this, _HighlightEditor_instances, createFreeOutlines_fn).call(this, params);
|
|
@@ -19894,6 +19729,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19894
19729
|
clipPathId
|
|
19895
19730
|
});
|
|
19896
19731
|
__privateMethod(_d = editor, _HighlightEditor_instances, addToDrawLayer_fn).call(_d);
|
|
19732
|
+
editor.rotate(editor.parentRotation);
|
|
19897
19733
|
}
|
|
19898
19734
|
return editor;
|
|
19899
19735
|
}
|
|
@@ -21803,11 +21639,7 @@ computeBbox_fn = function() {
|
|
|
21803
21639
|
for (const { line } of __privateGet(this, _lines2)) {
|
|
21804
21640
|
if (line.length <= 12) {
|
|
21805
21641
|
for (let i = 4, ii = line.length; i < ii; i += 6) {
|
|
21806
|
-
|
|
21807
|
-
bbox[0] = Math.min(bbox[0], x);
|
|
21808
|
-
bbox[1] = Math.min(bbox[1], y);
|
|
21809
|
-
bbox[2] = Math.max(bbox[2], x);
|
|
21810
|
-
bbox[3] = Math.max(bbox[3], y);
|
|
21642
|
+
Util.pointBoundingBox(line[i], line[i + 1], bbox);
|
|
21811
21643
|
}
|
|
21812
21644
|
continue;
|
|
21813
21645
|
}
|
|
@@ -21820,10 +21652,10 @@ computeBbox_fn = function() {
|
|
|
21820
21652
|
}
|
|
21821
21653
|
}
|
|
21822
21654
|
const [marginX, marginY] = __privateMethod(this, _InkDrawOutline_instances, getMarginComponents_fn).call(this);
|
|
21823
|
-
bbox[0] =
|
|
21824
|
-
bbox[1] =
|
|
21825
|
-
bbox[2] =
|
|
21826
|
-
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);
|
|
21827
21659
|
bbox[2] -= bbox[0];
|
|
21828
21660
|
bbox[3] -= bbox[1];
|
|
21829
21661
|
};
|
|
@@ -21877,6 +21709,7 @@ var _InkEditor = class _InkEditor extends DrawingEditor {
|
|
|
21877
21709
|
super({ ...params, name: "inkEditor" });
|
|
21878
21710
|
__privateAdd(this, _InkEditor_instances);
|
|
21879
21711
|
this._willKeepAspectRatio = true;
|
|
21712
|
+
this.defaultL10nId = "pdfjs-editor-ink-editor";
|
|
21880
21713
|
}
|
|
21881
21714
|
/** @inheritdoc */
|
|
21882
21715
|
static initialize(l10n, uiManager) {
|
|
@@ -22770,6 +22603,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22770
22603
|
this._willKeepAspectRatio = true;
|
|
22771
22604
|
__privateSet(this, _signatureData, params.signatureData || null);
|
|
22772
22605
|
__privateSet(this, _description, null);
|
|
22606
|
+
this.defaultL10nId = "pdfjs-editor-signature-editor1";
|
|
22773
22607
|
}
|
|
22774
22608
|
/** @inheritdoc */
|
|
22775
22609
|
static initialize(l10n, uiManager) {
|
|
@@ -22833,7 +22667,6 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22833
22667
|
baseY = this.y;
|
|
22834
22668
|
}
|
|
22835
22669
|
super.render();
|
|
22836
|
-
this.div.setAttribute("role", "figure");
|
|
22837
22670
|
if (this._drawId === null) {
|
|
22838
22671
|
if (__privateGet(this, _signatureData)) {
|
|
22839
22672
|
const {
|
|
@@ -22859,6 +22692,10 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22859
22692
|
});
|
|
22860
22693
|
this.addSignature(outline, heightInPage, description, uuid);
|
|
22861
22694
|
} else {
|
|
22695
|
+
this.div.setAttribute(
|
|
22696
|
+
"data-l10n-args",
|
|
22697
|
+
JSON.stringify({ description: "" })
|
|
22698
|
+
);
|
|
22862
22699
|
this.div.hidden = true;
|
|
22863
22700
|
this._uiManager.getSignature(this);
|
|
22864
22701
|
}
|
|
@@ -22925,6 +22762,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22925
22762
|
const { outline } = __privateSet(this, _signatureData, data);
|
|
22926
22763
|
__privateSet(this, _isExtracted, outline instanceof ContourDrawOutline);
|
|
22927
22764
|
__privateSet(this, _description, description);
|
|
22765
|
+
this.div.setAttribute("data-l10n-args", JSON.stringify({ description }));
|
|
22928
22766
|
let drawingOptions;
|
|
22929
22767
|
if (__privateGet(this, _isExtracted)) {
|
|
22930
22768
|
drawingOptions = _SignatureEditor.getDefaultDrawingOptions();
|
|
@@ -23105,6 +22943,7 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23105
22943
|
__privateAdd(this, _hasBeenAddedInUndoStack, false);
|
|
23106
22944
|
__privateSet(this, _bitmapUrl, params.bitmapUrl);
|
|
23107
22945
|
__privateSet(this, _bitmapFile, params.bitmapFile);
|
|
22946
|
+
this.defaultL10nId = "pdfjs-editor-stamp-editor";
|
|
23108
22947
|
}
|
|
23109
22948
|
/** @inheritdoc */
|
|
23110
22949
|
static initialize(l10n, uiManager) {
|
|
@@ -23246,7 +23085,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23246
23085
|
}
|
|
23247
23086
|
super.render();
|
|
23248
23087
|
this.div.hidden = true;
|
|
23249
|
-
this.div.setAttribute("role", "figure");
|
|
23250
23088
|
this.addAltTextButton();
|
|
23251
23089
|
if (!__privateGet(this, _missingCanvas)) {
|
|
23252
23090
|
if (__privateGet(this, _bitmap)) {
|
|
@@ -23394,10 +23232,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23394
23232
|
return { canvas, width, height, imageData };
|
|
23395
23233
|
}
|
|
23396
23234
|
/** @inheritdoc */
|
|
23397
|
-
getImageForAltText() {
|
|
23398
|
-
return __privateGet(this, _canvas);
|
|
23399
|
-
}
|
|
23400
|
-
/** @inheritdoc */
|
|
23401
23235
|
static async deserialize(data, parent, uiManager) {
|
|
23402
23236
|
let initialData = null;
|
|
23403
23237
|
let missingCanvas = false;
|
|
@@ -23713,7 +23547,7 @@ createCanvas_fn = function() {
|
|
|
23713
23547
|
action: "inserted_image"
|
|
23714
23548
|
});
|
|
23715
23549
|
if (__privateGet(this, _bitmapFileName)) {
|
|
23716
|
-
|
|
23550
|
+
this.div.setAttribute("aria-description", __privateGet(this, _bitmapFileName));
|
|
23717
23551
|
}
|
|
23718
23552
|
};
|
|
23719
23553
|
scaleBitmap_fn = function(width, height) {
|
|
@@ -24836,320 +24670,39 @@ if (false) {
|
|
|
24836
24670
|
};
|
|
24837
24671
|
}
|
|
24838
24672
|
|
|
24839
|
-
// src/lib/
|
|
24840
|
-
|
|
24841
|
-
|
|
24842
|
-
|
|
24843
|
-
|
|
24844
|
-
|
|
24845
|
-
|
|
24846
|
-
|
|
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
|
+
}
|
|
24847
24695
|
}
|
|
24848
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
24849
24696
|
}
|
|
24850
|
-
|
|
24851
|
-
|
|
24852
|
-
|
|
24853
|
-
|
|
24854
|
-
|
|
24855
|
-
|
|
24856
|
-
|
|
24857
|
-
reader.onload = () => {
|
|
24858
|
-
resolve(reader.result);
|
|
24859
|
-
};
|
|
24860
|
-
reader.readAsDataURL(new Blob([data], { type: "image/png" }));
|
|
24861
|
-
});
|
|
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) ?? [];
|
|
24862
24704
|
}
|
|
24863
|
-
|
|
24864
|
-
}
|
|
24865
|
-
|
|
24866
|
-
// src/lib/PDFPageProxy.ts
|
|
24867
|
-
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
24868
|
-
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
24869
|
-
const annotations = await getAnnotations.call(this, params);
|
|
24870
|
-
const operatorList = await this.getOperatorList({
|
|
24871
|
-
annotationMode: AnnotationMode.ENABLE_FORMS
|
|
24872
|
-
});
|
|
24873
|
-
const annotationsOperatorList = /* @__PURE__ */ new Map();
|
|
24874
|
-
let currentId = null;
|
|
24875
|
-
let currentList = [];
|
|
24876
|
-
for (const [index, op] of operatorList.fnArray.entries()) {
|
|
24877
|
-
const args = operatorList.argsArray[index];
|
|
24878
|
-
if (op === OPS.beginAnnotation) {
|
|
24879
|
-
currentId = args[0];
|
|
24880
|
-
currentList.push({ fn: op, args });
|
|
24881
|
-
} else if (op === OPS.endAnnotation && currentId) {
|
|
24882
|
-
currentList.push({ fn: op, args });
|
|
24883
|
-
annotationsOperatorList.set(currentId, currentList);
|
|
24884
|
-
currentList = [];
|
|
24885
|
-
} else if (currentId) {
|
|
24886
|
-
currentList.push({ fn: op, args });
|
|
24887
|
-
}
|
|
24888
|
-
}
|
|
24889
|
-
for (const annotation of annotations) {
|
|
24890
|
-
const opList = annotationsOperatorList.get(annotation.id);
|
|
24891
|
-
if (opList) {
|
|
24892
|
-
if (annotation.subtype === "Stamp") {
|
|
24893
|
-
try {
|
|
24894
|
-
const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
|
|
24895
|
-
const scale = 2;
|
|
24896
|
-
const viewport = this.getViewport({ scale });
|
|
24897
|
-
const { context: canvasContext } = canvasFactory.create(
|
|
24898
|
-
viewport.width,
|
|
24899
|
-
viewport.height
|
|
24900
|
-
);
|
|
24901
|
-
const gsx = new CanvasGraphics(
|
|
24902
|
-
canvasContext,
|
|
24903
|
-
this.commonObjs,
|
|
24904
|
-
this.objs,
|
|
24905
|
-
canvasFactory,
|
|
24906
|
-
this.filterFactory,
|
|
24907
|
-
{ optionalContentConfig: null }
|
|
24908
|
-
);
|
|
24909
|
-
gsx.beginDrawing({
|
|
24910
|
-
transform: null,
|
|
24911
|
-
viewport
|
|
24912
|
-
});
|
|
24913
|
-
canvasContext.clearRect(0, 0, viewport.width, viewport.height);
|
|
24914
|
-
gsx.executeOperatorList({
|
|
24915
|
-
fnArray: opList.map((op) => op.fn),
|
|
24916
|
-
argsArray: opList.map((op) => op.args)
|
|
24917
|
-
});
|
|
24918
|
-
const width = annotation.rect[2] - annotation.rect[0];
|
|
24919
|
-
const height = annotation.rect[3] - annotation.rect[1];
|
|
24920
|
-
const { context: croppedCanvasContext } = canvasFactory.create(
|
|
24921
|
-
width * scale,
|
|
24922
|
-
height * scale
|
|
24923
|
-
);
|
|
24924
|
-
croppedCanvasContext.drawImage(
|
|
24925
|
-
canvasContext.canvas,
|
|
24926
|
-
annotation.rect[0] * scale,
|
|
24927
|
-
(this.view[3] - annotation.rect[1] - height) * scale,
|
|
24928
|
-
width * scale,
|
|
24929
|
-
height * scale,
|
|
24930
|
-
0,
|
|
24931
|
-
0,
|
|
24932
|
-
width * scale,
|
|
24933
|
-
height * scale
|
|
24934
|
-
);
|
|
24935
|
-
annotation.graphics = await canvasToData(croppedCanvasContext.canvas);
|
|
24936
|
-
} catch (e) {
|
|
24937
|
-
console.error(e);
|
|
24938
|
-
}
|
|
24939
|
-
} else {
|
|
24940
|
-
let firstStroke = true;
|
|
24941
|
-
let firstFill = true;
|
|
24942
|
-
let currentFillColor = null;
|
|
24943
|
-
let currentLineWidth = null;
|
|
24944
|
-
for (const { fn, args } of opList) {
|
|
24945
|
-
if (fn === OPS.fill) {
|
|
24946
|
-
if (currentFillColor) {
|
|
24947
|
-
annotation.interiorColor = currentFillColor;
|
|
24948
|
-
currentFillColor = null;
|
|
24949
|
-
}
|
|
24950
|
-
firstFill = false;
|
|
24951
|
-
continue;
|
|
24952
|
-
}
|
|
24953
|
-
if (fn === OPS.beginText) {
|
|
24954
|
-
firstFill = false;
|
|
24955
|
-
continue;
|
|
24956
|
-
}
|
|
24957
|
-
if (fn === OPS.stroke) {
|
|
24958
|
-
if (currentLineWidth === null) {
|
|
24959
|
-
annotation.borderStyle.width = 1;
|
|
24960
|
-
}
|
|
24961
|
-
firstStroke = false;
|
|
24962
|
-
currentLineWidth = null;
|
|
24963
|
-
continue;
|
|
24964
|
-
}
|
|
24965
|
-
if (fn === OPS.fillStroke) {
|
|
24966
|
-
if (currentFillColor) {
|
|
24967
|
-
annotation.interiorColor = currentFillColor;
|
|
24968
|
-
currentFillColor = null;
|
|
24969
|
-
}
|
|
24970
|
-
if (currentLineWidth === null) {
|
|
24971
|
-
annotation.borderStyle.width = 1;
|
|
24972
|
-
}
|
|
24973
|
-
firstStroke = false;
|
|
24974
|
-
currentLineWidth = null;
|
|
24975
|
-
break;
|
|
24976
|
-
}
|
|
24977
|
-
if (!firstFill && !firstStroke) {
|
|
24978
|
-
break;
|
|
24979
|
-
}
|
|
24980
|
-
if (fn === OPS.setLineWidth && firstStroke) {
|
|
24981
|
-
currentLineWidth = args[0];
|
|
24982
|
-
annotation.borderStyle.width = currentLineWidth;
|
|
24983
|
-
}
|
|
24984
|
-
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
24985
|
-
if (!annotation.borderStyle.width) {
|
|
24986
|
-
annotation.borderStyle.width = 1;
|
|
24987
|
-
}
|
|
24988
|
-
annotation.color = args;
|
|
24989
|
-
}
|
|
24990
|
-
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
24991
|
-
currentFillColor = args;
|
|
24992
|
-
}
|
|
24993
|
-
if (fn === OPS.setGState) {
|
|
24994
|
-
for (const entry of args[0]) {
|
|
24995
|
-
if (!Array.isArray(entry)) {
|
|
24996
|
-
continue;
|
|
24997
|
-
}
|
|
24998
|
-
if (entry[0] === "ca" && firstFill) {
|
|
24999
|
-
annotation.interiorColorOpacity = entry[1];
|
|
25000
|
-
}
|
|
25001
|
-
if (entry[0] === "CA" && firstStroke) {
|
|
25002
|
-
annotation.borderColorOpacity = entry[1];
|
|
25003
|
-
}
|
|
25004
|
-
}
|
|
25005
|
-
}
|
|
25006
|
-
}
|
|
25007
|
-
}
|
|
25008
|
-
}
|
|
25009
|
-
}
|
|
25010
|
-
return annotations;
|
|
25011
|
-
};
|
|
25012
|
-
|
|
25013
|
-
// src/lib/StandardFontDataFactory.ts
|
|
25014
|
-
var StandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
25015
|
-
constructor() {
|
|
25016
|
-
super({
|
|
25017
|
-
baseUrl: null
|
|
25018
|
-
});
|
|
25019
|
-
}
|
|
25020
|
-
/**
|
|
25021
|
-
* Fetch the corresponding standard font data.
|
|
25022
|
-
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
25023
|
-
*/
|
|
25024
|
-
async fetch({ filename }) {
|
|
25025
|
-
switch (filename) {
|
|
25026
|
-
case "FoxitDingbats.pfb":
|
|
25027
|
-
return import("./FoxitDingbats-65AZ2Z2V.js").then((module) => module.default);
|
|
25028
|
-
case "FoxitFixed.pfb":
|
|
25029
|
-
return import("./FoxitFixed-OZGLVVOQ.js").then(
|
|
25030
|
-
(module) => module.default
|
|
25031
|
-
);
|
|
25032
|
-
case "FoxitFixedBold.pfb":
|
|
25033
|
-
return import("./FoxitFixedBold-37OOYMV7.js").then((module) => module.default);
|
|
25034
|
-
case "FoxitFixedBoldItalic.pfb":
|
|
25035
|
-
return import("./FoxitFixedBoldItalic-XYFHEG2V.js").then((module) => module.default);
|
|
25036
|
-
case "FoxitFixedItalic.pfb":
|
|
25037
|
-
return import("./FoxitFixedItalic-MM7OSGS6.js").then((module) => module.default);
|
|
25038
|
-
case "FoxitSerif.pfb":
|
|
25039
|
-
return import("./FoxitSerif-MLMJQPRP.js").then(
|
|
25040
|
-
(module) => module.default
|
|
25041
|
-
);
|
|
25042
|
-
case "FoxitSerifBold.pfb":
|
|
25043
|
-
return import("./FoxitSerifBold-AC7RJQWJ.js").then((module) => module.default);
|
|
25044
|
-
case "FoxitSerifBoldItalic.pfb":
|
|
25045
|
-
return import("./FoxitSerifBoldItalic-YCQ4CLKE.js").then((module) => module.default);
|
|
25046
|
-
case "FoxitSerifItalic.pfb":
|
|
25047
|
-
return import("./FoxitSerifItalic-CXVTCST4.js").then((module) => module.default);
|
|
25048
|
-
case "FoxitSymbol.pfb":
|
|
25049
|
-
return import("./FoxitSymbol-VUGMZN5C.js").then(
|
|
25050
|
-
(module) => module.default
|
|
25051
|
-
);
|
|
25052
|
-
case "LiberationSans-Bold.ttf":
|
|
25053
|
-
return import("./LiberationSans-Bold-XSHQQBWB.js").then((module) => module.default);
|
|
25054
|
-
case "LiberationSans-BoldItalic.ttf":
|
|
25055
|
-
return import("./LiberationSans-BoldItalic-CTAZRFRL.js").then((module) => module.default);
|
|
25056
|
-
case "LiberationSans-Italic.ttf":
|
|
25057
|
-
return import("./LiberationSans-Italic-WIOTUKLC.js").then((module) => module.default);
|
|
25058
|
-
case "LiberationSans-Regular.ttf":
|
|
25059
|
-
return import("./LiberationSans-Regular-CDMMZL5S.js").then((module) => module.default);
|
|
25060
|
-
}
|
|
25061
|
-
return Uint8Array.from([]);
|
|
25062
|
-
}
|
|
25063
|
-
};
|
|
25064
|
-
|
|
25065
|
-
// src/lib/AnnotationData.ts
|
|
25066
|
-
function isTextAnnotation(annotation) {
|
|
25067
|
-
return annotation.subtype === "Text";
|
|
25068
|
-
}
|
|
25069
|
-
function isLinkAnnotation(annotation) {
|
|
25070
|
-
return annotation.subtype === "Link";
|
|
25071
|
-
}
|
|
25072
|
-
function isFreeTextAnnotation(annotation) {
|
|
25073
|
-
return annotation.subtype === "FreeText";
|
|
25074
|
-
}
|
|
25075
|
-
function isLineAnnotation(annotation) {
|
|
25076
|
-
return annotation.subtype === "Line";
|
|
25077
|
-
}
|
|
25078
|
-
function isSquareAnnotation(annotation) {
|
|
25079
|
-
return annotation.subtype === "Square";
|
|
25080
|
-
}
|
|
25081
|
-
function isCircleAnnotation(annotation) {
|
|
25082
|
-
return annotation.subtype === "Circle";
|
|
25083
|
-
}
|
|
25084
|
-
function isPolygonAnnotation(annotation) {
|
|
25085
|
-
return annotation.subtype === "Polygon";
|
|
25086
|
-
}
|
|
25087
|
-
function isPolylineAnnotation(annotation) {
|
|
25088
|
-
return annotation.subtype === "PolyLine";
|
|
25089
|
-
}
|
|
25090
|
-
function isHighlightAnnotation(annotation) {
|
|
25091
|
-
return annotation.subtype === "Highlight";
|
|
25092
|
-
}
|
|
25093
|
-
function isUnderlineAnnotation(annotation) {
|
|
25094
|
-
return annotation.subtype === "Underline";
|
|
25095
|
-
}
|
|
25096
|
-
function isSquigglyAnnotation(annotation) {
|
|
25097
|
-
return annotation.subtype === "Squiggly";
|
|
25098
|
-
}
|
|
25099
|
-
function isStrikeOutAnnotation(annotation) {
|
|
25100
|
-
return annotation.subtype === "StrikeOut";
|
|
25101
|
-
}
|
|
25102
|
-
function isStampAnnotation(annotation) {
|
|
25103
|
-
return annotation.subtype === "Stamp";
|
|
25104
|
-
}
|
|
25105
|
-
function isCaretAnnotation(annotation) {
|
|
25106
|
-
return annotation.subtype === "Caret";
|
|
25107
|
-
}
|
|
25108
|
-
function isInkAnnotation(annotation) {
|
|
25109
|
-
return annotation.subtype === "Ink";
|
|
25110
|
-
}
|
|
25111
|
-
function isPopupAnnotation(annotation) {
|
|
25112
|
-
return annotation.subtype === "Popup";
|
|
25113
|
-
}
|
|
25114
|
-
function isFileAttachmentAnnotation(annotation) {
|
|
25115
|
-
return annotation.subtype === "FileAttachment";
|
|
25116
|
-
}
|
|
25117
|
-
function isSoundAnnotation(annotation) {
|
|
25118
|
-
return annotation.subtype === "Sound";
|
|
25119
|
-
}
|
|
25120
|
-
function isMovieAnnotation(annotation) {
|
|
25121
|
-
return annotation.subtype === "Movie";
|
|
25122
|
-
}
|
|
25123
|
-
function isWidgetAnnotation(annotation) {
|
|
25124
|
-
return annotation.subtype === "Widget";
|
|
25125
|
-
}
|
|
25126
|
-
function isTextWidgetAnnotation(annotation) {
|
|
25127
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Tx";
|
|
25128
|
-
}
|
|
25129
|
-
function isChoiceWidgetAnnotation(annotation) {
|
|
25130
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Ch";
|
|
25131
|
-
}
|
|
25132
|
-
function isButtonWidgetAnnotation(annotation) {
|
|
25133
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Btn";
|
|
25134
|
-
}
|
|
25135
|
-
function isScreenAnnotation(annotation) {
|
|
25136
|
-
return annotation.subtype === "Screen";
|
|
25137
|
-
}
|
|
25138
|
-
function isPrinterMarkAnnotation(annotation) {
|
|
25139
|
-
return annotation.subtype === "PrinterMark";
|
|
25140
|
-
}
|
|
25141
|
-
function isTrapNetAnnotation(annotation) {
|
|
25142
|
-
return annotation.subtype === "TrapNet";
|
|
25143
|
-
}
|
|
25144
|
-
function isWatermarkAnnotation(annotation) {
|
|
25145
|
-
return annotation.subtype === "Watermark";
|
|
25146
|
-
}
|
|
25147
|
-
function isThreeDAnnotation(annotation) {
|
|
25148
|
-
return annotation.subtype === "3D";
|
|
25149
|
-
}
|
|
25150
|
-
function isRedactAnnotation(annotation) {
|
|
25151
|
-
return annotation.subtype === "Redact";
|
|
25152
|
-
}
|
|
24705
|
+
};
|
|
25153
24706
|
|
|
25154
24707
|
// src/lib/SvgCanvasContext.ts
|
|
25155
24708
|
function parseTransformMatrix(transformString) {
|
|
@@ -25444,19 +24997,33 @@ var SvgCanvasContext = class {
|
|
|
25444
24997
|
this._styleStack.push(this._getStyleState());
|
|
25445
24998
|
this._transformMatrixStack.push(this.getTransform());
|
|
25446
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
|
+
}
|
|
25447
25006
|
restore() {
|
|
25448
|
-
|
|
25449
|
-
|
|
25450
|
-
|
|
25451
|
-
|
|
25452
|
-
|
|
25453
|
-
|
|
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);
|
|
25454
25026
|
}
|
|
25455
|
-
this._currentGroup = group;
|
|
25456
|
-
const state = this._styleStack.pop();
|
|
25457
|
-
this._applyStyleState(state);
|
|
25458
|
-
const { a, b, c, d, e, f } = this._transformMatrixStack.pop();
|
|
25459
|
-
this.setTransform(a, b, c, d, e, f);
|
|
25460
25027
|
}
|
|
25461
25028
|
beginPath() {
|
|
25462
25029
|
this._currentPosition = {};
|
|
@@ -25627,8 +25194,25 @@ var SvgCanvasContext = class {
|
|
|
25627
25194
|
);
|
|
25628
25195
|
this._currentPosition = { x: endX, y: endY };
|
|
25629
25196
|
}
|
|
25630
|
-
stroke() {
|
|
25631
|
-
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) {
|
|
25632
25216
|
this._applyStyle(this._currentElement, "stroke");
|
|
25633
25217
|
}
|
|
25634
25218
|
}
|
|
@@ -25777,6 +25361,9 @@ var SvgCanvasContext = class {
|
|
|
25777
25361
|
const fillRuleValue = fillRule ?? path;
|
|
25778
25362
|
this._currentStyle.fillRule = fillRuleValue;
|
|
25779
25363
|
}
|
|
25364
|
+
if (path instanceof SvgPath2D && path.commands.length === 0) {
|
|
25365
|
+
return;
|
|
25366
|
+
}
|
|
25780
25367
|
const id = `clip_${crypto.randomUUID()}`;
|
|
25781
25368
|
const clipPath = {
|
|
25782
25369
|
tag: "clipPath",
|
|
@@ -25939,7 +25526,6 @@ var SvgCanvasContext = class {
|
|
|
25939
25526
|
}
|
|
25940
25527
|
} else {
|
|
25941
25528
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25942
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25943
25529
|
if (strokeStyle instanceof SvgPattern) {
|
|
25944
25530
|
const path = transformPath(commands, transform);
|
|
25945
25531
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25970,9 +25556,7 @@ var SvgCanvasContext = class {
|
|
|
25970
25556
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25971
25557
|
}
|
|
25972
25558
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25973
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25974
|
-
} else {
|
|
25975
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25559
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25976
25560
|
}
|
|
25977
25561
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25978
25562
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|
|
@@ -26016,17 +25600,9 @@ var SvgCanvasContext = class {
|
|
|
26016
25600
|
parent.children.push(textElement);
|
|
26017
25601
|
}
|
|
26018
25602
|
_clearCanvas() {
|
|
26019
|
-
const rootGroup = this._root.children[1];
|
|
26020
25603
|
this._defs.children = [];
|
|
26021
|
-
this._root.children = this.
|
|
26022
|
-
|
|
26023
|
-
);
|
|
26024
|
-
this._currentGroup = {
|
|
26025
|
-
tag: "g",
|
|
26026
|
-
attrs: {},
|
|
26027
|
-
children: []
|
|
26028
|
-
};
|
|
26029
|
-
this._root.children.push(this._currentGroup);
|
|
25604
|
+
this._root.children = [this._defs];
|
|
25605
|
+
this._currentGroup = this._root;
|
|
26030
25606
|
this._groupStack = [];
|
|
26031
25607
|
}
|
|
26032
25608
|
};
|
|
@@ -26045,6 +25621,359 @@ async function toSvgNode(ctx) {
|
|
|
26045
25621
|
return ctx.getNode();
|
|
26046
25622
|
}
|
|
26047
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
|
+
|
|
26048
25977
|
// src/lib/TextLayer.ts
|
|
26049
25978
|
function isTextNode(node) {
|
|
26050
25979
|
return node.role === "text";
|
|
@@ -26059,16 +25988,6 @@ var MAX_TEXT_DIVS_TO_RENDER2 = 1e5;
|
|
|
26059
25988
|
var DEFAULT_FONT_SIZE3 = 30;
|
|
26060
25989
|
var DEFAULT_FONT_ASCENT = 0.8;
|
|
26061
25990
|
var HYPHEN_REGEX = /-\n+$/;
|
|
26062
|
-
function getDefaultFontFamily(type) {
|
|
26063
|
-
switch (type) {
|
|
26064
|
-
case "serif":
|
|
26065
|
-
return "Liberation Serif";
|
|
26066
|
-
case "monospace":
|
|
26067
|
-
return "Liberation Mono";
|
|
26068
|
-
default:
|
|
26069
|
-
return "Liberation Sans";
|
|
26070
|
-
}
|
|
26071
|
-
}
|
|
26072
25991
|
async function createTextLayer(page, {
|
|
26073
25992
|
canvasFactory,
|
|
26074
25993
|
viewport = page.getViewport({ scale: 1 }),
|
|
@@ -26208,7 +26127,7 @@ async function createTextLayer(page, {
|
|
|
26208
26127
|
}
|
|
26209
26128
|
if (shouldScaleText) {
|
|
26210
26129
|
if (canvasContext) {
|
|
26211
|
-
canvasContext.font =
|
|
26130
|
+
canvasContext.font = `400 ${fontHeight * outputScale}px 'Liberation Sans'`;
|
|
26212
26131
|
const { width } = canvasContext.measureText(geom.str);
|
|
26213
26132
|
if (width > 0) {
|
|
26214
26133
|
textDiv.scale = (style.vertical ? geom.height : geom.width) * outputScale / width;
|
|
@@ -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,6 +26463,7 @@ export {
|
|
|
26543
26463
|
GlobalWorkerOptions,
|
|
26544
26464
|
ImageKind,
|
|
26545
26465
|
InvalidPDFException,
|
|
26466
|
+
MathClamp,
|
|
26546
26467
|
OPS,
|
|
26547
26468
|
OutputScale,
|
|
26548
26469
|
PDFDataRangeTransport,
|
|
@@ -26570,7 +26491,6 @@ export {
|
|
|
26570
26491
|
createTextLayer,
|
|
26571
26492
|
createValidAbsoluteUrl,
|
|
26572
26493
|
fetchData,
|
|
26573
|
-
getDefaultFontFamily,
|
|
26574
26494
|
getDocument,
|
|
26575
26495
|
getFilenameFromUrl,
|
|
26576
26496
|
getPdfFilenameFromUrl,
|
|
@@ -26610,9 +26530,11 @@ export {
|
|
|
26610
26530
|
isThreeDAnnotation,
|
|
26611
26531
|
isTrapNetAnnotation,
|
|
26612
26532
|
isUnderlineAnnotation,
|
|
26533
|
+
isValidExplicitDest,
|
|
26613
26534
|
isWatermarkAnnotation,
|
|
26614
26535
|
isWidgetAnnotation,
|
|
26615
26536
|
loadDefaultFonts,
|
|
26537
|
+
makeSerializable,
|
|
26616
26538
|
noContextMenu,
|
|
26617
26539
|
normalizeUnicode,
|
|
26618
26540
|
setLayerDimensions,
|