@chialab/pdfjs-lib 1.0.0-alpha.0 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{chunk-DYHYQ33L.js → chunk-AK2AE3GS.js} +177 -43
- package/dist/browser/index.js +921 -1009
- package/dist/browser/worker.js +5827 -5389
- package/dist/index.d.ts +1 -0
- package/dist/lib/AnnotationData.d.ts +2 -1
- package/dist/lib/AnnotationOperatorsList.d.ts +21 -0
- package/dist/lib/SvgCanvasContext.d.ts +3 -2
- package/dist/lib/TextLayer.d.ts +0 -6
- package/dist/lib/utils.d.ts +9 -1
- package/dist/node/{chunk-KTTVPO2G.js → chunk-WL32POZ2.js} +177 -43
- package/dist/node/index.js +927 -1002
- package/dist/node/worker.js +5827 -5389
- package/dist/pdf.js/src/display/api.d.ts +30 -5
- package/dist/pdf.js/src/display/canvas.d.ts +19 -27
- package/dist/pdf.js/src/display/display_utils.d.ts +10 -0
- package/dist/pdf.js/src/display/editor/editor.d.ts +1 -1
- package/dist/pdf.js/src/display/editor/highlight.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/ink.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/signature.d.ts +1 -0
- package/dist/pdf.js/src/display/editor/stamp.d.ts +1 -2
- package/dist/pdf.js/src/display/editor/tools.d.ts +0 -6
- package/dist/pdf.js/src/display/pattern_helper.d.ts +4 -2
- package/dist/pdf.js/src/display/touch_manager.d.ts +5 -1
- package/dist/pdf.js/src/pdf.d.ts +3 -1
- package/dist/pdf.js/src/shared/util.d.ts +111 -95
- package/package.json +7 -5
- package/dist/browser/LiberationMono-Regular-UUOCTXY2.js +0 -9
- package/dist/browser/LiberationSerif-Regular-ASQ2LI3D.js +0 -9
- package/dist/node/LiberationMono-Regular-KMFXXO3B.js +0 -9
- package/dist/node/LiberationSerif-Regular-WAOWR76G.js +0 -9
package/dist/browser/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-AK2AE3GS.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);
|
|
@@ -5334,43 +5373,24 @@ _serializable = new WeakMap();
|
|
|
5334
5373
|
// src/lib/Canvas.ts
|
|
5335
5374
|
var Path2DConstructor = Path2D;
|
|
5336
5375
|
async function createCanvas(width, height) {
|
|
5376
|
+
await loadDefaultFonts();
|
|
5337
5377
|
const canvas = document.createElement("canvas");
|
|
5338
5378
|
canvas.width = width;
|
|
5339
5379
|
canvas.height = height;
|
|
5340
5380
|
return canvas;
|
|
5341
5381
|
}
|
|
5382
|
+
var loadingFontPromise = null;
|
|
5342
5383
|
async function loadDefaultFonts() {
|
|
5343
|
-
|
|
5344
|
-
import("./
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
(module) => new Blob([module.default], { type: "font/ttf" })
|
|
5352
|
-
)
|
|
5353
|
-
]);
|
|
5354
|
-
const fontMono = new FontFace(
|
|
5355
|
-
"Liberation Mono",
|
|
5356
|
-
`url(${URL.createObjectURL(monoBlob)})`
|
|
5357
|
-
);
|
|
5358
|
-
const fontSans = new FontFace(
|
|
5359
|
-
"Liberation Sans",
|
|
5360
|
-
`url(${URL.createObjectURL(sansBlob)})`
|
|
5361
|
-
);
|
|
5362
|
-
const fontSerif = new FontFace(
|
|
5363
|
-
"Liberation Serif",
|
|
5364
|
-
`url(${URL.createObjectURL(serifBlob)})`
|
|
5365
|
-
);
|
|
5366
|
-
const fonts = await Promise.all([
|
|
5367
|
-
fontMono.load(),
|
|
5368
|
-
fontSans.load(),
|
|
5369
|
-
fontSerif.load()
|
|
5370
|
-
]);
|
|
5371
|
-
for (const font of fonts) {
|
|
5372
|
-
document.fonts.add(font);
|
|
5384
|
+
if (loadingFontPromise === null) {
|
|
5385
|
+
loadingFontPromise = import("./LiberationSans-Regular-KIF3IRJY.js").then((module) => new Blob([module.default], { type: "font/ttf" })).then(async (sansBlob) => {
|
|
5386
|
+
const fontSans = new FontFace(
|
|
5387
|
+
"Liberation Sans",
|
|
5388
|
+
`url(${URL.createObjectURL(sansBlob)})`
|
|
5389
|
+
);
|
|
5390
|
+
document.fonts.add(await fontSans.load());
|
|
5391
|
+
});
|
|
5373
5392
|
}
|
|
5393
|
+
return loadingFontPromise;
|
|
5374
5394
|
}
|
|
5375
5395
|
|
|
5376
5396
|
// src/lib/Path2D.ts
|
|
@@ -6056,6 +6076,9 @@ var BaseShadingPattern = class {
|
|
|
6056
6076
|
unreachable("Cannot initialize BaseShadingPattern.");
|
|
6057
6077
|
}
|
|
6058
6078
|
}
|
|
6079
|
+
isModifyingCurrentTransform() {
|
|
6080
|
+
return false;
|
|
6081
|
+
}
|
|
6059
6082
|
getPattern() {
|
|
6060
6083
|
unreachable("Abstract method `getPattern` called.");
|
|
6061
6084
|
}
|
|
@@ -6354,17 +6377,22 @@ var MeshShadingPattern = class extends BaseShadingPattern {
|
|
|
6354
6377
|
scaleY
|
|
6355
6378
|
};
|
|
6356
6379
|
}
|
|
6380
|
+
isModifyingCurrentTransform() {
|
|
6381
|
+
return true;
|
|
6382
|
+
}
|
|
6357
6383
|
getPattern(ctx, owner, inverse, pathType) {
|
|
6358
6384
|
applyBoundingBox(ctx, this._bbox);
|
|
6359
|
-
|
|
6385
|
+
const scale = new Float32Array(2);
|
|
6360
6386
|
if (pathType === PathType.SHADING) {
|
|
6361
|
-
|
|
6387
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(ctx), scale);
|
|
6388
|
+
} else if (this.matrix) {
|
|
6389
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
6390
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
6391
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
6392
|
+
scale[0] *= matrixScaleX;
|
|
6393
|
+
scale[1] *= matrixScaleY;
|
|
6362
6394
|
} else {
|
|
6363
|
-
|
|
6364
|
-
if (this.matrix) {
|
|
6365
|
-
const matrixScale = Util.singularValueDecompose2dScale(this.matrix);
|
|
6366
|
-
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
|
|
6367
|
-
}
|
|
6395
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
6368
6396
|
}
|
|
6369
6397
|
const temporaryPatternCanvas = this._createMeshCanvas(
|
|
6370
6398
|
scale,
|
|
@@ -6406,7 +6434,8 @@ var PaintType = {
|
|
|
6406
6434
|
UNCOLORED: 2
|
|
6407
6435
|
};
|
|
6408
6436
|
var _TilingPattern = class _TilingPattern {
|
|
6409
|
-
constructor(IR,
|
|
6437
|
+
constructor(IR, ctx, canvasGraphicsFactory, baseTransform) {
|
|
6438
|
+
this.color = IR[1];
|
|
6410
6439
|
this.operatorList = IR[2];
|
|
6411
6440
|
this.matrix = IR[3];
|
|
6412
6441
|
this.bbox = IR[4];
|
|
@@ -6414,7 +6443,6 @@ var _TilingPattern = class _TilingPattern {
|
|
|
6414
6443
|
this.ystep = IR[6];
|
|
6415
6444
|
this.paintType = IR[7];
|
|
6416
6445
|
this.tilingType = IR[8];
|
|
6417
|
-
this.color = color;
|
|
6418
6446
|
this.ctx = ctx;
|
|
6419
6447
|
this.canvasGraphicsFactory = canvasGraphicsFactory;
|
|
6420
6448
|
this.baseTransform = baseTransform;
|
|
@@ -6435,12 +6463,12 @@ var _TilingPattern = class _TilingPattern {
|
|
|
6435
6463
|
const x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
|
6436
6464
|
const width = x1 - x0;
|
|
6437
6465
|
const height = y1 - y0;
|
|
6438
|
-
const
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
);
|
|
6442
|
-
const combinedScaleX =
|
|
6443
|
-
const combinedScaleY =
|
|
6466
|
+
const scale = new Float32Array(2);
|
|
6467
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
6468
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
6469
|
+
Util.singularValueDecompose2dScale(this.baseTransform, scale);
|
|
6470
|
+
const combinedScaleX = matrixScaleX * scale[0];
|
|
6471
|
+
const combinedScaleY = matrixScaleY * scale[1];
|
|
6444
6472
|
let canvasWidth = width, canvasHeight = height, redrawHorizontally = false, redrawVertically = false;
|
|
6445
6473
|
const xScaledStep = Math.ceil(xstep * combinedScaleX);
|
|
6446
6474
|
const yScaledStep = Math.ceil(ystep * combinedScaleY);
|
|
@@ -6556,12 +6584,11 @@ var _TilingPattern = class _TilingPattern {
|
|
|
6556
6584
|
const bboxWidth = x1 - x0;
|
|
6557
6585
|
const bboxHeight = y1 - y0;
|
|
6558
6586
|
graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
|
|
6559
|
-
|
|
6560
|
-
x0,
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
]);
|
|
6587
|
+
Util.axialAlignedBoundingBox(
|
|
6588
|
+
[x0, y0, x1, y1],
|
|
6589
|
+
getCurrentTransform(graphics.ctx),
|
|
6590
|
+
graphics.current.minMax
|
|
6591
|
+
);
|
|
6565
6592
|
graphics.clip();
|
|
6566
6593
|
graphics.endPath();
|
|
6567
6594
|
}
|
|
@@ -6586,6 +6613,9 @@ var _TilingPattern = class _TilingPattern {
|
|
|
6586
6613
|
throw new FormatError(`Unsupported paint type: ${paintType}`);
|
|
6587
6614
|
}
|
|
6588
6615
|
}
|
|
6616
|
+
isModifyingCurrentTransform() {
|
|
6617
|
+
return false;
|
|
6618
|
+
}
|
|
6589
6619
|
getPattern(ctx, owner, inverse, pathType) {
|
|
6590
6620
|
let matrix = inverse;
|
|
6591
6621
|
if (pathType !== PathType.SHADING) {
|
|
@@ -6618,8 +6648,15 @@ var MIN_FONT_SIZE = 16;
|
|
|
6618
6648
|
var MAX_FONT_SIZE = 100;
|
|
6619
6649
|
var EXECUTION_TIME = 15;
|
|
6620
6650
|
var EXECUTION_STEPS = 10;
|
|
6621
|
-
var MAX_SIZE_TO_COMPILE = 1e3;
|
|
6622
6651
|
var FULL_CHUNK_HEIGHT = 16;
|
|
6652
|
+
var SCALE_MATRIX = new DOMMatrix();
|
|
6653
|
+
var XY = new Float32Array(2);
|
|
6654
|
+
var MIN_MAX_INIT = new Float32Array([
|
|
6655
|
+
Infinity,
|
|
6656
|
+
Infinity,
|
|
6657
|
+
-Infinity,
|
|
6658
|
+
-Infinity
|
|
6659
|
+
]);
|
|
6623
6660
|
function mirrorContextOperations(ctx, destCtx) {
|
|
6624
6661
|
if (ctx._removeMirroring) {
|
|
6625
6662
|
throw new Error("Context is already forwarding operations.");
|
|
@@ -6657,39 +6694,39 @@ function mirrorContextOperations(ctx, destCtx) {
|
|
|
6657
6694
|
ctx.beginPath = ctx.__originalBeginPath;
|
|
6658
6695
|
delete ctx._removeMirroring;
|
|
6659
6696
|
};
|
|
6660
|
-
ctx.save = function
|
|
6697
|
+
ctx.save = function() {
|
|
6661
6698
|
destCtx.save();
|
|
6662
6699
|
this.__originalSave();
|
|
6663
6700
|
};
|
|
6664
|
-
ctx.restore = function
|
|
6701
|
+
ctx.restore = function() {
|
|
6665
6702
|
destCtx.restore();
|
|
6666
6703
|
this.__originalRestore();
|
|
6667
6704
|
};
|
|
6668
|
-
ctx.translate = function
|
|
6705
|
+
ctx.translate = function(x, y) {
|
|
6669
6706
|
destCtx.translate(x, y);
|
|
6670
6707
|
this.__originalTranslate(x, y);
|
|
6671
6708
|
};
|
|
6672
|
-
ctx.scale = function
|
|
6709
|
+
ctx.scale = function(x, y) {
|
|
6673
6710
|
destCtx.scale(x, y);
|
|
6674
6711
|
this.__originalScale(x, y);
|
|
6675
6712
|
};
|
|
6676
|
-
ctx.transform = function
|
|
6713
|
+
ctx.transform = function(a, b, c, d, e, f) {
|
|
6677
6714
|
destCtx.transform(a, b, c, d, e, f);
|
|
6678
6715
|
this.__originalTransform(a, b, c, d, e, f);
|
|
6679
6716
|
};
|
|
6680
|
-
ctx.setTransform = function
|
|
6717
|
+
ctx.setTransform = function(a, b, c, d, e, f) {
|
|
6681
6718
|
destCtx.setTransform(a, b, c, d, e, f);
|
|
6682
6719
|
this.__originalSetTransform(a, b, c, d, e, f);
|
|
6683
6720
|
};
|
|
6684
|
-
ctx.resetTransform = function
|
|
6721
|
+
ctx.resetTransform = function() {
|
|
6685
6722
|
destCtx.resetTransform();
|
|
6686
6723
|
this.__originalResetTransform();
|
|
6687
6724
|
};
|
|
6688
|
-
ctx.rotate = function
|
|
6725
|
+
ctx.rotate = function(angle) {
|
|
6689
6726
|
destCtx.rotate(angle);
|
|
6690
6727
|
this.__originalRotate(angle);
|
|
6691
6728
|
};
|
|
6692
|
-
ctx.clip = function
|
|
6729
|
+
ctx.clip = function(rule) {
|
|
6693
6730
|
destCtx.clip(rule);
|
|
6694
6731
|
this.__originalClip(rule);
|
|
6695
6732
|
};
|
|
@@ -6780,227 +6817,57 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
6780
6817
|
const scaleY = Math.hypot(c, d);
|
|
6781
6818
|
return [scaleX * destW, scaleY * destH];
|
|
6782
6819
|
}
|
|
6783
|
-
function compileType3Glyph(imgData) {
|
|
6784
|
-
const { width, height } = imgData;
|
|
6785
|
-
if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
6786
|
-
return null;
|
|
6787
|
-
}
|
|
6788
|
-
const POINT_TO_PROCESS_LIMIT = 1e3;
|
|
6789
|
-
const POINT_TYPES = new Uint8Array([
|
|
6790
|
-
0,
|
|
6791
|
-
2,
|
|
6792
|
-
4,
|
|
6793
|
-
0,
|
|
6794
|
-
1,
|
|
6795
|
-
0,
|
|
6796
|
-
5,
|
|
6797
|
-
4,
|
|
6798
|
-
8,
|
|
6799
|
-
10,
|
|
6800
|
-
0,
|
|
6801
|
-
8,
|
|
6802
|
-
0,
|
|
6803
|
-
2,
|
|
6804
|
-
1,
|
|
6805
|
-
0
|
|
6806
|
-
]);
|
|
6807
|
-
const width1 = width + 1;
|
|
6808
|
-
let points = new Uint8Array(width1 * (height + 1));
|
|
6809
|
-
let i, j, j0;
|
|
6810
|
-
const lineSize = width + 7 & ~7;
|
|
6811
|
-
let data = new Uint8Array(lineSize * height), pos = 0;
|
|
6812
|
-
for (const elem of imgData.data) {
|
|
6813
|
-
let mask = 128;
|
|
6814
|
-
while (mask > 0) {
|
|
6815
|
-
data[pos++] = elem & mask ? 0 : 255;
|
|
6816
|
-
mask >>= 1;
|
|
6817
|
-
}
|
|
6818
|
-
}
|
|
6819
|
-
let count = 0;
|
|
6820
|
-
pos = 0;
|
|
6821
|
-
if (data[pos] !== 0) {
|
|
6822
|
-
points[0] = 1;
|
|
6823
|
-
++count;
|
|
6824
|
-
}
|
|
6825
|
-
for (j = 1; j < width; j++) {
|
|
6826
|
-
if (data[pos] !== data[pos + 1]) {
|
|
6827
|
-
points[j] = data[pos] ? 2 : 1;
|
|
6828
|
-
++count;
|
|
6829
|
-
}
|
|
6830
|
-
pos++;
|
|
6831
|
-
}
|
|
6832
|
-
if (data[pos] !== 0) {
|
|
6833
|
-
points[j] = 2;
|
|
6834
|
-
++count;
|
|
6835
|
-
}
|
|
6836
|
-
for (i = 1; i < height; i++) {
|
|
6837
|
-
pos = i * lineSize;
|
|
6838
|
-
j0 = i * width1;
|
|
6839
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
6840
|
-
points[j0] = data[pos] ? 1 : 8;
|
|
6841
|
-
++count;
|
|
6842
|
-
}
|
|
6843
|
-
let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
|
6844
|
-
for (j = 1; j < width; j++) {
|
|
6845
|
-
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
|
|
6846
|
-
if (POINT_TYPES[sum]) {
|
|
6847
|
-
points[j0 + j] = POINT_TYPES[sum];
|
|
6848
|
-
++count;
|
|
6849
|
-
}
|
|
6850
|
-
pos++;
|
|
6851
|
-
}
|
|
6852
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
6853
|
-
points[j0 + j] = data[pos] ? 2 : 4;
|
|
6854
|
-
++count;
|
|
6855
|
-
}
|
|
6856
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
6857
|
-
return null;
|
|
6858
|
-
}
|
|
6859
|
-
}
|
|
6860
|
-
pos = lineSize * (height - 1);
|
|
6861
|
-
j0 = i * width1;
|
|
6862
|
-
if (data[pos] !== 0) {
|
|
6863
|
-
points[j0] = 8;
|
|
6864
|
-
++count;
|
|
6865
|
-
}
|
|
6866
|
-
for (j = 1; j < width; j++) {
|
|
6867
|
-
if (data[pos] !== data[pos + 1]) {
|
|
6868
|
-
points[j0 + j] = data[pos] ? 4 : 8;
|
|
6869
|
-
++count;
|
|
6870
|
-
}
|
|
6871
|
-
pos++;
|
|
6872
|
-
}
|
|
6873
|
-
if (data[pos] !== 0) {
|
|
6874
|
-
points[j0 + j] = 4;
|
|
6875
|
-
++count;
|
|
6876
|
-
}
|
|
6877
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
6878
|
-
return null;
|
|
6879
|
-
}
|
|
6880
|
-
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
6881
|
-
const path = new SvgPath2D();
|
|
6882
|
-
for (i = 0; count && i <= height; i++) {
|
|
6883
|
-
let p = i * width1;
|
|
6884
|
-
const end = p + width;
|
|
6885
|
-
while (p < end && !points[p]) {
|
|
6886
|
-
p++;
|
|
6887
|
-
}
|
|
6888
|
-
if (p === end) {
|
|
6889
|
-
continue;
|
|
6890
|
-
}
|
|
6891
|
-
path.moveTo(p % width1, i);
|
|
6892
|
-
const p0 = p;
|
|
6893
|
-
let type = points[p];
|
|
6894
|
-
do {
|
|
6895
|
-
const step = steps[type];
|
|
6896
|
-
do {
|
|
6897
|
-
p += step;
|
|
6898
|
-
} while (!points[p]);
|
|
6899
|
-
const pp = points[p];
|
|
6900
|
-
if (pp !== 5 && pp !== 10) {
|
|
6901
|
-
type = pp;
|
|
6902
|
-
points[p] = 0;
|
|
6903
|
-
} else {
|
|
6904
|
-
type = pp & 51 * type >> 4;
|
|
6905
|
-
points[p] &= type >> 2 | type << 2;
|
|
6906
|
-
}
|
|
6907
|
-
path.lineTo(p % width1, p / width1 | 0);
|
|
6908
|
-
if (!points[p]) {
|
|
6909
|
-
--count;
|
|
6910
|
-
}
|
|
6911
|
-
} while (p0 !== p);
|
|
6912
|
-
--i;
|
|
6913
|
-
}
|
|
6914
|
-
data = null;
|
|
6915
|
-
points = null;
|
|
6916
|
-
const drawOutline = function(c) {
|
|
6917
|
-
c.save();
|
|
6918
|
-
c.scale(1 / width, -1 / height);
|
|
6919
|
-
c.translate(0, -height);
|
|
6920
|
-
c.fill(path);
|
|
6921
|
-
c.beginPath();
|
|
6922
|
-
c.restore();
|
|
6923
|
-
};
|
|
6924
|
-
return drawOutline;
|
|
6925
|
-
}
|
|
6926
6820
|
var CanvasExtraState = class {
|
|
6927
6821
|
constructor(width, height) {
|
|
6928
|
-
|
|
6929
|
-
this
|
|
6930
|
-
this
|
|
6931
|
-
this
|
|
6932
|
-
this
|
|
6933
|
-
this
|
|
6934
|
-
this
|
|
6935
|
-
this
|
|
6936
|
-
|
|
6937
|
-
this
|
|
6938
|
-
this
|
|
6939
|
-
|
|
6940
|
-
this
|
|
6941
|
-
this
|
|
6942
|
-
|
|
6943
|
-
this
|
|
6944
|
-
this
|
|
6945
|
-
this
|
|
6946
|
-
this
|
|
6947
|
-
this
|
|
6948
|
-
|
|
6949
|
-
this
|
|
6950
|
-
this
|
|
6951
|
-
this
|
|
6952
|
-
this
|
|
6953
|
-
|
|
6822
|
+
// Are soft masks and alpha values shapes or opacities?
|
|
6823
|
+
__publicField(this, "alphaIsShape", false);
|
|
6824
|
+
__publicField(this, "fontSize", 0);
|
|
6825
|
+
__publicField(this, "fontSizeScale", 1);
|
|
6826
|
+
__publicField(this, "textMatrix", null);
|
|
6827
|
+
__publicField(this, "textMatrixScale", 1);
|
|
6828
|
+
__publicField(this, "fontMatrix", FONT_IDENTITY_MATRIX);
|
|
6829
|
+
__publicField(this, "leading", 0);
|
|
6830
|
+
// Current point (in user coordinates)
|
|
6831
|
+
__publicField(this, "x", 0);
|
|
6832
|
+
__publicField(this, "y", 0);
|
|
6833
|
+
// Start of text line (in text coordinates)
|
|
6834
|
+
__publicField(this, "lineX", 0);
|
|
6835
|
+
__publicField(this, "lineY", 0);
|
|
6836
|
+
// Character and word spacing
|
|
6837
|
+
__publicField(this, "charSpacing", 0);
|
|
6838
|
+
__publicField(this, "wordSpacing", 0);
|
|
6839
|
+
__publicField(this, "textHScale", 1);
|
|
6840
|
+
__publicField(this, "textRenderingMode", TextRenderingMode.FILL);
|
|
6841
|
+
__publicField(this, "textRise", 0);
|
|
6842
|
+
// Default fore and background colors
|
|
6843
|
+
__publicField(this, "fillColor", "#000000");
|
|
6844
|
+
__publicField(this, "strokeColor", "#000000");
|
|
6845
|
+
__publicField(this, "patternFill", false);
|
|
6846
|
+
__publicField(this, "patternStroke", false);
|
|
6847
|
+
// Note: fill alpha applies to all non-stroking operations
|
|
6848
|
+
__publicField(this, "fillAlpha", 1);
|
|
6849
|
+
__publicField(this, "strokeAlpha", 1);
|
|
6850
|
+
__publicField(this, "lineWidth", 1);
|
|
6851
|
+
__publicField(this, "activeSMask", null);
|
|
6852
|
+
__publicField(this, "transferMaps", "none");
|
|
6853
|
+
this.clipBox = new Float32Array([0, 0, width, height]);
|
|
6854
|
+
this.minMax = MIN_MAX_INIT.slice();
|
|
6954
6855
|
}
|
|
6955
6856
|
clone() {
|
|
6956
6857
|
const clone = Object.create(this);
|
|
6957
6858
|
clone.clipBox = this.clipBox.slice();
|
|
6859
|
+
clone.minMax = this.minMax.slice();
|
|
6958
6860
|
return clone;
|
|
6959
6861
|
}
|
|
6960
|
-
setCurrentPoint(x, y) {
|
|
6961
|
-
this.x = x;
|
|
6962
|
-
this.y = y;
|
|
6963
|
-
}
|
|
6964
|
-
updatePathMinMax(transform, x, y) {
|
|
6965
|
-
[x, y] = Util.applyTransform([x, y], transform);
|
|
6966
|
-
this.minX = Math.min(this.minX, x);
|
|
6967
|
-
this.minY = Math.min(this.minY, y);
|
|
6968
|
-
this.maxX = Math.max(this.maxX, x);
|
|
6969
|
-
this.maxY = Math.max(this.maxY, y);
|
|
6970
|
-
}
|
|
6971
|
-
updateRectMinMax(transform, rect) {
|
|
6972
|
-
const p1 = Util.applyTransform(rect, transform);
|
|
6973
|
-
const p2 = Util.applyTransform(rect.slice(2), transform);
|
|
6974
|
-
const p3 = Util.applyTransform([rect[0], rect[3]], transform);
|
|
6975
|
-
const p4 = Util.applyTransform([rect[2], rect[1]], transform);
|
|
6976
|
-
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
|
6977
|
-
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
|
6978
|
-
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
|
6979
|
-
this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]);
|
|
6980
|
-
}
|
|
6981
|
-
updateScalingPathMinMax(transform, minMax) {
|
|
6982
|
-
Util.scaleMinMax(transform, minMax);
|
|
6983
|
-
this.minX = Math.min(this.minX, minMax[0]);
|
|
6984
|
-
this.minY = Math.min(this.minY, minMax[1]);
|
|
6985
|
-
this.maxX = Math.max(this.maxX, minMax[2]);
|
|
6986
|
-
this.maxY = Math.max(this.maxY, minMax[3]);
|
|
6987
|
-
}
|
|
6988
|
-
updateCurvePathMinMax(transform, x0, y0, x1, y1, x2, y2, x3, y3, minMax) {
|
|
6989
|
-
const box = Util.bezierBoundingBox(x0, y0, x1, y1, x2, y2, x3, y3, minMax);
|
|
6990
|
-
if (minMax) {
|
|
6991
|
-
return;
|
|
6992
|
-
}
|
|
6993
|
-
this.updateRectMinMax(transform, box);
|
|
6994
|
-
}
|
|
6995
6862
|
getPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
6996
|
-
const box =
|
|
6863
|
+
const box = this.minMax.slice();
|
|
6997
6864
|
if (pathType === PathType.STROKE) {
|
|
6998
6865
|
if (!transform) {
|
|
6999
6866
|
unreachable("Stroke bounding box must include transform.");
|
|
7000
6867
|
}
|
|
7001
|
-
|
|
7002
|
-
const xStrokePad =
|
|
7003
|
-
const yStrokePad =
|
|
6868
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
6869
|
+
const xStrokePad = XY[0] * this.lineWidth / 2;
|
|
6870
|
+
const yStrokePad = XY[1] * this.lineWidth / 2;
|
|
7004
6871
|
box[0] -= xStrokePad;
|
|
7005
6872
|
box[1] -= yStrokePad;
|
|
7006
6873
|
box[2] += xStrokePad;
|
|
@@ -7013,14 +6880,11 @@ var CanvasExtraState = class {
|
|
|
7013
6880
|
this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]);
|
|
7014
6881
|
}
|
|
7015
6882
|
isEmptyClip() {
|
|
7016
|
-
return this.
|
|
6883
|
+
return this.minMax[0] === Infinity;
|
|
7017
6884
|
}
|
|
7018
6885
|
startNewPathAndClipBox(box) {
|
|
7019
|
-
this.clipBox
|
|
7020
|
-
this.
|
|
7021
|
-
this.minY = Infinity;
|
|
7022
|
-
this.maxX = 0;
|
|
7023
|
-
this.maxY = 0;
|
|
6886
|
+
this.clipBox.set(box, 0);
|
|
6887
|
+
this.minMax.set(MIN_MAX_INIT, 0);
|
|
7024
6888
|
}
|
|
7025
6889
|
getClippedPathBoundingBox(pathType = PathType.FILL, transform = null) {
|
|
7026
6890
|
return Util.intersect(
|
|
@@ -7184,24 +7048,20 @@ function resetCtxToDefault(ctx) {
|
|
|
7184
7048
|
ctx.setLineDash([]);
|
|
7185
7049
|
ctx.lineDashOffset = 0;
|
|
7186
7050
|
}
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
ctx.filter = "none";
|
|
7191
|
-
}
|
|
7051
|
+
const { filter } = ctx;
|
|
7052
|
+
if (filter !== "none" && filter !== "") {
|
|
7053
|
+
ctx.filter = "none";
|
|
7192
7054
|
}
|
|
7193
7055
|
}
|
|
7194
7056
|
function getImageSmoothingEnabled(transform, interpolate) {
|
|
7195
7057
|
if (interpolate) {
|
|
7196
7058
|
return true;
|
|
7197
7059
|
}
|
|
7198
|
-
|
|
7199
|
-
scale[0] = Math.fround(scale[0]);
|
|
7200
|
-
scale[1] = Math.fround(scale[1]);
|
|
7060
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7201
7061
|
const actualScale = Math.fround(
|
|
7202
|
-
|
|
7062
|
+
OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS
|
|
7203
7063
|
);
|
|
7204
|
-
return
|
|
7064
|
+
return XY[0] <= actualScale && XY[1] <= actualScale;
|
|
7205
7065
|
}
|
|
7206
7066
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
7207
7067
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
|
@@ -7226,7 +7086,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7226
7086
|
this.canvasFactory = canvasFactory;
|
|
7227
7087
|
this.filterFactory = filterFactory;
|
|
7228
7088
|
this.groupStack = [];
|
|
7229
|
-
this.processingType3 = null;
|
|
7230
7089
|
this.baseTransform = null;
|
|
7231
7090
|
this.baseTransformStack = [];
|
|
7232
7091
|
this.groupLevel = 0;
|
|
@@ -7447,10 +7306,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7447
7306
|
0
|
|
7448
7307
|
]);
|
|
7449
7308
|
maskToCanvas = Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
|
|
7450
|
-
const
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
);
|
|
7309
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
7310
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], maskToCanvas, minMax);
|
|
7311
|
+
const [minX, minY, maxX, maxY] = minMax;
|
|
7454
7312
|
const drawnWidth = Math.round(maxX - minX) || 1;
|
|
7455
7313
|
const drawnHeight = Math.round(maxY - minY) || 1;
|
|
7456
7314
|
const fillCanvas = this.cachedCanvases.getCanvas(
|
|
@@ -7569,8 +7427,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7569
7427
|
this.current.strokeAlpha = value;
|
|
7570
7428
|
break;
|
|
7571
7429
|
case "ca":
|
|
7572
|
-
this.current.fillAlpha = value;
|
|
7573
|
-
this.ctx.globalAlpha = value;
|
|
7430
|
+
this.ctx.globalAlpha = this.current.fillAlpha = value;
|
|
7574
7431
|
break;
|
|
7575
7432
|
case "BM":
|
|
7576
7433
|
this.ctx.globalCompositeOperation = value;
|
|
@@ -7619,16 +7476,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7619
7476
|
drawnHeight
|
|
7620
7477
|
);
|
|
7621
7478
|
this.suspendedCtx = this.ctx;
|
|
7622
|
-
this.ctx = scratchCanvas.context;
|
|
7623
|
-
|
|
7624
|
-
ctx.setTransform(...getCurrentTransform(this.suspendedCtx));
|
|
7479
|
+
const ctx = this.ctx = scratchCanvas.context;
|
|
7480
|
+
ctx.setTransform(this.suspendedCtx.getTransform());
|
|
7625
7481
|
copyCtxState(this.suspendedCtx, ctx);
|
|
7626
7482
|
mirrorContextOperations(ctx, this.suspendedCtx);
|
|
7627
|
-
this.setGState([
|
|
7628
|
-
["BM", "source-over"],
|
|
7629
|
-
["ca", 1],
|
|
7630
|
-
["CA", 1]
|
|
7631
|
-
]);
|
|
7483
|
+
this.setGState([["BM", "source-over"]]);
|
|
7632
7484
|
}
|
|
7633
7485
|
endSMaskMode() {
|
|
7634
7486
|
if (!this.inSMaskMode) {
|
|
@@ -7748,31 +7600,28 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7748
7600
|
save() {
|
|
7749
7601
|
if (this.inSMaskMode) {
|
|
7750
7602
|
copyCtxState(this.ctx, this.suspendedCtx);
|
|
7751
|
-
this.suspendedCtx.save();
|
|
7752
|
-
} else {
|
|
7753
|
-
this.ctx.save();
|
|
7754
7603
|
}
|
|
7604
|
+
this.ctx.save();
|
|
7755
7605
|
const old = this.current;
|
|
7756
7606
|
this.stateStack.push(old);
|
|
7757
7607
|
this.current = old.clone();
|
|
7758
7608
|
}
|
|
7759
7609
|
restore() {
|
|
7760
|
-
if (this.stateStack.length === 0
|
|
7761
|
-
this.endSMaskMode();
|
|
7762
|
-
}
|
|
7763
|
-
if (this.stateStack.length !== 0) {
|
|
7764
|
-
this.current = this.stateStack.pop();
|
|
7610
|
+
if (this.stateStack.length === 0) {
|
|
7765
7611
|
if (this.inSMaskMode) {
|
|
7766
|
-
this.
|
|
7767
|
-
copyCtxState(this.suspendedCtx, this.ctx);
|
|
7768
|
-
} else {
|
|
7769
|
-
this.ctx.restore();
|
|
7612
|
+
this.endSMaskMode();
|
|
7770
7613
|
}
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7614
|
+
return;
|
|
7615
|
+
}
|
|
7616
|
+
this.current = this.stateStack.pop();
|
|
7617
|
+
this.ctx.restore();
|
|
7618
|
+
if (this.inSMaskMode) {
|
|
7619
|
+
copyCtxState(this.suspendedCtx, this.ctx);
|
|
7775
7620
|
}
|
|
7621
|
+
this.checkSMaskState();
|
|
7622
|
+
this.pendingClip = null;
|
|
7623
|
+
this._cachedScaleForStroking[0] = -1;
|
|
7624
|
+
this._cachedGetSinglePixelWidth = null;
|
|
7776
7625
|
}
|
|
7777
7626
|
transform(a, b, c, d, e, f) {
|
|
7778
7627
|
this.ctx.transform(a, b, c, d, e, f);
|
|
@@ -7780,145 +7629,60 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7780
7629
|
this._cachedGetSinglePixelWidth = null;
|
|
7781
7630
|
}
|
|
7782
7631
|
// Path
|
|
7783
|
-
constructPath(
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
const isScalingMatrix = currentTransform[0] === 0 && currentTransform[3] === 0 || currentTransform[1] === 0 && currentTransform[2] === 0;
|
|
7790
|
-
const minMaxForBezier = isScalingMatrix ? minMax.slice(0) : null;
|
|
7791
|
-
for (let i = 0, j = 0, ii = ops.length; i < ii; i++) {
|
|
7792
|
-
switch (ops[i] | 0) {
|
|
7793
|
-
case OPS.rectangle:
|
|
7794
|
-
x = args[j++];
|
|
7795
|
-
y = args[j++];
|
|
7796
|
-
const width = args[j++];
|
|
7797
|
-
const height = args[j++];
|
|
7798
|
-
const xw = x + width;
|
|
7799
|
-
const yh = y + height;
|
|
7800
|
-
ctx.moveTo(x, y);
|
|
7801
|
-
if (width === 0 || height === 0) {
|
|
7802
|
-
ctx.lineTo(xw, yh);
|
|
7803
|
-
} else {
|
|
7804
|
-
ctx.lineTo(xw, y);
|
|
7805
|
-
ctx.lineTo(xw, yh);
|
|
7806
|
-
ctx.lineTo(x, yh);
|
|
7807
|
-
}
|
|
7808
|
-
if (!isScalingMatrix) {
|
|
7809
|
-
current.updateRectMinMax(currentTransform, [x, y, xw, yh]);
|
|
7810
|
-
}
|
|
7811
|
-
ctx.closePath();
|
|
7812
|
-
break;
|
|
7813
|
-
case OPS.moveTo:
|
|
7814
|
-
x = args[j++];
|
|
7815
|
-
y = args[j++];
|
|
7816
|
-
ctx.moveTo(x, y);
|
|
7817
|
-
if (!isScalingMatrix) {
|
|
7818
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
7819
|
-
}
|
|
7820
|
-
break;
|
|
7821
|
-
case OPS.lineTo:
|
|
7822
|
-
x = args[j++];
|
|
7823
|
-
y = args[j++];
|
|
7824
|
-
ctx.lineTo(x, y);
|
|
7825
|
-
if (!isScalingMatrix) {
|
|
7826
|
-
current.updatePathMinMax(currentTransform, x, y);
|
|
7827
|
-
}
|
|
7828
|
-
break;
|
|
7829
|
-
case OPS.curveTo:
|
|
7830
|
-
startX = x;
|
|
7831
|
-
startY = y;
|
|
7832
|
-
x = args[j + 4];
|
|
7833
|
-
y = args[j + 5];
|
|
7834
|
-
ctx.bezierCurveTo(
|
|
7835
|
-
args[j],
|
|
7836
|
-
args[j + 1],
|
|
7837
|
-
args[j + 2],
|
|
7838
|
-
args[j + 3],
|
|
7839
|
-
x,
|
|
7840
|
-
y
|
|
7841
|
-
);
|
|
7842
|
-
current.updateCurvePathMinMax(
|
|
7843
|
-
currentTransform,
|
|
7844
|
-
startX,
|
|
7845
|
-
startY,
|
|
7846
|
-
args[j],
|
|
7847
|
-
args[j + 1],
|
|
7848
|
-
args[j + 2],
|
|
7849
|
-
args[j + 3],
|
|
7850
|
-
x,
|
|
7851
|
-
y,
|
|
7852
|
-
minMaxForBezier
|
|
7853
|
-
);
|
|
7854
|
-
j += 6;
|
|
7855
|
-
break;
|
|
7856
|
-
case OPS.curveTo2:
|
|
7857
|
-
startX = x;
|
|
7858
|
-
startY = y;
|
|
7859
|
-
ctx.bezierCurveTo(
|
|
7860
|
-
x,
|
|
7861
|
-
y,
|
|
7862
|
-
args[j],
|
|
7863
|
-
args[j + 1],
|
|
7864
|
-
args[j + 2],
|
|
7865
|
-
args[j + 3]
|
|
7866
|
-
);
|
|
7867
|
-
current.updateCurvePathMinMax(
|
|
7868
|
-
currentTransform,
|
|
7869
|
-
startX,
|
|
7870
|
-
startY,
|
|
7871
|
-
x,
|
|
7872
|
-
y,
|
|
7873
|
-
args[j],
|
|
7874
|
-
args[j + 1],
|
|
7875
|
-
args[j + 2],
|
|
7876
|
-
args[j + 3],
|
|
7877
|
-
minMaxForBezier
|
|
7878
|
-
);
|
|
7879
|
-
x = args[j + 2];
|
|
7880
|
-
y = args[j + 3];
|
|
7881
|
-
j += 4;
|
|
7882
|
-
break;
|
|
7883
|
-
case OPS.curveTo3:
|
|
7884
|
-
startX = x;
|
|
7885
|
-
startY = y;
|
|
7886
|
-
x = args[j + 2];
|
|
7887
|
-
y = args[j + 3];
|
|
7888
|
-
ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
|
|
7889
|
-
current.updateCurvePathMinMax(
|
|
7890
|
-
currentTransform,
|
|
7891
|
-
startX,
|
|
7892
|
-
startY,
|
|
7893
|
-
args[j],
|
|
7894
|
-
args[j + 1],
|
|
7895
|
-
x,
|
|
7896
|
-
y,
|
|
7897
|
-
x,
|
|
7898
|
-
y,
|
|
7899
|
-
minMaxForBezier
|
|
7900
|
-
);
|
|
7901
|
-
j += 4;
|
|
7902
|
-
break;
|
|
7903
|
-
case OPS.closePath:
|
|
7904
|
-
ctx.closePath();
|
|
7905
|
-
break;
|
|
7906
|
-
}
|
|
7632
|
+
constructPath(op, data, minMax) {
|
|
7633
|
+
let [path] = data;
|
|
7634
|
+
if (!minMax) {
|
|
7635
|
+
path || (path = data[0] = new SvgPath2D());
|
|
7636
|
+
this[op](path);
|
|
7637
|
+
return;
|
|
7907
7638
|
}
|
|
7908
|
-
if (
|
|
7909
|
-
|
|
7639
|
+
if (!(path instanceof SvgPath2D)) {
|
|
7640
|
+
const path2d = data[0] = new SvgPath2D();
|
|
7641
|
+
for (let i = 0, ii = path.length; i < ii; ) {
|
|
7642
|
+
switch (path[i++]) {
|
|
7643
|
+
case DrawOPS.moveTo:
|
|
7644
|
+
path2d.moveTo(path[i++], path[i++]);
|
|
7645
|
+
break;
|
|
7646
|
+
case DrawOPS.lineTo:
|
|
7647
|
+
path2d.lineTo(path[i++], path[i++]);
|
|
7648
|
+
break;
|
|
7649
|
+
case DrawOPS.curveTo:
|
|
7650
|
+
path2d.bezierCurveTo(
|
|
7651
|
+
path[i++],
|
|
7652
|
+
path[i++],
|
|
7653
|
+
path[i++],
|
|
7654
|
+
path[i++],
|
|
7655
|
+
path[i++],
|
|
7656
|
+
path[i++]
|
|
7657
|
+
);
|
|
7658
|
+
break;
|
|
7659
|
+
case DrawOPS.closePath:
|
|
7660
|
+
path2d.closePath();
|
|
7661
|
+
break;
|
|
7662
|
+
default:
|
|
7663
|
+
warn(`Unrecognized drawing path operator: ${path[i - 1]}`);
|
|
7664
|
+
break;
|
|
7665
|
+
}
|
|
7666
|
+
}
|
|
7667
|
+
path = path2d;
|
|
7910
7668
|
}
|
|
7911
|
-
|
|
7669
|
+
Util.axialAlignedBoundingBox(
|
|
7670
|
+
minMax,
|
|
7671
|
+
getCurrentTransform(this.ctx),
|
|
7672
|
+
this.current.minMax
|
|
7673
|
+
);
|
|
7674
|
+
this[op](path);
|
|
7912
7675
|
}
|
|
7913
7676
|
closePath() {
|
|
7914
7677
|
this.ctx.closePath();
|
|
7915
7678
|
}
|
|
7916
|
-
stroke(consumePath = true) {
|
|
7679
|
+
stroke(path, consumePath = true) {
|
|
7917
7680
|
const ctx = this.ctx;
|
|
7918
7681
|
const strokeColor = this.current.strokeColor;
|
|
7919
7682
|
ctx.globalAlpha = this.current.strokeAlpha;
|
|
7920
7683
|
if (this.contentVisible) {
|
|
7921
7684
|
if (typeof strokeColor === "object" && strokeColor?.getPattern) {
|
|
7685
|
+
const baseTransform = strokeColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
7922
7686
|
ctx.save();
|
|
7923
7687
|
ctx.strokeStyle = strokeColor.getPattern(
|
|
7924
7688
|
ctx,
|
|
@@ -7926,33 +7690,49 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7926
7690
|
getCurrentTransformInverse(ctx),
|
|
7927
7691
|
PathType.STROKE
|
|
7928
7692
|
);
|
|
7693
|
+
if (baseTransform) {
|
|
7694
|
+
const newPath = new SvgPath2D();
|
|
7695
|
+
newPath.addPath(
|
|
7696
|
+
path,
|
|
7697
|
+
ctx.getTransform().invertSelf().multiplySelf(baseTransform)
|
|
7698
|
+
);
|
|
7699
|
+
path = newPath;
|
|
7700
|
+
}
|
|
7929
7701
|
this.rescaleAndStroke(
|
|
7702
|
+
path,
|
|
7930
7703
|
/* saveRestore */
|
|
7931
7704
|
false
|
|
7932
7705
|
);
|
|
7933
7706
|
ctx.restore();
|
|
7934
7707
|
} else {
|
|
7935
7708
|
this.rescaleAndStroke(
|
|
7709
|
+
path,
|
|
7936
7710
|
/* saveRestore */
|
|
7937
7711
|
true
|
|
7938
7712
|
);
|
|
7939
7713
|
}
|
|
7940
7714
|
}
|
|
7941
7715
|
if (consumePath) {
|
|
7942
|
-
this.consumePath(
|
|
7716
|
+
this.consumePath(
|
|
7717
|
+
path,
|
|
7718
|
+
this.current.getClippedPathBoundingBox(
|
|
7719
|
+
PathType.STROKE,
|
|
7720
|
+
getCurrentTransform(this.ctx)
|
|
7721
|
+
)
|
|
7722
|
+
);
|
|
7943
7723
|
}
|
|
7944
7724
|
ctx.globalAlpha = this.current.fillAlpha;
|
|
7945
7725
|
}
|
|
7946
|
-
closeStroke() {
|
|
7947
|
-
this.
|
|
7948
|
-
this.stroke();
|
|
7726
|
+
closeStroke(path) {
|
|
7727
|
+
this.stroke(path);
|
|
7949
7728
|
}
|
|
7950
|
-
fill(consumePath = true) {
|
|
7729
|
+
fill(path, consumePath = true) {
|
|
7951
7730
|
const ctx = this.ctx;
|
|
7952
7731
|
const fillColor = this.current.fillColor;
|
|
7953
7732
|
const isPatternFill = this.current.patternFill;
|
|
7954
7733
|
let needRestore = false;
|
|
7955
7734
|
if (isPatternFill) {
|
|
7735
|
+
const baseTransform = fillColor.isModifyingCurrentTransform() ? ctx.getTransform() : null;
|
|
7956
7736
|
ctx.save();
|
|
7957
7737
|
ctx.fillStyle = fillColor.getPattern(
|
|
7958
7738
|
ctx,
|
|
@@ -7960,48 +7740,57 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7960
7740
|
getCurrentTransformInverse(ctx),
|
|
7961
7741
|
PathType.FILL
|
|
7962
7742
|
);
|
|
7743
|
+
if (baseTransform) {
|
|
7744
|
+
const newPath = new SvgPath2D();
|
|
7745
|
+
newPath.addPath(
|
|
7746
|
+
path,
|
|
7747
|
+
ctx.getTransform().invertSelf().multiplySelf(baseTransform)
|
|
7748
|
+
);
|
|
7749
|
+
path = newPath;
|
|
7750
|
+
}
|
|
7963
7751
|
needRestore = true;
|
|
7964
7752
|
}
|
|
7965
7753
|
const intersect = this.current.getClippedPathBoundingBox();
|
|
7966
7754
|
if (this.contentVisible && intersect !== null) {
|
|
7967
7755
|
if (this.pendingEOFill) {
|
|
7968
|
-
ctx.fill("evenodd");
|
|
7756
|
+
ctx.fill(path, "evenodd");
|
|
7969
7757
|
this.pendingEOFill = false;
|
|
7970
7758
|
} else {
|
|
7971
|
-
ctx.fill();
|
|
7759
|
+
ctx.fill(path);
|
|
7972
7760
|
}
|
|
7973
7761
|
}
|
|
7974
7762
|
if (needRestore) {
|
|
7975
7763
|
ctx.restore();
|
|
7976
7764
|
}
|
|
7977
7765
|
if (consumePath) {
|
|
7978
|
-
this.consumePath(intersect);
|
|
7766
|
+
this.consumePath(path, intersect);
|
|
7979
7767
|
}
|
|
7980
7768
|
}
|
|
7981
|
-
eoFill() {
|
|
7769
|
+
eoFill(path) {
|
|
7982
7770
|
this.pendingEOFill = true;
|
|
7983
|
-
this.fill();
|
|
7771
|
+
this.fill(path);
|
|
7984
7772
|
}
|
|
7985
|
-
fillStroke() {
|
|
7986
|
-
this.fill(false);
|
|
7987
|
-
this.stroke(false);
|
|
7988
|
-
this.consumePath();
|
|
7773
|
+
fillStroke(path) {
|
|
7774
|
+
this.fill(path, false);
|
|
7775
|
+
this.stroke(path, false);
|
|
7776
|
+
this.consumePath(path);
|
|
7989
7777
|
}
|
|
7990
|
-
eoFillStroke() {
|
|
7778
|
+
eoFillStroke(path) {
|
|
7991
7779
|
this.pendingEOFill = true;
|
|
7992
|
-
this.fillStroke();
|
|
7780
|
+
this.fillStroke(path);
|
|
7993
7781
|
}
|
|
7994
|
-
closeFillStroke() {
|
|
7995
|
-
this.
|
|
7996
|
-
this.fillStroke();
|
|
7782
|
+
closeFillStroke(path) {
|
|
7783
|
+
this.fillStroke(path);
|
|
7997
7784
|
}
|
|
7998
|
-
closeEOFillStroke() {
|
|
7785
|
+
closeEOFillStroke(path) {
|
|
7999
7786
|
this.pendingEOFill = true;
|
|
8000
|
-
this.
|
|
8001
|
-
this.fillStroke();
|
|
7787
|
+
this.fillStroke(path);
|
|
8002
7788
|
}
|
|
8003
|
-
endPath() {
|
|
8004
|
-
this.consumePath();
|
|
7789
|
+
endPath(path) {
|
|
7790
|
+
this.consumePath(path);
|
|
7791
|
+
}
|
|
7792
|
+
rawFillPath(path) {
|
|
7793
|
+
this.ctx.fill(path);
|
|
8005
7794
|
}
|
|
8006
7795
|
// Clipping
|
|
8007
7796
|
clip() {
|
|
@@ -8012,7 +7801,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8012
7801
|
}
|
|
8013
7802
|
// Text
|
|
8014
7803
|
beginText() {
|
|
8015
|
-
this.current.textMatrix =
|
|
7804
|
+
this.current.textMatrix = null;
|
|
8016
7805
|
this.current.textMatrixScale = 1;
|
|
8017
7806
|
this.current.x = this.current.lineX = 0;
|
|
8018
7807
|
this.current.y = this.current.lineY = 0;
|
|
@@ -8021,7 +7810,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8021
7810
|
const paths = this.pendingTextPaths;
|
|
8022
7811
|
const ctx = this.ctx;
|
|
8023
7812
|
if (paths === void 0) {
|
|
8024
|
-
ctx.beginPath();
|
|
8025
7813
|
return;
|
|
8026
7814
|
}
|
|
8027
7815
|
const newPath = new SvgPath2D();
|
|
@@ -8033,7 +7821,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8033
7821
|
);
|
|
8034
7822
|
}
|
|
8035
7823
|
ctx.clip(newPath);
|
|
8036
|
-
ctx.beginPath();
|
|
8037
7824
|
delete this.pendingTextPaths;
|
|
8038
7825
|
}
|
|
8039
7826
|
setCharSpacing(spacing) {
|
|
@@ -8101,11 +7888,12 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8101
7888
|
this.setLeading(-y);
|
|
8102
7889
|
this.moveText(x, y);
|
|
8103
7890
|
}
|
|
8104
|
-
setTextMatrix(
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
7891
|
+
setTextMatrix(matrix) {
|
|
7892
|
+
const { current } = this;
|
|
7893
|
+
current.textMatrix = matrix;
|
|
7894
|
+
current.textMatrixScale = Math.hypot(matrix[0], matrix[1]);
|
|
7895
|
+
current.x = current.lineX = 0;
|
|
7896
|
+
current.y = current.lineY = 0;
|
|
8109
7897
|
}
|
|
8110
7898
|
nextLine() {
|
|
8111
7899
|
this.moveText(0, this.current.leading);
|
|
@@ -8152,8 +7940,8 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8152
7940
|
[a, b, c, d, 0, 0],
|
|
8153
7941
|
invPatternTransform
|
|
8154
7942
|
);
|
|
8155
|
-
|
|
8156
|
-
ctx.lineWidth *= Math.max(
|
|
7943
|
+
Util.singularValueDecompose2dScale(transf, XY);
|
|
7944
|
+
ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
|
|
8157
7945
|
ctx.stroke(
|
|
8158
7946
|
__privateMethod(this, _CanvasGraphics_instances, getScaledPath_fn).call(this, path, currentTransform, patternStrokeTransform)
|
|
8159
7947
|
);
|
|
@@ -8223,7 +8011,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8223
8011
|
const widthAdvanceScale = fontSize * current.fontMatrix[0];
|
|
8224
8012
|
const simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
|
8225
8013
|
ctx.save();
|
|
8226
|
-
|
|
8014
|
+
if (current.textMatrix) {
|
|
8015
|
+
ctx.transform(...current.textMatrix);
|
|
8016
|
+
}
|
|
8227
8017
|
ctx.translate(current.x, current.y + current.textRise);
|
|
8228
8018
|
if (fontDirection > 0) {
|
|
8229
8019
|
ctx.scale(textHScale, -1);
|
|
@@ -8378,7 +8168,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8378
8168
|
this._cachedScaleForStroking[0] = -1;
|
|
8379
8169
|
this._cachedGetSinglePixelWidth = null;
|
|
8380
8170
|
ctx.save();
|
|
8381
|
-
|
|
8171
|
+
if (current.textMatrix) {
|
|
8172
|
+
ctx.transform(...current.textMatrix);
|
|
8173
|
+
}
|
|
8382
8174
|
ctx.translate(current.x, current.y + current.textRise);
|
|
8383
8175
|
ctx.scale(textHScale, fontDirection);
|
|
8384
8176
|
for (i = 0; i < glyphsLength; ++i) {
|
|
@@ -8393,37 +8185,34 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8393
8185
|
const operatorList = font.charProcOperatorList[glyph.operatorListId];
|
|
8394
8186
|
if (!operatorList) {
|
|
8395
8187
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
|
8396
|
-
|
|
8397
|
-
}
|
|
8398
|
-
if (this.contentVisible) {
|
|
8399
|
-
this.processingType3 = glyph;
|
|
8188
|
+
} else if (this.contentVisible) {
|
|
8400
8189
|
this.save();
|
|
8401
8190
|
ctx.scale(fontSize, fontSize);
|
|
8402
8191
|
ctx.transform(...fontMatrix);
|
|
8403
8192
|
this.executeOperatorList(operatorList);
|
|
8404
8193
|
this.restore();
|
|
8405
8194
|
}
|
|
8406
|
-
const
|
|
8407
|
-
|
|
8195
|
+
const p = [glyph.width, 0];
|
|
8196
|
+
Util.applyTransform(p, fontMatrix);
|
|
8197
|
+
width = p[0] * fontSize + spacing;
|
|
8408
8198
|
ctx.translate(width, 0);
|
|
8409
8199
|
current.x += width * textHScale;
|
|
8410
8200
|
}
|
|
8411
8201
|
ctx.restore();
|
|
8412
|
-
this.processingType3 = null;
|
|
8413
8202
|
}
|
|
8414
8203
|
// Type3 fonts
|
|
8415
8204
|
setCharWidth(xWidth, yWidth) {
|
|
8416
8205
|
}
|
|
8417
8206
|
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
8418
|
-
|
|
8419
|
-
|
|
8207
|
+
const clip = new SvgPath2D();
|
|
8208
|
+
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
8209
|
+
this.ctx.clip(clip);
|
|
8420
8210
|
this.endPath();
|
|
8421
8211
|
}
|
|
8422
8212
|
// Color
|
|
8423
8213
|
getColorN_Pattern(IR) {
|
|
8424
8214
|
let pattern;
|
|
8425
8215
|
if (IR[0] === "TilingPattern") {
|
|
8426
|
-
const color = IR[1];
|
|
8427
8216
|
const baseTransform = this.baseTransform || getCurrentTransform(this.ctx);
|
|
8428
8217
|
const canvasGraphicsFactory = {
|
|
8429
8218
|
createCanvasGraphics: (ctx) => new _CanvasGraphics(
|
|
@@ -8440,7 +8229,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8440
8229
|
};
|
|
8441
8230
|
pattern = new TilingPattern(
|
|
8442
8231
|
IR,
|
|
8443
|
-
color,
|
|
8444
8232
|
this.ctx,
|
|
8445
8233
|
canvasGraphicsFactory,
|
|
8446
8234
|
baseTransform
|
|
@@ -8507,10 +8295,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8507
8295
|
const inv = getCurrentTransformInverse(ctx);
|
|
8508
8296
|
if (inv) {
|
|
8509
8297
|
const { width, height } = ctx.canvas;
|
|
8510
|
-
const
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
);
|
|
8298
|
+
const minMax = MIN_MAX_INIT.slice();
|
|
8299
|
+
Util.axialAlignedBoundingBox([0, 0, width, height], inv, minMax);
|
|
8300
|
+
const [x0, y0, x1, y1] = minMax;
|
|
8514
8301
|
this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
|
|
8515
8302
|
} else {
|
|
8516
8303
|
this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
|
|
@@ -8536,11 +8323,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8536
8323
|
}
|
|
8537
8324
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
8538
8325
|
if (bbox) {
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8326
|
+
Util.axialAlignedBoundingBox(
|
|
8327
|
+
bbox,
|
|
8328
|
+
this.baseTransform,
|
|
8329
|
+
this.current.minMax
|
|
8330
|
+
);
|
|
8331
|
+
const [x0, y0, x1, y1] = bbox;
|
|
8332
|
+
const clip = new SvgPath2D();
|
|
8333
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
8334
|
+
this.ctx.clip(clip);
|
|
8544
8335
|
this.endPath();
|
|
8545
8336
|
}
|
|
8546
8337
|
}
|
|
@@ -8574,9 +8365,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8574
8365
|
if (!group.bbox) {
|
|
8575
8366
|
throw new Error("Bounding box is required.");
|
|
8576
8367
|
}
|
|
8577
|
-
let bounds =
|
|
8368
|
+
let bounds = MIN_MAX_INIT.slice();
|
|
8369
|
+
Util.axialAlignedBoundingBox(
|
|
8578
8370
|
group.bbox,
|
|
8579
|
-
getCurrentTransform(currentCtx)
|
|
8371
|
+
getCurrentTransform(currentCtx),
|
|
8372
|
+
bounds
|
|
8580
8373
|
);
|
|
8581
8374
|
const canvasBounds = [
|
|
8582
8375
|
0,
|
|
@@ -8602,6 +8395,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8602
8395
|
const groupCtx = scratchCanvas.context;
|
|
8603
8396
|
groupCtx.translate(-offsetX, -offsetY);
|
|
8604
8397
|
groupCtx.transform(...currentTransform);
|
|
8398
|
+
let clip = new SvgPath2D();
|
|
8399
|
+
const [x0, y0, x1, y1] = group.bbox;
|
|
8400
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
8401
|
+
if (group.matrix) {
|
|
8402
|
+
const path = new SvgPath2D();
|
|
8403
|
+
path.addPath(clip, new DOMMatrix(group.matrix));
|
|
8404
|
+
clip = path;
|
|
8405
|
+
}
|
|
8406
|
+
groupCtx.clip(clip);
|
|
8605
8407
|
if (group.smask) {
|
|
8606
8408
|
this.smaskStack.push({
|
|
8607
8409
|
canvas: scratchCanvas.canvas,
|
|
@@ -8647,9 +8449,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8647
8449
|
this.restore();
|
|
8648
8450
|
this.ctx.save();
|
|
8649
8451
|
this.ctx.setTransform(...currentMtx);
|
|
8650
|
-
const dirtyBox =
|
|
8452
|
+
const dirtyBox = MIN_MAX_INIT.slice();
|
|
8453
|
+
Util.axialAlignedBoundingBox(
|
|
8651
8454
|
[0, 0, groupCtx.canvas.width, groupCtx.canvas.height],
|
|
8652
|
-
currentMtx
|
|
8455
|
+
currentMtx,
|
|
8456
|
+
dirtyBox
|
|
8653
8457
|
);
|
|
8654
8458
|
this.ctx.drawImage(groupCtx.canvas, 0, 0);
|
|
8655
8459
|
this.ctx.restore();
|
|
@@ -8675,9 +8479,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8675
8479
|
rect[0] = rect[1] = 0;
|
|
8676
8480
|
rect[2] = width;
|
|
8677
8481
|
rect[3] = height;
|
|
8678
|
-
|
|
8679
|
-
getCurrentTransform(this.ctx)
|
|
8680
|
-
);
|
|
8482
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);
|
|
8681
8483
|
const { viewportScale } = this;
|
|
8682
8484
|
const canvasWidth = Math.ceil(
|
|
8683
8485
|
width * this.outputScaleX * viewportScale
|
|
@@ -8694,14 +8496,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8694
8496
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
8695
8497
|
this.ctx = context;
|
|
8696
8498
|
this.ctx.save();
|
|
8697
|
-
this.ctx.setTransform(
|
|
8499
|
+
this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);
|
|
8698
8500
|
resetCtxToDefault(this.ctx);
|
|
8699
8501
|
} else {
|
|
8700
8502
|
resetCtxToDefault(this.ctx);
|
|
8701
8503
|
this.endPath();
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
this.ctx.
|
|
8504
|
+
const clip = new SvgPath2D();
|
|
8505
|
+
clip.rect(rect[0], rect[1], width, height);
|
|
8506
|
+
this.ctx.clip(clip);
|
|
8705
8507
|
}
|
|
8706
8508
|
}
|
|
8707
8509
|
this.current = new CanvasExtraState(
|
|
@@ -8728,16 +8530,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8728
8530
|
img = this.getObject(img.data, img);
|
|
8729
8531
|
img.count = count;
|
|
8730
8532
|
const ctx = this.ctx;
|
|
8731
|
-
const glyph = this.processingType3;
|
|
8732
|
-
if (glyph) {
|
|
8733
|
-
if (glyph.compiled === void 0) {
|
|
8734
|
-
glyph.compiled = compileType3Glyph(img);
|
|
8735
|
-
}
|
|
8736
|
-
if (glyph.compiled) {
|
|
8737
|
-
glyph.compiled(ctx);
|
|
8738
|
-
return;
|
|
8739
|
-
}
|
|
8740
|
-
}
|
|
8741
8533
|
const mask = this._createMaskCanvas(img);
|
|
8742
8534
|
const maskCanvas = mask.canvas;
|
|
8743
8535
|
ctx.save();
|
|
@@ -8773,8 +8565,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8773
8565
|
positions[i],
|
|
8774
8566
|
positions[i + 1]
|
|
8775
8567
|
]);
|
|
8776
|
-
|
|
8777
|
-
ctx.drawImage(mask.canvas, x, y);
|
|
8568
|
+
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
8778
8569
|
}
|
|
8779
8570
|
ctx.restore();
|
|
8780
8571
|
this.compose();
|
|
@@ -8891,11 +8682,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8891
8682
|
const height = imgData.height;
|
|
8892
8683
|
const ctx = this.ctx;
|
|
8893
8684
|
this.save();
|
|
8894
|
-
|
|
8895
|
-
|
|
8896
|
-
|
|
8897
|
-
ctx.filter = "none";
|
|
8898
|
-
}
|
|
8685
|
+
const { filter } = ctx;
|
|
8686
|
+
if (filter !== "none" && filter !== "") {
|
|
8687
|
+
ctx.filter = "none";
|
|
8899
8688
|
}
|
|
8900
8689
|
ctx.scale(1 / width, -1 / height);
|
|
8901
8690
|
let imgToPaint;
|
|
@@ -9011,7 +8800,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9011
8800
|
endCompat() {
|
|
9012
8801
|
}
|
|
9013
8802
|
// Helper functions
|
|
9014
|
-
consumePath(clipBox) {
|
|
8803
|
+
consumePath(path, clipBox) {
|
|
9015
8804
|
const isEmpty = this.current.isEmptyClip();
|
|
9016
8805
|
if (this.pendingClip) {
|
|
9017
8806
|
this.current.updateClipFromPath();
|
|
@@ -9023,15 +8812,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9023
8812
|
if (this.pendingClip) {
|
|
9024
8813
|
if (!isEmpty) {
|
|
9025
8814
|
if (this.pendingClip === EO_CLIP) {
|
|
9026
|
-
ctx.clip("evenodd");
|
|
8815
|
+
ctx.clip(path, "evenodd");
|
|
9027
8816
|
} else {
|
|
9028
|
-
ctx.clip();
|
|
8817
|
+
ctx.clip(path);
|
|
9029
8818
|
}
|
|
9030
8819
|
}
|
|
9031
8820
|
this.pendingClip = null;
|
|
9032
8821
|
}
|
|
9033
8822
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
9034
|
-
ctx.beginPath();
|
|
9035
8823
|
}
|
|
9036
8824
|
getSinglePixelWidth() {
|
|
9037
8825
|
if (!this._cachedGetSinglePixelWidth) {
|
|
@@ -9091,13 +8879,15 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9091
8879
|
}
|
|
9092
8880
|
// Rescale before stroking in order to have a final lineWidth
|
|
9093
8881
|
// with both thicknesses greater or equal to 1.
|
|
9094
|
-
rescaleAndStroke(saveRestore) {
|
|
9095
|
-
const {
|
|
9096
|
-
|
|
8882
|
+
rescaleAndStroke(path, saveRestore) {
|
|
8883
|
+
const {
|
|
8884
|
+
ctx,
|
|
8885
|
+
current: { lineWidth }
|
|
8886
|
+
} = this;
|
|
9097
8887
|
const [scaleX, scaleY] = this.getScaleForStroking();
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
ctx.stroke();
|
|
8888
|
+
if (scaleX === scaleY) {
|
|
8889
|
+
ctx.lineWidth = (lineWidth || 1) * scaleX;
|
|
8890
|
+
ctx.stroke(path);
|
|
9101
8891
|
return;
|
|
9102
8892
|
}
|
|
9103
8893
|
const dashes = ctx.getLineDash();
|
|
@@ -9105,12 +8895,17 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9105
8895
|
ctx.save();
|
|
9106
8896
|
}
|
|
9107
8897
|
ctx.scale(scaleX, scaleY);
|
|
8898
|
+
SCALE_MATRIX.a = 1 / scaleX;
|
|
8899
|
+
SCALE_MATRIX.d = 1 / scaleY;
|
|
8900
|
+
const newPath = new SvgPath2D();
|
|
8901
|
+
newPath.addPath(path, SCALE_MATRIX);
|
|
9108
8902
|
if (dashes.length > 0) {
|
|
9109
8903
|
const scale = Math.max(scaleX, scaleY);
|
|
9110
8904
|
ctx.setLineDash(dashes.map((x) => x / scale));
|
|
9111
8905
|
ctx.lineDashOffset /= scale;
|
|
9112
8906
|
}
|
|
9113
|
-
ctx.
|
|
8907
|
+
ctx.lineWidth = lineWidth || 1;
|
|
8908
|
+
ctx.stroke(newPath);
|
|
9114
8909
|
if (saveRestore) {
|
|
9115
8910
|
ctx.restore();
|
|
9116
8911
|
}
|
|
@@ -11161,7 +10956,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11161
10956
|
throw new Error('No "textContentSource" parameter specified.');
|
|
11162
10957
|
}
|
|
11163
10958
|
__privateSet(this, _container3, __privateSet(this, _rootContainer, container));
|
|
11164
|
-
__privateSet(this, _scale, viewport.scale *
|
|
10959
|
+
__privateSet(this, _scale, viewport.scale * OutputScale.pixelRatio);
|
|
11165
10960
|
__privateSet(this, _rotation, viewport.rotation);
|
|
11166
10961
|
__privateSet(this, _layoutTextParams, {
|
|
11167
10962
|
div: null,
|
|
@@ -11239,7 +11034,7 @@ var _TextLayer = class _TextLayer {
|
|
|
11239
11034
|
*/
|
|
11240
11035
|
update({ viewport, onBefore = null }) {
|
|
11241
11036
|
var _a2;
|
|
11242
|
-
const scale = viewport.scale *
|
|
11037
|
+
const scale = viewport.scale * OutputScale.pixelRatio;
|
|
11243
11038
|
const rotation = viewport.rotation;
|
|
11244
11039
|
if (rotation !== __privateGet(this, _rotation)) {
|
|
11245
11040
|
onBefore?.();
|
|
@@ -11619,6 +11414,7 @@ function getDocument(src = {}) {
|
|
|
11619
11414
|
const cMapUrl = getFactoryUrlProp(src.cMapUrl);
|
|
11620
11415
|
const cMapPacked = src.cMapPacked !== false;
|
|
11621
11416
|
const CMapReaderFactory = src.CMapReaderFactory || (isNodeJS ? NodeCMapReaderFactory : DOMCMapReaderFactory);
|
|
11417
|
+
const iccUrl = getFactoryUrlProp(src.iccUrl);
|
|
11622
11418
|
const standardFontDataUrl = getFactoryUrlProp(src.standardFontDataUrl);
|
|
11623
11419
|
const StandardFontDataFactory2 = src.StandardFontDataFactory || (isNodeJS ? NodeStandardFontDataFactory : DOMStandardFontDataFactory);
|
|
11624
11420
|
const wasmUrl = getFactoryUrlProp(src.wasmUrl);
|
|
@@ -11690,6 +11486,7 @@ function getDocument(src = {}) {
|
|
|
11690
11486
|
useWasm,
|
|
11691
11487
|
useWorkerFetch,
|
|
11692
11488
|
cMapUrl,
|
|
11489
|
+
iccUrl,
|
|
11693
11490
|
standardFontDataUrl,
|
|
11694
11491
|
wasmUrl
|
|
11695
11492
|
}
|
|
@@ -11823,19 +11620,54 @@ function getFactoryUrlProp(val) {
|
|
|
11823
11620
|
}
|
|
11824
11621
|
throw new Error(`Invalid factory url: "${val}" must include trailing slash.`);
|
|
11825
11622
|
}
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11623
|
+
var isRefProxy = (v) => typeof v === "object" && Number.isInteger(v?.num) && v.num >= 0 && Number.isInteger(v?.gen) && v.gen >= 0;
|
|
11624
|
+
var isNameProxy = (v) => typeof v === "object" && typeof v?.name === "string";
|
|
11625
|
+
var isValidExplicitDest = _isValidExplicitDest.bind(
|
|
11626
|
+
null,
|
|
11627
|
+
/* validRef = */
|
|
11628
|
+
isRefProxy,
|
|
11629
|
+
/* validName = */
|
|
11630
|
+
isNameProxy
|
|
11631
|
+
);
|
|
11829
11632
|
var _docId2;
|
|
11830
11633
|
var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
11831
11634
|
constructor() {
|
|
11832
|
-
|
|
11833
|
-
|
|
11834
|
-
|
|
11835
|
-
this
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11635
|
+
/**
|
|
11636
|
+
* @private
|
|
11637
|
+
*/
|
|
11638
|
+
__publicField(this, "_capability", Promise.withResolvers());
|
|
11639
|
+
/**
|
|
11640
|
+
* @private
|
|
11641
|
+
*/
|
|
11642
|
+
__publicField(this, "_transport", null);
|
|
11643
|
+
/**
|
|
11644
|
+
* @private
|
|
11645
|
+
*/
|
|
11646
|
+
__publicField(this, "_worker", null);
|
|
11647
|
+
/**
|
|
11648
|
+
* Unique identifier for the document loading task.
|
|
11649
|
+
* @type {string}
|
|
11650
|
+
*/
|
|
11651
|
+
__publicField(this, "docId", `d${__privateWrapper(_PDFDocumentLoadingTask, _docId2)._++}`);
|
|
11652
|
+
/**
|
|
11653
|
+
* Whether the loading task is destroyed or not.
|
|
11654
|
+
* @type {boolean}
|
|
11655
|
+
*/
|
|
11656
|
+
__publicField(this, "destroyed", false);
|
|
11657
|
+
/**
|
|
11658
|
+
* Callback to request a password if a wrong or no password was provided.
|
|
11659
|
+
* The callback receives two parameters: a function that should be called
|
|
11660
|
+
* with the new password, and a reason (see {@link PasswordResponses}).
|
|
11661
|
+
* @type {function}
|
|
11662
|
+
*/
|
|
11663
|
+
__publicField(this, "onPassword", null);
|
|
11664
|
+
/**
|
|
11665
|
+
* Callback to be able to monitor the loading progress of the PDF file
|
|
11666
|
+
* (necessary to implement e.g. a loading bar).
|
|
11667
|
+
* The callback receives an {@link OnProgressParameters} argument.
|
|
11668
|
+
* @type {function}
|
|
11669
|
+
*/
|
|
11670
|
+
__publicField(this, "onProgress", null);
|
|
11839
11671
|
}
|
|
11840
11672
|
/**
|
|
11841
11673
|
* Promise for document loading task completion.
|
|
@@ -11870,6 +11702,15 @@ var _PDFDocumentLoadingTask = class _PDFDocumentLoadingTask {
|
|
|
11870
11702
|
this._worker?.destroy();
|
|
11871
11703
|
this._worker = null;
|
|
11872
11704
|
}
|
|
11705
|
+
/**
|
|
11706
|
+
* Attempt to fetch the raw data of the PDF document, when e.g.
|
|
11707
|
+
* - An exception was thrown during document initialization.
|
|
11708
|
+
* - An `onPassword` callback is delaying initialization.
|
|
11709
|
+
* @returns {Promise<Uint8Array>}
|
|
11710
|
+
*/
|
|
11711
|
+
async getData() {
|
|
11712
|
+
return this._transport.getData();
|
|
11713
|
+
}
|
|
11873
11714
|
};
|
|
11874
11715
|
_docId2 = new WeakMap();
|
|
11875
11716
|
__privateAdd(_PDFDocumentLoadingTask, _docId2, 0);
|
|
@@ -13046,6 +12887,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13046
12887
|
}
|
|
13047
12888
|
/**
|
|
13048
12889
|
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
|
12890
|
+
* @returns {PDFWorker}
|
|
13049
12891
|
*/
|
|
13050
12892
|
static fromPort(params) {
|
|
13051
12893
|
if (false) {
|
|
@@ -13081,7 +12923,7 @@ var _PDFWorker = class _PDFWorker {
|
|
|
13081
12923
|
if (__privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get)) {
|
|
13082
12924
|
return __privateGet(this, _PDFWorker_static, mainThreadWorkerMessageHandler_get);
|
|
13083
12925
|
}
|
|
13084
|
-
const worker = true ? await import("./worker.js") : await
|
|
12926
|
+
const worker = true ? await import("./worker.js") : await __raw_import__(this.workerSrc);
|
|
13085
12927
|
return worker.WorkerMessageHandler;
|
|
13086
12928
|
};
|
|
13087
12929
|
return shadow(this, "_setupFakeWorkerGlobal", loader());
|
|
@@ -17610,7 +17452,7 @@ var _FreeTextEditor = class _FreeTextEditor extends AnnotationEditor {
|
|
|
17610
17452
|
__privateSet(this, _content, `${bufferBefore.join("\n")}${paste}${bufferAfter.join("\n")}`);
|
|
17611
17453
|
__privateMethod(this, _FreeTextEditor_instances, setContent_fn).call(this);
|
|
17612
17454
|
const newRange = new Range();
|
|
17613
|
-
let beforeLength = bufferBefore.
|
|
17455
|
+
let beforeLength = Math.sumPrecise(bufferBefore.map((line) => line.length));
|
|
17614
17456
|
for (const { firstChild } of this.editorDiv.childNodes) {
|
|
17615
17457
|
if (firstChild.nodeType === Node.TEXT_NODE) {
|
|
17616
17458
|
const length = firstChild.nodeValue.length;
|
|
@@ -18460,35 +18302,24 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18460
18302
|
const outline = __privateGet(this, _outline);
|
|
18461
18303
|
let lastX = outline[4];
|
|
18462
18304
|
let lastY = outline[5];
|
|
18463
|
-
|
|
18464
|
-
let minY = lastY;
|
|
18465
|
-
let maxX = lastX;
|
|
18466
|
-
let maxY = lastY;
|
|
18305
|
+
const minMax = [lastX, lastY, lastX, lastY];
|
|
18467
18306
|
let lastPointX = lastX;
|
|
18468
18307
|
let lastPointY = lastY;
|
|
18469
18308
|
const ltrCallback = isLTR ? Math.max : Math.min;
|
|
18470
18309
|
for (let i = 6, ii = outline.length; i < ii; i += 6) {
|
|
18310
|
+
const x = outline[i + 4], y = outline[i + 5];
|
|
18471
18311
|
if (isNaN(outline[i])) {
|
|
18472
|
-
|
|
18473
|
-
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
if (lastPointY
|
|
18477
|
-
lastPointX =
|
|
18478
|
-
lastPointY = outline[i + 5];
|
|
18479
|
-
} else if (lastPointY === outline[i + 5]) {
|
|
18480
|
-
lastPointX = ltrCallback(lastPointX, outline[i + 4]);
|
|
18312
|
+
Util.pointBoundingBox(x, y, minMax);
|
|
18313
|
+
if (lastPointY < y) {
|
|
18314
|
+
lastPointX = x;
|
|
18315
|
+
lastPointY = y;
|
|
18316
|
+
} else if (lastPointY === y) {
|
|
18317
|
+
lastPointX = ltrCallback(lastPointX, x);
|
|
18481
18318
|
}
|
|
18482
18319
|
} else {
|
|
18483
|
-
const bbox2 =
|
|
18484
|
-
|
|
18485
|
-
|
|
18486
|
-
...outline.slice(i, i + 6)
|
|
18487
|
-
);
|
|
18488
|
-
minX = Math.min(minX, bbox2[0]);
|
|
18489
|
-
minY = Math.min(minY, bbox2[1]);
|
|
18490
|
-
maxX = Math.max(maxX, bbox2[2]);
|
|
18491
|
-
maxY = Math.max(maxY, bbox2[3]);
|
|
18320
|
+
const bbox2 = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18321
|
+
Util.bezierBoundingBox(lastX, lastY, ...outline.slice(i, i + 6), bbox2);
|
|
18322
|
+
Util.rectBoundingBox(...bbox2, minMax);
|
|
18492
18323
|
if (lastPointY < bbox2[3]) {
|
|
18493
18324
|
lastPointX = bbox2[2];
|
|
18494
18325
|
lastPointY = bbox2[3];
|
|
@@ -18496,14 +18327,14 @@ computeMinMax_fn = function(isLTR) {
|
|
|
18496
18327
|
lastPointX = ltrCallback(lastPointX, bbox2[2]);
|
|
18497
18328
|
}
|
|
18498
18329
|
}
|
|
18499
|
-
lastX =
|
|
18500
|
-
lastY =
|
|
18330
|
+
lastX = x;
|
|
18331
|
+
lastY = y;
|
|
18501
18332
|
}
|
|
18502
18333
|
const bbox = __privateGet(this, _bbox);
|
|
18503
|
-
bbox[0] =
|
|
18504
|
-
bbox[1] =
|
|
18505
|
-
bbox[2] =
|
|
18506
|
-
bbox[3] =
|
|
18334
|
+
bbox[0] = minMax[0] - __privateGet(this, _innerMargin2);
|
|
18335
|
+
bbox[1] = minMax[1] - __privateGet(this, _innerMargin2);
|
|
18336
|
+
bbox[2] = minMax[2] - minMax[0] + 2 * __privateGet(this, _innerMargin2);
|
|
18337
|
+
bbox[3] = minMax[3] - minMax[1] + 2 * __privateGet(this, _innerMargin2);
|
|
18507
18338
|
this.lastPoint = [lastPointX, lastPointY];
|
|
18508
18339
|
};
|
|
18509
18340
|
|
|
@@ -18528,10 +18359,7 @@ var HighlightOutliner = class {
|
|
|
18528
18359
|
__privateAdd(this, _lastPoint);
|
|
18529
18360
|
__privateAdd(this, _verticalEdges, []);
|
|
18530
18361
|
__privateAdd(this, _intervals, []);
|
|
18531
|
-
|
|
18532
|
-
let maxX = -Infinity;
|
|
18533
|
-
let minY = Infinity;
|
|
18534
|
-
let maxY = -Infinity;
|
|
18362
|
+
const minMax = [Infinity, Infinity, -Infinity, -Infinity];
|
|
18535
18363
|
const NUMBER_OF_DIGITS = 4;
|
|
18536
18364
|
const EPSILON = 10 ** -NUMBER_OF_DIGITS;
|
|
18537
18365
|
for (const { x, y, width, height } of boxes) {
|
|
@@ -18542,15 +18370,12 @@ var HighlightOutliner = class {
|
|
|
18542
18370
|
const left = [x1, y1, y2, true];
|
|
18543
18371
|
const right = [x2, y1, y2, false];
|
|
18544
18372
|
__privateGet(this, _verticalEdges).push(left, right);
|
|
18545
|
-
|
|
18546
|
-
|
|
18547
|
-
|
|
18548
|
-
|
|
18549
|
-
|
|
18550
|
-
const
|
|
18551
|
-
const bboxHeight = maxY - minY + 2 * innerMargin;
|
|
18552
|
-
const shiftedMinX = minX - innerMargin;
|
|
18553
|
-
const shiftedMinY = minY - innerMargin;
|
|
18373
|
+
Util.rectBoundingBox(x1, y1, x2, y2, minMax);
|
|
18374
|
+
}
|
|
18375
|
+
const bboxWidth = minMax[2] - minMax[0] + 2 * innerMargin;
|
|
18376
|
+
const bboxHeight = minMax[3] - minMax[1] + 2 * innerMargin;
|
|
18377
|
+
const shiftedMinX = minMax[0] - innerMargin;
|
|
18378
|
+
const shiftedMinY = minMax[1] - innerMargin;
|
|
18554
18379
|
const lastEdge = __privateGet(this, _verticalEdges).at(isLTR ? -1 : -2);
|
|
18555
18380
|
const lastPoint = [lastEdge[0], lastEdge[2]];
|
|
18556
18381
|
for (const edge of __privateGet(this, _verticalEdges)) {
|
|
@@ -19079,6 +18904,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19079
18904
|
__privateSet(this, _methodOfCreation, params.methodOfCreation || "");
|
|
19080
18905
|
__privateSet(this, _text, params.text || "");
|
|
19081
18906
|
this._isDraggable = false;
|
|
18907
|
+
this.defaultL10nId = "pdfjs-editor-highlight-editor";
|
|
19082
18908
|
if (params.highlightId > -1) {
|
|
19083
18909
|
__privateSet(this, _isFreeHighlight, true);
|
|
19084
18910
|
__privateMethod(this, _HighlightEditor_instances, createFreeOutlines_fn).call(this, params);
|
|
@@ -19593,6 +19419,7 @@ var _HighlightEditor = class _HighlightEditor extends AnnotationEditor {
|
|
|
19593
19419
|
clipPathId
|
|
19594
19420
|
});
|
|
19595
19421
|
__privateMethod(_d = editor, _HighlightEditor_instances, addToDrawLayer_fn).call(_d);
|
|
19422
|
+
editor.rotate(editor.parentRotation);
|
|
19596
19423
|
}
|
|
19597
19424
|
return editor;
|
|
19598
19425
|
}
|
|
@@ -21502,11 +21329,7 @@ computeBbox_fn = function() {
|
|
|
21502
21329
|
for (const { line } of __privateGet(this, _lines2)) {
|
|
21503
21330
|
if (line.length <= 12) {
|
|
21504
21331
|
for (let i = 4, ii = line.length; i < ii; i += 6) {
|
|
21505
|
-
|
|
21506
|
-
bbox[0] = Math.min(bbox[0], x);
|
|
21507
|
-
bbox[1] = Math.min(bbox[1], y);
|
|
21508
|
-
bbox[2] = Math.max(bbox[2], x);
|
|
21509
|
-
bbox[3] = Math.max(bbox[3], y);
|
|
21332
|
+
Util.pointBoundingBox(line[i], line[i + 1], bbox);
|
|
21510
21333
|
}
|
|
21511
21334
|
continue;
|
|
21512
21335
|
}
|
|
@@ -21519,10 +21342,10 @@ computeBbox_fn = function() {
|
|
|
21519
21342
|
}
|
|
21520
21343
|
}
|
|
21521
21344
|
const [marginX, marginY] = __privateMethod(this, _InkDrawOutline_instances, getMarginComponents_fn).call(this);
|
|
21522
|
-
bbox[0] =
|
|
21523
|
-
bbox[1] =
|
|
21524
|
-
bbox[2] =
|
|
21525
|
-
bbox[3] =
|
|
21345
|
+
bbox[0] = MathClamp(bbox[0] - marginX, 0, 1);
|
|
21346
|
+
bbox[1] = MathClamp(bbox[1] - marginY, 0, 1);
|
|
21347
|
+
bbox[2] = MathClamp(bbox[2] + marginX, 0, 1);
|
|
21348
|
+
bbox[3] = MathClamp(bbox[3] + marginY, 0, 1);
|
|
21526
21349
|
bbox[2] -= bbox[0];
|
|
21527
21350
|
bbox[3] -= bbox[1];
|
|
21528
21351
|
};
|
|
@@ -21576,6 +21399,7 @@ var _InkEditor = class _InkEditor extends DrawingEditor {
|
|
|
21576
21399
|
super({ ...params, name: "inkEditor" });
|
|
21577
21400
|
__privateAdd(this, _InkEditor_instances);
|
|
21578
21401
|
this._willKeepAspectRatio = true;
|
|
21402
|
+
this.defaultL10nId = "pdfjs-editor-ink-editor";
|
|
21579
21403
|
}
|
|
21580
21404
|
/** @inheritdoc */
|
|
21581
21405
|
static initialize(l10n, uiManager) {
|
|
@@ -22469,6 +22293,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22469
22293
|
this._willKeepAspectRatio = true;
|
|
22470
22294
|
__privateSet(this, _signatureData, params.signatureData || null);
|
|
22471
22295
|
__privateSet(this, _description, null);
|
|
22296
|
+
this.defaultL10nId = "pdfjs-editor-signature-editor1";
|
|
22472
22297
|
}
|
|
22473
22298
|
/** @inheritdoc */
|
|
22474
22299
|
static initialize(l10n, uiManager) {
|
|
@@ -22532,7 +22357,6 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22532
22357
|
baseY = this.y;
|
|
22533
22358
|
}
|
|
22534
22359
|
super.render();
|
|
22535
|
-
this.div.setAttribute("role", "figure");
|
|
22536
22360
|
if (this._drawId === null) {
|
|
22537
22361
|
if (__privateGet(this, _signatureData)) {
|
|
22538
22362
|
const {
|
|
@@ -22558,6 +22382,10 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22558
22382
|
});
|
|
22559
22383
|
this.addSignature(outline, heightInPage, description, uuid);
|
|
22560
22384
|
} else {
|
|
22385
|
+
this.div.setAttribute(
|
|
22386
|
+
"data-l10n-args",
|
|
22387
|
+
JSON.stringify({ description: "" })
|
|
22388
|
+
);
|
|
22561
22389
|
this.div.hidden = true;
|
|
22562
22390
|
this._uiManager.getSignature(this);
|
|
22563
22391
|
}
|
|
@@ -22624,6 +22452,7 @@ var _SignatureEditor = class _SignatureEditor extends DrawingEditor {
|
|
|
22624
22452
|
const { outline } = __privateSet(this, _signatureData, data);
|
|
22625
22453
|
__privateSet(this, _isExtracted, outline instanceof ContourDrawOutline);
|
|
22626
22454
|
__privateSet(this, _description, description);
|
|
22455
|
+
this.div.setAttribute("data-l10n-args", JSON.stringify({ description }));
|
|
22627
22456
|
let drawingOptions;
|
|
22628
22457
|
if (__privateGet(this, _isExtracted)) {
|
|
22629
22458
|
drawingOptions = _SignatureEditor.getDefaultDrawingOptions();
|
|
@@ -22804,6 +22633,7 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22804
22633
|
__privateAdd(this, _hasBeenAddedInUndoStack, false);
|
|
22805
22634
|
__privateSet(this, _bitmapUrl, params.bitmapUrl);
|
|
22806
22635
|
__privateSet(this, _bitmapFile, params.bitmapFile);
|
|
22636
|
+
this.defaultL10nId = "pdfjs-editor-stamp-editor";
|
|
22807
22637
|
}
|
|
22808
22638
|
/** @inheritdoc */
|
|
22809
22639
|
static initialize(l10n, uiManager) {
|
|
@@ -22945,7 +22775,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
22945
22775
|
}
|
|
22946
22776
|
super.render();
|
|
22947
22777
|
this.div.hidden = true;
|
|
22948
|
-
this.div.setAttribute("role", "figure");
|
|
22949
22778
|
this.addAltTextButton();
|
|
22950
22779
|
if (!__privateGet(this, _missingCanvas)) {
|
|
22951
22780
|
if (__privateGet(this, _bitmap)) {
|
|
@@ -23093,10 +22922,6 @@ var StampEditor = class extends AnnotationEditor {
|
|
|
23093
22922
|
return { canvas, width, height, imageData };
|
|
23094
22923
|
}
|
|
23095
22924
|
/** @inheritdoc */
|
|
23096
|
-
getImageForAltText() {
|
|
23097
|
-
return __privateGet(this, _canvas);
|
|
23098
|
-
}
|
|
23099
|
-
/** @inheritdoc */
|
|
23100
22925
|
static async deserialize(data, parent, uiManager) {
|
|
23101
22926
|
let initialData = null;
|
|
23102
22927
|
let missingCanvas = false;
|
|
@@ -23412,7 +23237,7 @@ createCanvas_fn = function() {
|
|
|
23412
23237
|
action: "inserted_image"
|
|
23413
23238
|
});
|
|
23414
23239
|
if (__privateGet(this, _bitmapFileName)) {
|
|
23415
|
-
|
|
23240
|
+
this.div.setAttribute("aria-description", __privateGet(this, _bitmapFileName));
|
|
23416
23241
|
}
|
|
23417
23242
|
};
|
|
23418
23243
|
scaleBitmap_fn = function(width, height) {
|
|
@@ -24535,319 +24360,39 @@ if (false) {
|
|
|
24535
24360
|
};
|
|
24536
24361
|
}
|
|
24537
24362
|
|
|
24538
|
-
// src/lib/
|
|
24539
|
-
|
|
24540
|
-
|
|
24541
|
-
|
|
24542
|
-
|
|
24543
|
-
|
|
24544
|
-
|
|
24545
|
-
|
|
24363
|
+
// src/lib/AnnotationOperatorsList.ts
|
|
24364
|
+
var AnnotationOperatorsList = class {
|
|
24365
|
+
/**
|
|
24366
|
+
* The list of operators to be executed.
|
|
24367
|
+
* @param operatorList The list of operators to be executed.
|
|
24368
|
+
*/
|
|
24369
|
+
constructor(operatorList) {
|
|
24370
|
+
__publicField(this, "map", /* @__PURE__ */ new Map());
|
|
24371
|
+
let currentId = null;
|
|
24372
|
+
let currentList = [];
|
|
24373
|
+
for (const [index, op] of operatorList.fnArray.entries()) {
|
|
24374
|
+
const args = operatorList.argsArray[index];
|
|
24375
|
+
if (op === OPS.beginAnnotation) {
|
|
24376
|
+
currentId = args[0];
|
|
24377
|
+
currentList.push({ fn: op, args });
|
|
24378
|
+
} else if (op === OPS.endAnnotation && currentId) {
|
|
24379
|
+
currentList.push({ fn: op, args });
|
|
24380
|
+
this.map.set(currentId, currentList);
|
|
24381
|
+
currentList = [];
|
|
24382
|
+
} else if (currentId) {
|
|
24383
|
+
currentList.push({ fn: op, args });
|
|
24384
|
+
}
|
|
24546
24385
|
}
|
|
24547
|
-
return new Uint8Array(await blob.arrayBuffer());
|
|
24548
24386
|
}
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
resolve(reader.result);
|
|
24557
|
-
};
|
|
24558
|
-
reader.readAsDataURL(new Blob([data], { type: "image/png" }));
|
|
24559
|
-
});
|
|
24387
|
+
/**
|
|
24388
|
+
* Get the list of operators for the given annotation id.
|
|
24389
|
+
* @param id The id of the annotation.
|
|
24390
|
+
* @return The list of operators for the given annotation id.
|
|
24391
|
+
*/
|
|
24392
|
+
get(id) {
|
|
24393
|
+
return this.map.get(id) ?? [];
|
|
24560
24394
|
}
|
|
24561
|
-
|
|
24562
|
-
}
|
|
24563
|
-
|
|
24564
|
-
// src/lib/PDFPageProxy.ts
|
|
24565
|
-
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
24566
|
-
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
24567
|
-
const annotations = await getAnnotations.call(this, params);
|
|
24568
|
-
const operatorList = await this.getOperatorList({
|
|
24569
|
-
annotationMode: AnnotationMode.ENABLE_FORMS
|
|
24570
|
-
});
|
|
24571
|
-
const annotationsOperatorList = /* @__PURE__ */ new Map();
|
|
24572
|
-
let currentId = null;
|
|
24573
|
-
let currentList = [];
|
|
24574
|
-
for (const [index, op] of operatorList.fnArray.entries()) {
|
|
24575
|
-
const args = operatorList.argsArray[index];
|
|
24576
|
-
if (op === OPS.beginAnnotation) {
|
|
24577
|
-
currentId = args[0];
|
|
24578
|
-
currentList.push({ fn: op, args });
|
|
24579
|
-
} else if (op === OPS.endAnnotation && currentId) {
|
|
24580
|
-
currentList.push({ fn: op, args });
|
|
24581
|
-
annotationsOperatorList.set(currentId, currentList);
|
|
24582
|
-
currentList = [];
|
|
24583
|
-
} else if (currentId) {
|
|
24584
|
-
currentList.push({ fn: op, args });
|
|
24585
|
-
}
|
|
24586
|
-
}
|
|
24587
|
-
for (const annotation of annotations) {
|
|
24588
|
-
const opList = annotationsOperatorList.get(annotation.id);
|
|
24589
|
-
if (opList) {
|
|
24590
|
-
if (annotation.subtype === "Stamp") {
|
|
24591
|
-
try {
|
|
24592
|
-
const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
|
|
24593
|
-
const scale = 2;
|
|
24594
|
-
const viewport = this.getViewport({ scale });
|
|
24595
|
-
const { context: canvasContext } = canvasFactory.create(
|
|
24596
|
-
viewport.width,
|
|
24597
|
-
viewport.height
|
|
24598
|
-
);
|
|
24599
|
-
const gsx = new CanvasGraphics(
|
|
24600
|
-
canvasContext,
|
|
24601
|
-
this.commonObjs,
|
|
24602
|
-
this.objs,
|
|
24603
|
-
canvasFactory,
|
|
24604
|
-
this.filterFactory,
|
|
24605
|
-
{ optionalContentConfig: null }
|
|
24606
|
-
);
|
|
24607
|
-
gsx.beginDrawing({
|
|
24608
|
-
transform: null,
|
|
24609
|
-
viewport
|
|
24610
|
-
});
|
|
24611
|
-
canvasContext.clearRect(0, 0, viewport.width, viewport.height);
|
|
24612
|
-
gsx.executeOperatorList({
|
|
24613
|
-
fnArray: opList.map((op) => op.fn),
|
|
24614
|
-
argsArray: opList.map((op) => op.args)
|
|
24615
|
-
});
|
|
24616
|
-
const width = annotation.rect[2] - annotation.rect[0];
|
|
24617
|
-
const height = annotation.rect[3] - annotation.rect[1];
|
|
24618
|
-
const { context: croppedCanvasContext } = canvasFactory.create(
|
|
24619
|
-
width * scale,
|
|
24620
|
-
height * scale
|
|
24621
|
-
);
|
|
24622
|
-
croppedCanvasContext.drawImage(
|
|
24623
|
-
canvasContext.canvas,
|
|
24624
|
-
annotation.rect[0] * scale,
|
|
24625
|
-
(this.view[3] - annotation.rect[1] - height) * scale,
|
|
24626
|
-
width * scale,
|
|
24627
|
-
height * scale,
|
|
24628
|
-
0,
|
|
24629
|
-
0,
|
|
24630
|
-
width * scale,
|
|
24631
|
-
height * scale
|
|
24632
|
-
);
|
|
24633
|
-
annotation.graphics = await canvasToData(croppedCanvasContext.canvas);
|
|
24634
|
-
} catch (e) {
|
|
24635
|
-
console.error(e);
|
|
24636
|
-
}
|
|
24637
|
-
} else {
|
|
24638
|
-
let firstStroke = true;
|
|
24639
|
-
let firstFill = true;
|
|
24640
|
-
let currentFillColor = null;
|
|
24641
|
-
let currentLineWidth = null;
|
|
24642
|
-
for (const { fn, args } of opList) {
|
|
24643
|
-
if (fn === OPS.fill) {
|
|
24644
|
-
if (currentFillColor) {
|
|
24645
|
-
annotation.interiorColor = currentFillColor;
|
|
24646
|
-
currentFillColor = null;
|
|
24647
|
-
}
|
|
24648
|
-
firstFill = false;
|
|
24649
|
-
continue;
|
|
24650
|
-
}
|
|
24651
|
-
if (fn === OPS.beginText) {
|
|
24652
|
-
firstFill = false;
|
|
24653
|
-
continue;
|
|
24654
|
-
}
|
|
24655
|
-
if (fn === OPS.stroke) {
|
|
24656
|
-
if (currentLineWidth === null) {
|
|
24657
|
-
annotation.borderStyle.width = 1;
|
|
24658
|
-
}
|
|
24659
|
-
firstStroke = false;
|
|
24660
|
-
currentLineWidth = null;
|
|
24661
|
-
continue;
|
|
24662
|
-
}
|
|
24663
|
-
if (fn === OPS.fillStroke) {
|
|
24664
|
-
if (currentFillColor) {
|
|
24665
|
-
annotation.interiorColor = currentFillColor;
|
|
24666
|
-
currentFillColor = null;
|
|
24667
|
-
}
|
|
24668
|
-
if (currentLineWidth === null) {
|
|
24669
|
-
annotation.borderStyle.width = 1;
|
|
24670
|
-
}
|
|
24671
|
-
firstStroke = false;
|
|
24672
|
-
currentLineWidth = null;
|
|
24673
|
-
break;
|
|
24674
|
-
}
|
|
24675
|
-
if (!firstFill && !firstStroke) {
|
|
24676
|
-
break;
|
|
24677
|
-
}
|
|
24678
|
-
if (fn === OPS.setLineWidth && firstStroke) {
|
|
24679
|
-
currentLineWidth = args[0];
|
|
24680
|
-
annotation.borderStyle.width = currentLineWidth;
|
|
24681
|
-
}
|
|
24682
|
-
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
24683
|
-
if (!annotation.borderStyle.width) {
|
|
24684
|
-
annotation.borderStyle.width = 1;
|
|
24685
|
-
}
|
|
24686
|
-
annotation.color = args;
|
|
24687
|
-
}
|
|
24688
|
-
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
24689
|
-
currentFillColor = args;
|
|
24690
|
-
}
|
|
24691
|
-
if (fn === OPS.setGState) {
|
|
24692
|
-
for (const entry of args[0]) {
|
|
24693
|
-
if (!Array.isArray(entry)) {
|
|
24694
|
-
continue;
|
|
24695
|
-
}
|
|
24696
|
-
if (entry[0] === "ca" && firstFill) {
|
|
24697
|
-
annotation.interiorColorOpacity = entry[1];
|
|
24698
|
-
}
|
|
24699
|
-
if (entry[0] === "CA" && firstStroke) {
|
|
24700
|
-
annotation.borderColorOpacity = entry[1];
|
|
24701
|
-
}
|
|
24702
|
-
}
|
|
24703
|
-
}
|
|
24704
|
-
}
|
|
24705
|
-
}
|
|
24706
|
-
}
|
|
24707
|
-
}
|
|
24708
|
-
return annotations;
|
|
24709
|
-
};
|
|
24710
|
-
|
|
24711
|
-
// src/lib/StandardFontDataFactory.ts
|
|
24712
|
-
var StandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
24713
|
-
constructor() {
|
|
24714
|
-
super({
|
|
24715
|
-
baseUrl: null
|
|
24716
|
-
});
|
|
24717
|
-
}
|
|
24718
|
-
/**
|
|
24719
|
-
* Fetch the corresponding standard font data.
|
|
24720
|
-
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
24721
|
-
*/
|
|
24722
|
-
async fetch({ filename }) {
|
|
24723
|
-
switch (filename) {
|
|
24724
|
-
case "FoxitDingbats.pfb":
|
|
24725
|
-
return import("./FoxitDingbats-SB6TO3S5.js").then((module) => module.default);
|
|
24726
|
-
case "FoxitFixed.pfb":
|
|
24727
|
-
return import("./FoxitFixed-UIGSMBQB.js").then(
|
|
24728
|
-
(module) => module.default
|
|
24729
|
-
);
|
|
24730
|
-
case "FoxitFixedBold.pfb":
|
|
24731
|
-
return import("./FoxitFixedBold-2PAEIZAT.js").then((module) => module.default);
|
|
24732
|
-
case "FoxitFixedBoldItalic.pfb":
|
|
24733
|
-
return import("./FoxitFixedBoldItalic-OSQUQDEE.js").then((module) => module.default);
|
|
24734
|
-
case "FoxitFixedItalic.pfb":
|
|
24735
|
-
return import("./FoxitFixedItalic-W73RDK22.js").then((module) => module.default);
|
|
24736
|
-
case "FoxitSerif.pfb":
|
|
24737
|
-
return import("./FoxitSerif-3HH3SOZF.js").then(
|
|
24738
|
-
(module) => module.default
|
|
24739
|
-
);
|
|
24740
|
-
case "FoxitSerifBold.pfb":
|
|
24741
|
-
return import("./FoxitSerifBold-HXP2QOO7.js").then((module) => module.default);
|
|
24742
|
-
case "FoxitSerifBoldItalic.pfb":
|
|
24743
|
-
return import("./FoxitSerifBoldItalic-FZXLNWD7.js").then((module) => module.default);
|
|
24744
|
-
case "FoxitSerifItalic.pfb":
|
|
24745
|
-
return import("./FoxitSerifItalic-WQFHUBI2.js").then((module) => module.default);
|
|
24746
|
-
case "FoxitSymbol.pfb":
|
|
24747
|
-
return import("./FoxitSymbol-OVWU7LKS.js").then(
|
|
24748
|
-
(module) => module.default
|
|
24749
|
-
);
|
|
24750
|
-
case "LiberationSans-Bold.ttf":
|
|
24751
|
-
return import("./LiberationSans-Bold-GSJN42N5.js").then((module) => module.default);
|
|
24752
|
-
case "LiberationSans-BoldItalic.ttf":
|
|
24753
|
-
return import("./LiberationSans-BoldItalic-UCPQJ3L2.js").then((module) => module.default);
|
|
24754
|
-
case "LiberationSans-Italic.ttf":
|
|
24755
|
-
return import("./LiberationSans-Italic-6CIHEALY.js").then((module) => module.default);
|
|
24756
|
-
case "LiberationSans-Regular.ttf":
|
|
24757
|
-
return import("./LiberationSans-Regular-KIF3IRJY.js").then((module) => module.default);
|
|
24758
|
-
}
|
|
24759
|
-
return Uint8Array.from([]);
|
|
24760
|
-
}
|
|
24761
|
-
};
|
|
24762
|
-
|
|
24763
|
-
// src/lib/AnnotationData.ts
|
|
24764
|
-
function isTextAnnotation(annotation) {
|
|
24765
|
-
return annotation.subtype === "Text";
|
|
24766
|
-
}
|
|
24767
|
-
function isLinkAnnotation(annotation) {
|
|
24768
|
-
return annotation.subtype === "Link";
|
|
24769
|
-
}
|
|
24770
|
-
function isFreeTextAnnotation(annotation) {
|
|
24771
|
-
return annotation.subtype === "FreeText";
|
|
24772
|
-
}
|
|
24773
|
-
function isLineAnnotation(annotation) {
|
|
24774
|
-
return annotation.subtype === "Line";
|
|
24775
|
-
}
|
|
24776
|
-
function isSquareAnnotation(annotation) {
|
|
24777
|
-
return annotation.subtype === "Square";
|
|
24778
|
-
}
|
|
24779
|
-
function isCircleAnnotation(annotation) {
|
|
24780
|
-
return annotation.subtype === "Circle";
|
|
24781
|
-
}
|
|
24782
|
-
function isPolygonAnnotation(annotation) {
|
|
24783
|
-
return annotation.subtype === "Polygon";
|
|
24784
|
-
}
|
|
24785
|
-
function isPolylineAnnotation(annotation) {
|
|
24786
|
-
return annotation.subtype === "PolyLine";
|
|
24787
|
-
}
|
|
24788
|
-
function isHighlightAnnotation(annotation) {
|
|
24789
|
-
return annotation.subtype === "Highlight";
|
|
24790
|
-
}
|
|
24791
|
-
function isUnderlineAnnotation(annotation) {
|
|
24792
|
-
return annotation.subtype === "Underline";
|
|
24793
|
-
}
|
|
24794
|
-
function isSquigglyAnnotation(annotation) {
|
|
24795
|
-
return annotation.subtype === "Squiggly";
|
|
24796
|
-
}
|
|
24797
|
-
function isStrikeOutAnnotation(annotation) {
|
|
24798
|
-
return annotation.subtype === "StrikeOut";
|
|
24799
|
-
}
|
|
24800
|
-
function isStampAnnotation(annotation) {
|
|
24801
|
-
return annotation.subtype === "Stamp";
|
|
24802
|
-
}
|
|
24803
|
-
function isCaretAnnotation(annotation) {
|
|
24804
|
-
return annotation.subtype === "Caret";
|
|
24805
|
-
}
|
|
24806
|
-
function isInkAnnotation(annotation) {
|
|
24807
|
-
return annotation.subtype === "Ink";
|
|
24808
|
-
}
|
|
24809
|
-
function isPopupAnnotation(annotation) {
|
|
24810
|
-
return annotation.subtype === "Popup";
|
|
24811
|
-
}
|
|
24812
|
-
function isFileAttachmentAnnotation(annotation) {
|
|
24813
|
-
return annotation.subtype === "FileAttachment";
|
|
24814
|
-
}
|
|
24815
|
-
function isSoundAnnotation(annotation) {
|
|
24816
|
-
return annotation.subtype === "Sound";
|
|
24817
|
-
}
|
|
24818
|
-
function isMovieAnnotation(annotation) {
|
|
24819
|
-
return annotation.subtype === "Movie";
|
|
24820
|
-
}
|
|
24821
|
-
function isWidgetAnnotation(annotation) {
|
|
24822
|
-
return annotation.subtype === "Widget";
|
|
24823
|
-
}
|
|
24824
|
-
function isTextWidgetAnnotation(annotation) {
|
|
24825
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Tx";
|
|
24826
|
-
}
|
|
24827
|
-
function isChoiceWidgetAnnotation(annotation) {
|
|
24828
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Ch";
|
|
24829
|
-
}
|
|
24830
|
-
function isButtonWidgetAnnotation(annotation) {
|
|
24831
|
-
return annotation.subtype === "Widget" && annotation.fieldType === "Btn";
|
|
24832
|
-
}
|
|
24833
|
-
function isScreenAnnotation(annotation) {
|
|
24834
|
-
return annotation.subtype === "Screen";
|
|
24835
|
-
}
|
|
24836
|
-
function isPrinterMarkAnnotation(annotation) {
|
|
24837
|
-
return annotation.subtype === "PrinterMark";
|
|
24838
|
-
}
|
|
24839
|
-
function isTrapNetAnnotation(annotation) {
|
|
24840
|
-
return annotation.subtype === "TrapNet";
|
|
24841
|
-
}
|
|
24842
|
-
function isWatermarkAnnotation(annotation) {
|
|
24843
|
-
return annotation.subtype === "Watermark";
|
|
24844
|
-
}
|
|
24845
|
-
function isThreeDAnnotation(annotation) {
|
|
24846
|
-
return annotation.subtype === "3D";
|
|
24847
|
-
}
|
|
24848
|
-
function isRedactAnnotation(annotation) {
|
|
24849
|
-
return annotation.subtype === "Redact";
|
|
24850
|
-
}
|
|
24395
|
+
};
|
|
24851
24396
|
|
|
24852
24397
|
// src/lib/SvgCanvasContext.ts
|
|
24853
24398
|
function parseTransformMatrix(transformString) {
|
|
@@ -25142,19 +24687,33 @@ var SvgCanvasContext = class {
|
|
|
25142
24687
|
this._styleStack.push(this._getStyleState());
|
|
25143
24688
|
this._transformMatrixStack.push(this.getTransform());
|
|
25144
24689
|
}
|
|
24690
|
+
clearRect(x, y, width, height) {
|
|
24691
|
+
if (x !== 0 || y !== 0 || this._width !== width || this._height !== height) {
|
|
24692
|
+
throw new Error("clearRect is not supported in SVG");
|
|
24693
|
+
}
|
|
24694
|
+
this._clearCanvas();
|
|
24695
|
+
}
|
|
25145
24696
|
restore() {
|
|
25146
|
-
|
|
25147
|
-
|
|
25148
|
-
|
|
25149
|
-
|
|
25150
|
-
|
|
25151
|
-
|
|
24697
|
+
if (this._groupStack.length) {
|
|
24698
|
+
const group = this._groupStack.pop();
|
|
24699
|
+
if (!this._isTransformationGroup(this._currentGroup)) {
|
|
24700
|
+
group.children = group.children.filter(
|
|
24701
|
+
(child) => child !== this._currentGroup
|
|
24702
|
+
);
|
|
24703
|
+
group.children.push(...this._currentGroup.children);
|
|
24704
|
+
}
|
|
24705
|
+
this._currentGroup = group;
|
|
24706
|
+
} else {
|
|
24707
|
+
this._currentGroup = this._root;
|
|
24708
|
+
}
|
|
24709
|
+
if (this._styleStack.length) {
|
|
24710
|
+
const state = this._styleStack.pop();
|
|
24711
|
+
this._applyStyleState(state);
|
|
24712
|
+
}
|
|
24713
|
+
if (this._transformMatrixStack.length) {
|
|
24714
|
+
const { a, b, c, d, e, f } = this._transformMatrixStack.pop();
|
|
24715
|
+
this.setTransform(a, b, c, d, e, f);
|
|
25152
24716
|
}
|
|
25153
|
-
this._currentGroup = group;
|
|
25154
|
-
const state = this._styleStack.pop();
|
|
25155
|
-
this._applyStyleState(state);
|
|
25156
|
-
const { a, b, c, d, e, f } = this._transformMatrixStack.pop();
|
|
25157
|
-
this.setTransform(a, b, c, d, e, f);
|
|
25158
24717
|
}
|
|
25159
24718
|
beginPath() {
|
|
25160
24719
|
this._currentPosition = {};
|
|
@@ -25325,8 +24884,25 @@ var SvgCanvasContext = class {
|
|
|
25325
24884
|
);
|
|
25326
24885
|
this._currentPosition = { x: endX, y: endY };
|
|
25327
24886
|
}
|
|
25328
|
-
stroke() {
|
|
25329
|
-
if (
|
|
24887
|
+
stroke(path) {
|
|
24888
|
+
if (path instanceof SvgPath2D) {
|
|
24889
|
+
const d = toCommands(path);
|
|
24890
|
+
if (d && d !== "Z") {
|
|
24891
|
+
const parent = this._currentGroup;
|
|
24892
|
+
const pathElement = {
|
|
24893
|
+
tag: "path",
|
|
24894
|
+
attrs: {
|
|
24895
|
+
d,
|
|
24896
|
+
fill: "none",
|
|
24897
|
+
stroke: "none",
|
|
24898
|
+
"stroke-width": "0"
|
|
24899
|
+
}
|
|
24900
|
+
};
|
|
24901
|
+
this._applyTransformation(pathElement);
|
|
24902
|
+
this._applyStyle(pathElement, "stroke");
|
|
24903
|
+
parent.children.push(pathElement);
|
|
24904
|
+
}
|
|
24905
|
+
} else if (this._currentElement) {
|
|
25330
24906
|
this._applyStyle(this._currentElement, "stroke");
|
|
25331
24907
|
}
|
|
25332
24908
|
}
|
|
@@ -25475,6 +25051,9 @@ var SvgCanvasContext = class {
|
|
|
25475
25051
|
const fillRuleValue = fillRule ?? path;
|
|
25476
25052
|
this._currentStyle.fillRule = fillRuleValue;
|
|
25477
25053
|
}
|
|
25054
|
+
if (path instanceof SvgPath2D && path.commands.length === 0) {
|
|
25055
|
+
return;
|
|
25056
|
+
}
|
|
25478
25057
|
const id = `clip_${crypto.randomUUID()}`;
|
|
25479
25058
|
const clipPath = {
|
|
25480
25059
|
tag: "clipPath",
|
|
@@ -25637,7 +25216,6 @@ var SvgCanvasContext = class {
|
|
|
25637
25216
|
}
|
|
25638
25217
|
} else {
|
|
25639
25218
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25640
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25641
25219
|
if (strokeStyle instanceof SvgPattern) {
|
|
25642
25220
|
const path = transformPath(commands, transform);
|
|
25643
25221
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25668,9 +25246,7 @@ var SvgCanvasContext = class {
|
|
|
25668
25246
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25669
25247
|
}
|
|
25670
25248
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25671
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25672
|
-
} else {
|
|
25673
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25249
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25674
25250
|
}
|
|
25675
25251
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25676
25252
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|
|
@@ -25714,21 +25290,13 @@ var SvgCanvasContext = class {
|
|
|
25714
25290
|
parent.children.push(textElement);
|
|
25715
25291
|
}
|
|
25716
25292
|
_clearCanvas() {
|
|
25717
|
-
const rootGroup = this._root.children[1];
|
|
25718
25293
|
this._defs.children = [];
|
|
25719
|
-
this._root.children = this.
|
|
25720
|
-
|
|
25721
|
-
);
|
|
25722
|
-
this._currentGroup = {
|
|
25723
|
-
tag: "g",
|
|
25724
|
-
attrs: {},
|
|
25725
|
-
children: []
|
|
25726
|
-
};
|
|
25727
|
-
this._root.children.push(this._currentGroup);
|
|
25294
|
+
this._root.children = [this._defs];
|
|
25295
|
+
this._currentGroup = this._root;
|
|
25728
25296
|
this._groupStack = [];
|
|
25729
25297
|
}
|
|
25730
25298
|
};
|
|
25731
|
-
async function
|
|
25299
|
+
async function createSvgContext(width, height) {
|
|
25732
25300
|
const canvas = await createCanvas(width, height);
|
|
25733
25301
|
return new SvgCanvasContext(
|
|
25734
25302
|
width,
|
|
@@ -25743,6 +25311,359 @@ async function toSvgNode(ctx) {
|
|
|
25743
25311
|
return ctx.getNode();
|
|
25744
25312
|
}
|
|
25745
25313
|
|
|
25314
|
+
// src/lib/utils.ts
|
|
25315
|
+
async function canvasToData(canvas) {
|
|
25316
|
+
if ("toBlob" in canvas) {
|
|
25317
|
+
const blob = await new Promise(
|
|
25318
|
+
(resolve) => canvas.toBlob((data) => resolve(data))
|
|
25319
|
+
);
|
|
25320
|
+
if (!blob) {
|
|
25321
|
+
throw new Error("Failed to generate graphics");
|
|
25322
|
+
}
|
|
25323
|
+
return new Uint8Array(await blob.arrayBuffer());
|
|
25324
|
+
}
|
|
25325
|
+
const buffer = await canvas.encode("png");
|
|
25326
|
+
return new Uint8Array(buffer);
|
|
25327
|
+
}
|
|
25328
|
+
async function toDataUrl(data, type = "image/png") {
|
|
25329
|
+
if (typeof FileReader !== "undefined") {
|
|
25330
|
+
return new Promise((resolve) => {
|
|
25331
|
+
const reader = new FileReader();
|
|
25332
|
+
reader.onload = () => {
|
|
25333
|
+
resolve(reader.result);
|
|
25334
|
+
};
|
|
25335
|
+
reader.readAsDataURL(new Blob([data], { type }));
|
|
25336
|
+
});
|
|
25337
|
+
}
|
|
25338
|
+
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
25339
|
+
}
|
|
25340
|
+
function makeSerializable(object) {
|
|
25341
|
+
if (typeof object !== "object" || object === null) {
|
|
25342
|
+
return object;
|
|
25343
|
+
}
|
|
25344
|
+
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) {
|
|
25345
|
+
return makeSerializable(Array.from(object));
|
|
25346
|
+
}
|
|
25347
|
+
if (object instanceof BigInt64Array || object instanceof BigUint64Array) {
|
|
25348
|
+
return makeSerializable(Array.from(object));
|
|
25349
|
+
}
|
|
25350
|
+
if (Array.isArray(object)) {
|
|
25351
|
+
return object.map(makeSerializable);
|
|
25352
|
+
}
|
|
25353
|
+
return Object.fromEntries(
|
|
25354
|
+
Object.entries(object).map(([key, value]) => [
|
|
25355
|
+
key,
|
|
25356
|
+
makeSerializable(value)
|
|
25357
|
+
])
|
|
25358
|
+
);
|
|
25359
|
+
}
|
|
25360
|
+
|
|
25361
|
+
// src/lib/PDFPageProxy.ts
|
|
25362
|
+
var getAnnotations = PDFPageProxy.prototype.getAnnotations;
|
|
25363
|
+
PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
25364
|
+
const annotations = await getAnnotations.call(this, params);
|
|
25365
|
+
const operatorList = await this.getOperatorList({
|
|
25366
|
+
annotationMode: AnnotationMode.ENABLE_FORMS
|
|
25367
|
+
});
|
|
25368
|
+
const annotationOperatorsList = new AnnotationOperatorsList(operatorList);
|
|
25369
|
+
for (const annotation of annotations) {
|
|
25370
|
+
const opList = annotationOperatorsList.get(annotation.id);
|
|
25371
|
+
if (opList) {
|
|
25372
|
+
if (annotation.subtype === "Stamp") {
|
|
25373
|
+
try {
|
|
25374
|
+
const canvasFactory = isNodeJS ? new NodeCanvasFactory({}) : new DOMCanvasFactory({});
|
|
25375
|
+
const scale = 2;
|
|
25376
|
+
const viewport = this.getViewport({ scale });
|
|
25377
|
+
const svgContext = await createSvgContext(
|
|
25378
|
+
viewport.width,
|
|
25379
|
+
viewport.height
|
|
25380
|
+
);
|
|
25381
|
+
const gsx = new CanvasGraphics(
|
|
25382
|
+
svgContext,
|
|
25383
|
+
this.commonObjs,
|
|
25384
|
+
this.objs,
|
|
25385
|
+
canvasFactory,
|
|
25386
|
+
this.filterFactory,
|
|
25387
|
+
{ optionalContentConfig: null }
|
|
25388
|
+
);
|
|
25389
|
+
gsx.beginDrawing({
|
|
25390
|
+
transform: null,
|
|
25391
|
+
viewport
|
|
25392
|
+
});
|
|
25393
|
+
svgContext.clearRect(0, 0, viewport.width, viewport.height);
|
|
25394
|
+
gsx.executeOperatorList({
|
|
25395
|
+
fnArray: opList.map((op) => op.fn),
|
|
25396
|
+
argsArray: opList.map((op) => op.args)
|
|
25397
|
+
});
|
|
25398
|
+
const width = annotation.rect[2] - annotation.rect[0];
|
|
25399
|
+
const height = annotation.rect[3] - annotation.rect[1];
|
|
25400
|
+
annotation.graphics = {
|
|
25401
|
+
tag: "svg",
|
|
25402
|
+
attrs: {
|
|
25403
|
+
version: "1.1",
|
|
25404
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
25405
|
+
width: `${width}`,
|
|
25406
|
+
height: `${height}`,
|
|
25407
|
+
viewBox: `0 0 ${width * scale} ${height * scale}`,
|
|
25408
|
+
preserveAspectRatio: "none",
|
|
25409
|
+
"xml:space": "preserve"
|
|
25410
|
+
},
|
|
25411
|
+
children: [
|
|
25412
|
+
{
|
|
25413
|
+
tag: "g",
|
|
25414
|
+
attrs: {
|
|
25415
|
+
transform: `translate(-${annotation.rect[0] * scale}, -${(this.view[3] - annotation.rect[1] - height) * scale})`
|
|
25416
|
+
},
|
|
25417
|
+
children: [await toSvgNode(svgContext)]
|
|
25418
|
+
}
|
|
25419
|
+
]
|
|
25420
|
+
};
|
|
25421
|
+
} catch (e) {
|
|
25422
|
+
console.error(e);
|
|
25423
|
+
}
|
|
25424
|
+
} else {
|
|
25425
|
+
switch (annotation.subtype) {
|
|
25426
|
+
case "Square":
|
|
25427
|
+
case "Circle":
|
|
25428
|
+
case "Polygon":
|
|
25429
|
+
case "Line":
|
|
25430
|
+
case "PolyLine":
|
|
25431
|
+
case "FreeText":
|
|
25432
|
+
case "Ink": {
|
|
25433
|
+
let firstStroke = true;
|
|
25434
|
+
let firstFill = true;
|
|
25435
|
+
let firstText = true;
|
|
25436
|
+
let currentFillColor = null;
|
|
25437
|
+
let currentLineWidth = null;
|
|
25438
|
+
for (const { fn, args } of opList) {
|
|
25439
|
+
const finalFn = fn === OPS.constructPath ? args[0] : fn;
|
|
25440
|
+
if (finalFn === OPS.fill) {
|
|
25441
|
+
if (currentFillColor && firstFill) {
|
|
25442
|
+
annotation.interiorColor = currentFillColor;
|
|
25443
|
+
currentFillColor = null;
|
|
25444
|
+
}
|
|
25445
|
+
firstFill = false;
|
|
25446
|
+
continue;
|
|
25447
|
+
}
|
|
25448
|
+
if (fn === OPS.beginText) {
|
|
25449
|
+
if (firstFill) {
|
|
25450
|
+
annotation.interiorColor = null;
|
|
25451
|
+
}
|
|
25452
|
+
firstFill = false;
|
|
25453
|
+
currentFillColor = null;
|
|
25454
|
+
continue;
|
|
25455
|
+
}
|
|
25456
|
+
if (finalFn === OPS.stroke || finalFn === OPS.closeStroke) {
|
|
25457
|
+
if (currentLineWidth === null && firstStroke) {
|
|
25458
|
+
annotation.borderStyle.width = 1;
|
|
25459
|
+
}
|
|
25460
|
+
firstStroke = false;
|
|
25461
|
+
currentLineWidth = null;
|
|
25462
|
+
continue;
|
|
25463
|
+
}
|
|
25464
|
+
if (finalFn === OPS.fillStroke || finalFn === OPS.closeFillStroke) {
|
|
25465
|
+
if (currentFillColor && firstFill) {
|
|
25466
|
+
annotation.interiorColor = currentFillColor;
|
|
25467
|
+
}
|
|
25468
|
+
if (currentLineWidth === null && firstStroke) {
|
|
25469
|
+
annotation.borderStyle.width = 1;
|
|
25470
|
+
}
|
|
25471
|
+
firstFill = false;
|
|
25472
|
+
firstStroke = false;
|
|
25473
|
+
currentFillColor = null;
|
|
25474
|
+
currentLineWidth = null;
|
|
25475
|
+
break;
|
|
25476
|
+
}
|
|
25477
|
+
if (!firstFill && !firstStroke) {
|
|
25478
|
+
break;
|
|
25479
|
+
}
|
|
25480
|
+
if (fn === OPS.setLineWidth && firstStroke) {
|
|
25481
|
+
currentLineWidth = args[0];
|
|
25482
|
+
annotation.borderStyle.width = currentLineWidth;
|
|
25483
|
+
}
|
|
25484
|
+
if (fn === OPS.setStrokeRGBColor && firstStroke) {
|
|
25485
|
+
annotation.color = args;
|
|
25486
|
+
}
|
|
25487
|
+
if (fn === OPS.setFillRGBColor && firstFill) {
|
|
25488
|
+
currentFillColor = args;
|
|
25489
|
+
}
|
|
25490
|
+
if (fn === OPS.setGState) {
|
|
25491
|
+
for (const entry of args[0]) {
|
|
25492
|
+
if (!Array.isArray(entry)) {
|
|
25493
|
+
continue;
|
|
25494
|
+
}
|
|
25495
|
+
if (entry[0] === "ca" && firstFill) {
|
|
25496
|
+
annotation.interiorColorOpacity = entry[1];
|
|
25497
|
+
}
|
|
25498
|
+
if (entry[0] === "CA" && firstStroke) {
|
|
25499
|
+
annotation.borderColorOpacity = entry[1];
|
|
25500
|
+
}
|
|
25501
|
+
}
|
|
25502
|
+
}
|
|
25503
|
+
if (fn === OPS.setFont && firstText) {
|
|
25504
|
+
const fontName = args[0];
|
|
25505
|
+
const font = fontName.startsWith("g_") ? this.commonObjs.get(fontName) : this.objs.get(fontName);
|
|
25506
|
+
if (font) {
|
|
25507
|
+
annotation.defaultAppearanceData.fontName = font.fallbackName;
|
|
25508
|
+
}
|
|
25509
|
+
}
|
|
25510
|
+
if (fn === OPS.endText) {
|
|
25511
|
+
firstText = false;
|
|
25512
|
+
}
|
|
25513
|
+
}
|
|
25514
|
+
if (firstStroke) {
|
|
25515
|
+
annotation.borderStyle.width = 0;
|
|
25516
|
+
}
|
|
25517
|
+
break;
|
|
25518
|
+
}
|
|
25519
|
+
}
|
|
25520
|
+
}
|
|
25521
|
+
}
|
|
25522
|
+
}
|
|
25523
|
+
return makeSerializable(annotations);
|
|
25524
|
+
};
|
|
25525
|
+
|
|
25526
|
+
// src/lib/StandardFontDataFactory.ts
|
|
25527
|
+
var StandardFontDataFactory = class extends BaseStandardFontDataFactory {
|
|
25528
|
+
constructor() {
|
|
25529
|
+
super({
|
|
25530
|
+
baseUrl: null
|
|
25531
|
+
});
|
|
25532
|
+
}
|
|
25533
|
+
/**
|
|
25534
|
+
* Fetch the corresponding standard font data.
|
|
25535
|
+
* We need to use specific dynamic imports for each font file for the bundler to include them.
|
|
25536
|
+
*/
|
|
25537
|
+
async fetch({ filename }) {
|
|
25538
|
+
switch (filename) {
|
|
25539
|
+
case "FoxitDingbats.pfb":
|
|
25540
|
+
return import("./FoxitDingbats-SB6TO3S5.js").then((module) => module.default);
|
|
25541
|
+
case "FoxitFixed.pfb":
|
|
25542
|
+
return import("./FoxitFixed-UIGSMBQB.js").then(
|
|
25543
|
+
(module) => module.default
|
|
25544
|
+
);
|
|
25545
|
+
case "FoxitFixedBold.pfb":
|
|
25546
|
+
return import("./FoxitFixedBold-2PAEIZAT.js").then((module) => module.default);
|
|
25547
|
+
case "FoxitFixedBoldItalic.pfb":
|
|
25548
|
+
return import("./FoxitFixedBoldItalic-OSQUQDEE.js").then((module) => module.default);
|
|
25549
|
+
case "FoxitFixedItalic.pfb":
|
|
25550
|
+
return import("./FoxitFixedItalic-W73RDK22.js").then((module) => module.default);
|
|
25551
|
+
case "FoxitSerif.pfb":
|
|
25552
|
+
return import("./FoxitSerif-3HH3SOZF.js").then(
|
|
25553
|
+
(module) => module.default
|
|
25554
|
+
);
|
|
25555
|
+
case "FoxitSerifBold.pfb":
|
|
25556
|
+
return import("./FoxitSerifBold-HXP2QOO7.js").then((module) => module.default);
|
|
25557
|
+
case "FoxitSerifBoldItalic.pfb":
|
|
25558
|
+
return import("./FoxitSerifBoldItalic-FZXLNWD7.js").then((module) => module.default);
|
|
25559
|
+
case "FoxitSerifItalic.pfb":
|
|
25560
|
+
return import("./FoxitSerifItalic-WQFHUBI2.js").then((module) => module.default);
|
|
25561
|
+
case "FoxitSymbol.pfb":
|
|
25562
|
+
return import("./FoxitSymbol-OVWU7LKS.js").then(
|
|
25563
|
+
(module) => module.default
|
|
25564
|
+
);
|
|
25565
|
+
case "LiberationSans-Bold.ttf":
|
|
25566
|
+
return import("./LiberationSans-Bold-GSJN42N5.js").then((module) => module.default);
|
|
25567
|
+
case "LiberationSans-BoldItalic.ttf":
|
|
25568
|
+
return import("./LiberationSans-BoldItalic-UCPQJ3L2.js").then((module) => module.default);
|
|
25569
|
+
case "LiberationSans-Italic.ttf":
|
|
25570
|
+
return import("./LiberationSans-Italic-6CIHEALY.js").then((module) => module.default);
|
|
25571
|
+
case "LiberationSans-Regular.ttf":
|
|
25572
|
+
return import("./LiberationSans-Regular-KIF3IRJY.js").then((module) => module.default);
|
|
25573
|
+
}
|
|
25574
|
+
return Uint8Array.from([]);
|
|
25575
|
+
}
|
|
25576
|
+
};
|
|
25577
|
+
|
|
25578
|
+
// src/lib/AnnotationData.ts
|
|
25579
|
+
function isTextAnnotation(annotation) {
|
|
25580
|
+
return annotation.subtype === "Text";
|
|
25581
|
+
}
|
|
25582
|
+
function isLinkAnnotation(annotation) {
|
|
25583
|
+
return annotation.subtype === "Link";
|
|
25584
|
+
}
|
|
25585
|
+
function isFreeTextAnnotation(annotation) {
|
|
25586
|
+
return annotation.subtype === "FreeText";
|
|
25587
|
+
}
|
|
25588
|
+
function isLineAnnotation(annotation) {
|
|
25589
|
+
return annotation.subtype === "Line";
|
|
25590
|
+
}
|
|
25591
|
+
function isSquareAnnotation(annotation) {
|
|
25592
|
+
return annotation.subtype === "Square";
|
|
25593
|
+
}
|
|
25594
|
+
function isCircleAnnotation(annotation) {
|
|
25595
|
+
return annotation.subtype === "Circle";
|
|
25596
|
+
}
|
|
25597
|
+
function isPolygonAnnotation(annotation) {
|
|
25598
|
+
return annotation.subtype === "Polygon";
|
|
25599
|
+
}
|
|
25600
|
+
function isPolylineAnnotation(annotation) {
|
|
25601
|
+
return annotation.subtype === "PolyLine";
|
|
25602
|
+
}
|
|
25603
|
+
function isHighlightAnnotation(annotation) {
|
|
25604
|
+
return annotation.subtype === "Highlight";
|
|
25605
|
+
}
|
|
25606
|
+
function isUnderlineAnnotation(annotation) {
|
|
25607
|
+
return annotation.subtype === "Underline";
|
|
25608
|
+
}
|
|
25609
|
+
function isSquigglyAnnotation(annotation) {
|
|
25610
|
+
return annotation.subtype === "Squiggly";
|
|
25611
|
+
}
|
|
25612
|
+
function isStrikeOutAnnotation(annotation) {
|
|
25613
|
+
return annotation.subtype === "StrikeOut";
|
|
25614
|
+
}
|
|
25615
|
+
function isStampAnnotation(annotation) {
|
|
25616
|
+
return annotation.subtype === "Stamp";
|
|
25617
|
+
}
|
|
25618
|
+
function isCaretAnnotation(annotation) {
|
|
25619
|
+
return annotation.subtype === "Caret";
|
|
25620
|
+
}
|
|
25621
|
+
function isInkAnnotation(annotation) {
|
|
25622
|
+
return annotation.subtype === "Ink";
|
|
25623
|
+
}
|
|
25624
|
+
function isPopupAnnotation(annotation) {
|
|
25625
|
+
return annotation.subtype === "Popup";
|
|
25626
|
+
}
|
|
25627
|
+
function isFileAttachmentAnnotation(annotation) {
|
|
25628
|
+
return annotation.subtype === "FileAttachment";
|
|
25629
|
+
}
|
|
25630
|
+
function isSoundAnnotation(annotation) {
|
|
25631
|
+
return annotation.subtype === "Sound";
|
|
25632
|
+
}
|
|
25633
|
+
function isMovieAnnotation(annotation) {
|
|
25634
|
+
return annotation.subtype === "Movie";
|
|
25635
|
+
}
|
|
25636
|
+
function isWidgetAnnotation(annotation) {
|
|
25637
|
+
return annotation.subtype === "Widget";
|
|
25638
|
+
}
|
|
25639
|
+
function isTextWidgetAnnotation(annotation) {
|
|
25640
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Tx";
|
|
25641
|
+
}
|
|
25642
|
+
function isChoiceWidgetAnnotation(annotation) {
|
|
25643
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Ch";
|
|
25644
|
+
}
|
|
25645
|
+
function isButtonWidgetAnnotation(annotation) {
|
|
25646
|
+
return annotation.subtype === "Widget" && annotation.fieldType === "Btn";
|
|
25647
|
+
}
|
|
25648
|
+
function isScreenAnnotation(annotation) {
|
|
25649
|
+
return annotation.subtype === "Screen";
|
|
25650
|
+
}
|
|
25651
|
+
function isPrinterMarkAnnotation(annotation) {
|
|
25652
|
+
return annotation.subtype === "PrinterMark";
|
|
25653
|
+
}
|
|
25654
|
+
function isTrapNetAnnotation(annotation) {
|
|
25655
|
+
return annotation.subtype === "TrapNet";
|
|
25656
|
+
}
|
|
25657
|
+
function isWatermarkAnnotation(annotation) {
|
|
25658
|
+
return annotation.subtype === "Watermark";
|
|
25659
|
+
}
|
|
25660
|
+
function isThreeDAnnotation(annotation) {
|
|
25661
|
+
return annotation.subtype === "3D";
|
|
25662
|
+
}
|
|
25663
|
+
function isRedactAnnotation(annotation) {
|
|
25664
|
+
return annotation.subtype === "Redact";
|
|
25665
|
+
}
|
|
25666
|
+
|
|
25746
25667
|
// src/lib/TextLayer.ts
|
|
25747
25668
|
function isTextNode(node) {
|
|
25748
25669
|
return node.role === "text";
|
|
@@ -25757,17 +25678,6 @@ var MAX_TEXT_DIVS_TO_RENDER2 = 1e5;
|
|
|
25757
25678
|
var DEFAULT_FONT_SIZE3 = 30;
|
|
25758
25679
|
var DEFAULT_FONT_ASCENT = 0.8;
|
|
25759
25680
|
var HYPHEN_REGEX = /-\n+$/;
|
|
25760
|
-
function getDefaultFontFamily(type) {
|
|
25761
|
-
switch (type) {
|
|
25762
|
-
case "serif":
|
|
25763
|
-
return "Liberation Serif";
|
|
25764
|
-
case "monospace":
|
|
25765
|
-
return "Liberation Mono";
|
|
25766
|
-
default:
|
|
25767
|
-
return "Liberation Sans";
|
|
25768
|
-
}
|
|
25769
|
-
}
|
|
25770
|
-
var loadingFontsPromise = null;
|
|
25771
25681
|
async function createTextLayer(page, {
|
|
25772
25682
|
canvasFactory,
|
|
25773
25683
|
viewport = page.getViewport({ scale: 1 }),
|
|
@@ -25907,7 +25817,7 @@ async function createTextLayer(page, {
|
|
|
25907
25817
|
}
|
|
25908
25818
|
if (shouldScaleText) {
|
|
25909
25819
|
if (canvasContext) {
|
|
25910
|
-
canvasContext.font =
|
|
25820
|
+
canvasContext.font = `400 ${fontHeight * outputScale}px 'Liberation Sans'`;
|
|
25911
25821
|
const { width } = canvasContext.measureText(geom.str);
|
|
25912
25822
|
if (width > 0) {
|
|
25913
25823
|
textDiv.scale = (style.vertical ? geom.height : geom.width) * outputScale / width;
|
|
@@ -25920,10 +25830,6 @@ async function createTextLayer(page, {
|
|
|
25920
25830
|
const lang = inputLang || "";
|
|
25921
25831
|
let canvasContext2 = canvasCache.get(lang);
|
|
25922
25832
|
if (!canvasContext2) {
|
|
25923
|
-
if (!loadingFontsPromise) {
|
|
25924
|
-
loadingFontsPromise = loadDefaultFonts();
|
|
25925
|
-
}
|
|
25926
|
-
await loadingFontsPromise;
|
|
25927
25833
|
const { context } = await canvasFactory.create(100, 100);
|
|
25928
25834
|
context.canvas.lang = lang;
|
|
25929
25835
|
canvasContext2 = context;
|
|
@@ -25941,7 +25847,7 @@ async function createTextLayer(page, {
|
|
|
25941
25847
|
}
|
|
25942
25848
|
const savedFont = canvasContext.font;
|
|
25943
25849
|
canvasContext.canvas.width = canvasContext.canvas.height = DEFAULT_FONT_SIZE3;
|
|
25944
|
-
canvasContext.font =
|
|
25850
|
+
canvasContext.font = `400 ${DEFAULT_FONT_SIZE3}px 'Liberation Sans'`;
|
|
25945
25851
|
const metrics = canvasContext.measureText(" ");
|
|
25946
25852
|
let ascent = metrics.fontBoundingBoxAscent;
|
|
25947
25853
|
let descent = Math.abs(metrics.fontBoundingBoxDescent);
|
|
@@ -26213,6 +26119,7 @@ async function createTextLayer(page, {
|
|
|
26213
26119
|
}
|
|
26214
26120
|
return null;
|
|
26215
26121
|
};
|
|
26122
|
+
await loadDefaultFonts();
|
|
26216
26123
|
const reader = textContentSource.getReader();
|
|
26217
26124
|
while (true) {
|
|
26218
26125
|
const { value, done } = await reader.read();
|
|
@@ -26246,12 +26153,14 @@ export {
|
|
|
26246
26153
|
GlobalWorkerOptions,
|
|
26247
26154
|
ImageKind,
|
|
26248
26155
|
InvalidPDFException,
|
|
26156
|
+
MathClamp,
|
|
26249
26157
|
OPS,
|
|
26250
26158
|
OutputScale,
|
|
26251
26159
|
PDFDataRangeTransport,
|
|
26252
26160
|
PDFDateString,
|
|
26253
26161
|
PDFWorker,
|
|
26254
26162
|
PasswordResponses,
|
|
26163
|
+
Path2DConstructor as Path2D,
|
|
26255
26164
|
PermissionFlag,
|
|
26256
26165
|
PixelsPerInch,
|
|
26257
26166
|
RenderingCancelledException,
|
|
@@ -26267,11 +26176,11 @@ export {
|
|
|
26267
26176
|
XfaLayer,
|
|
26268
26177
|
build,
|
|
26269
26178
|
canvasToData,
|
|
26270
|
-
|
|
26179
|
+
createCanvas,
|
|
26180
|
+
createSvgContext,
|
|
26271
26181
|
createTextLayer,
|
|
26272
26182
|
createValidAbsoluteUrl,
|
|
26273
26183
|
fetchData,
|
|
26274
|
-
getDefaultFontFamily,
|
|
26275
26184
|
getDocument,
|
|
26276
26185
|
getFilenameFromUrl,
|
|
26277
26186
|
getPdfFilenameFromUrl,
|
|
@@ -26311,8 +26220,11 @@ export {
|
|
|
26311
26220
|
isThreeDAnnotation,
|
|
26312
26221
|
isTrapNetAnnotation,
|
|
26313
26222
|
isUnderlineAnnotation,
|
|
26223
|
+
isValidExplicitDest,
|
|
26314
26224
|
isWatermarkAnnotation,
|
|
26315
26225
|
isWidgetAnnotation,
|
|
26226
|
+
loadDefaultFonts,
|
|
26227
|
+
makeSerializable,
|
|
26316
26228
|
noContextMenu,
|
|
26317
26229
|
normalizeUnicode,
|
|
26318
26230
|
setLayerDimensions,
|