@chialab/pdfjs-lib 1.0.0-alpha.6 → 1.0.0-alpha.7
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-KKGFKVEF.js → chunk-LJIJQE3F.js} +83 -24
- package/dist/browser/index.js +81 -210
- package/dist/browser/worker.js +3412 -3258
- package/dist/lib/SvgCanvasContext.d.ts +1 -1
- package/dist/node/{chunk-PWUBNK7D.js → chunk-XZBSEIET.js} +83 -24
- package/dist/node/index.js +81 -210
- package/dist/node/worker.js +3412 -3258
- package/dist/pdf.js/src/display/canvas.d.ts +1 -1
- package/dist/pdf.js/src/shared/util.d.ts +6 -3
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ export declare class SvgCanvasContext {
|
|
|
113
113
|
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
|
|
114
114
|
rect(x: number, y: number, width: number, height: number): void;
|
|
115
115
|
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: boolean): void;
|
|
116
|
-
stroke(): void;
|
|
116
|
+
stroke(path?: Path2D): void;
|
|
117
117
|
transform(...values: number[]): void;
|
|
118
118
|
translate(x: number, y: number): void;
|
|
119
119
|
scale(x: number, y: number): void;
|
|
@@ -324,7 +324,8 @@ var OPS = {
|
|
|
324
324
|
paintSolidColorImageMask: 90,
|
|
325
325
|
constructPath: 91,
|
|
326
326
|
setStrokeTransparent: 92,
|
|
327
|
-
setFillTransparent: 93
|
|
327
|
+
setFillTransparent: 93,
|
|
328
|
+
rawFillPath: 94
|
|
328
329
|
};
|
|
329
330
|
var DrawOPS = {
|
|
330
331
|
moveTo: 0,
|
|
@@ -576,10 +577,57 @@ var hexNumbers = Array.from(
|
|
|
576
577
|
(n) => n.toString(16).padStart(2, "0")
|
|
577
578
|
);
|
|
578
579
|
var _Util_static, getExtremumOnCurve_fn, getExtremum_fn;
|
|
579
|
-
var
|
|
580
|
+
var _Util = class _Util {
|
|
580
581
|
static makeHexColor(r, g, b) {
|
|
581
582
|
return `#${hexNumbers[r]}${hexNumbers[g]}${hexNumbers[b]}`;
|
|
582
583
|
}
|
|
584
|
+
// Apply a scaling matrix to some min/max values.
|
|
585
|
+
// If a scaling factor is negative then min and max must be
|
|
586
|
+
// swapped.
|
|
587
|
+
static scaleMinMax(transform, minMax) {
|
|
588
|
+
let temp;
|
|
589
|
+
if (transform[0]) {
|
|
590
|
+
if (transform[0] < 0) {
|
|
591
|
+
temp = minMax[0];
|
|
592
|
+
minMax[0] = minMax[2];
|
|
593
|
+
minMax[2] = temp;
|
|
594
|
+
}
|
|
595
|
+
minMax[0] *= transform[0];
|
|
596
|
+
minMax[2] *= transform[0];
|
|
597
|
+
if (transform[3] < 0) {
|
|
598
|
+
temp = minMax[1];
|
|
599
|
+
minMax[1] = minMax[3];
|
|
600
|
+
minMax[3] = temp;
|
|
601
|
+
}
|
|
602
|
+
minMax[1] *= transform[3];
|
|
603
|
+
minMax[3] *= transform[3];
|
|
604
|
+
} else {
|
|
605
|
+
temp = minMax[0];
|
|
606
|
+
minMax[0] = minMax[1];
|
|
607
|
+
minMax[1] = temp;
|
|
608
|
+
temp = minMax[2];
|
|
609
|
+
minMax[2] = minMax[3];
|
|
610
|
+
minMax[3] = temp;
|
|
611
|
+
if (transform[1] < 0) {
|
|
612
|
+
temp = minMax[1];
|
|
613
|
+
minMax[1] = minMax[3];
|
|
614
|
+
minMax[3] = temp;
|
|
615
|
+
}
|
|
616
|
+
minMax[1] *= transform[1];
|
|
617
|
+
minMax[3] *= transform[1];
|
|
618
|
+
if (transform[2] < 0) {
|
|
619
|
+
temp = minMax[0];
|
|
620
|
+
minMax[0] = minMax[2];
|
|
621
|
+
minMax[2] = temp;
|
|
622
|
+
}
|
|
623
|
+
minMax[0] *= transform[2];
|
|
624
|
+
minMax[2] *= transform[2];
|
|
625
|
+
}
|
|
626
|
+
minMax[0] += transform[4];
|
|
627
|
+
minMax[1] += transform[5];
|
|
628
|
+
minMax[2] += transform[4];
|
|
629
|
+
minMax[3] += transform[5];
|
|
630
|
+
}
|
|
583
631
|
// Concatenates two transformation matrices together and returns the result.
|
|
584
632
|
static transform(m1, m2) {
|
|
585
633
|
return [
|
|
@@ -593,23 +641,36 @@ var Util = class {
|
|
|
593
641
|
}
|
|
594
642
|
// For 2d affine transforms
|
|
595
643
|
static applyTransform(p, m) {
|
|
596
|
-
const
|
|
597
|
-
|
|
598
|
-
|
|
644
|
+
const [p0, p1] = p;
|
|
645
|
+
p[0] = p0 * m[0] + p1 * m[2] + m[4];
|
|
646
|
+
p[1] = p0 * m[1] + p1 * m[3] + m[5];
|
|
647
|
+
}
|
|
648
|
+
// For 2d affine transforms
|
|
649
|
+
static applyTransformToBezier(p, [m0, m1, m2, m3, m4, m5]) {
|
|
650
|
+
for (let i = 0; i < 6; i += 2) {
|
|
651
|
+
const pI = p[i];
|
|
652
|
+
const pI1 = p[i + 1];
|
|
653
|
+
p[i] = pI * m0 + pI1 * m2 + m4;
|
|
654
|
+
p[i + 1] = pI * m1 + pI1 * m3 + m5;
|
|
655
|
+
}
|
|
599
656
|
}
|
|
600
657
|
static applyInverseTransform(p, m) {
|
|
658
|
+
const [p0, p1] = p;
|
|
601
659
|
const d = m[0] * m[3] - m[1] * m[2];
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return [xt, yt];
|
|
660
|
+
p[0] = (p0 * m[3] - p1 * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
|
|
661
|
+
p[1] = (-p0 * m[1] + p1 * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
|
|
605
662
|
}
|
|
606
663
|
// Applies the transform to the rectangle and finds the minimum axially
|
|
607
664
|
// aligned bounding box.
|
|
608
665
|
static getAxialAlignedBoundingBox(r, m) {
|
|
609
|
-
const p1 =
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
666
|
+
const p1 = [r[0], r[1]];
|
|
667
|
+
_Util.applyTransform(p1, m);
|
|
668
|
+
const p2 = [r[2], r[3]];
|
|
669
|
+
_Util.applyTransform(p2, m);
|
|
670
|
+
const p3 = [r[0], r[3]];
|
|
671
|
+
_Util.applyTransform(p3, m);
|
|
672
|
+
const p4 = [r[2], r[1]];
|
|
673
|
+
_Util.applyTransform(p4, m);
|
|
613
674
|
return [
|
|
614
675
|
Math.min(p1[0], p2[0], p3[0], p4[0]),
|
|
615
676
|
Math.min(p1[1], p2[1], p3[1], p4[1]),
|
|
@@ -631,17 +692,14 @@ var Util = class {
|
|
|
631
692
|
// This calculation uses Singular Value Decomposition.
|
|
632
693
|
// The SVD can be represented with formula A = USV. We are interested in the
|
|
633
694
|
// matrix S here because it represents the scale values.
|
|
634
|
-
static singularValueDecompose2dScale(
|
|
635
|
-
const
|
|
636
|
-
const
|
|
637
|
-
const
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
const sx = first + second || 1;
|
|
643
|
-
const sy = first - second || 1;
|
|
644
|
-
return [Math.sqrt(sx), Math.sqrt(sy)];
|
|
695
|
+
static singularValueDecompose2dScale([m0, m1, m2, m3], output) {
|
|
696
|
+
const a = m0 ** 2 + m1 ** 2;
|
|
697
|
+
const b = m0 * m2 + m1 * m3;
|
|
698
|
+
const c = m2 ** 2 + m3 ** 2;
|
|
699
|
+
const first = (a + c) / 2;
|
|
700
|
+
const second = Math.sqrt(first ** 2 - (a * c - b ** 2));
|
|
701
|
+
output[0] = Math.sqrt(first + second || 1);
|
|
702
|
+
output[1] = Math.sqrt(first - second || 1);
|
|
645
703
|
}
|
|
646
704
|
// Normalize rectangle rect=[x1, y1, x2, y2] so that (x1,y1) < (x2,y2)
|
|
647
705
|
// For coordinate systems whose origin lies in the bottom-left, this
|
|
@@ -740,7 +798,8 @@ getExtremum_fn = function(x0, x1, x2, x3, y0, y1, y2, y3, a, b, c, minMax) {
|
|
|
740
798
|
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b + sqrtDelta) / a2, minMax);
|
|
741
799
|
__privateMethod(this, _Util_static, getExtremumOnCurve_fn).call(this, x0, x1, x2, x3, y0, y1, y2, y3, (-b - sqrtDelta) / a2, minMax);
|
|
742
800
|
};
|
|
743
|
-
__privateAdd(
|
|
801
|
+
__privateAdd(_Util, _Util_static);
|
|
802
|
+
var Util = _Util;
|
|
744
803
|
var PDFStringTranslateTable = [
|
|
745
804
|
0,
|
|
746
805
|
0,
|
package/dist/node/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
unreachable,
|
|
47
47
|
warn,
|
|
48
48
|
wrapReason
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-XZBSEIET.js";
|
|
50
50
|
import {
|
|
51
51
|
__privateAdd,
|
|
52
52
|
__privateGet,
|
|
@@ -240,7 +240,9 @@ var PageViewport = class _PageViewport {
|
|
|
240
240
|
* @see {@link convertToViewportRectangle}
|
|
241
241
|
*/
|
|
242
242
|
convertToViewportPoint(x, y) {
|
|
243
|
-
|
|
243
|
+
const p = [x, y];
|
|
244
|
+
Util.applyTransform(p, this.transform);
|
|
245
|
+
return p;
|
|
244
246
|
}
|
|
245
247
|
/**
|
|
246
248
|
* Converts PDF rectangle to the viewport coordinates.
|
|
@@ -250,8 +252,10 @@ var PageViewport = class _PageViewport {
|
|
|
250
252
|
* @see {@link convertToViewportPoint}
|
|
251
253
|
*/
|
|
252
254
|
convertToViewportRectangle(rect) {
|
|
253
|
-
const topLeft =
|
|
254
|
-
|
|
255
|
+
const topLeft = [rect[0], rect[1]];
|
|
256
|
+
Util.applyTransform(topLeft, this.transform);
|
|
257
|
+
const bottomRight = [rect[2], rect[3]];
|
|
258
|
+
Util.applyTransform(bottomRight, this.transform);
|
|
255
259
|
return [topLeft[0], topLeft[1], bottomRight[0], bottomRight[1]];
|
|
256
260
|
}
|
|
257
261
|
/**
|
|
@@ -264,7 +268,9 @@ var PageViewport = class _PageViewport {
|
|
|
264
268
|
* @see {@link convertToViewportPoint}
|
|
265
269
|
*/
|
|
266
270
|
convertToPdfPoint(x, y) {
|
|
267
|
-
|
|
271
|
+
const p = [x, y];
|
|
272
|
+
Util.applyInverseTransform(p, this.transform);
|
|
273
|
+
return p;
|
|
268
274
|
}
|
|
269
275
|
};
|
|
270
276
|
var RenderingCancelledException = class extends BaseException {
|
|
@@ -7035,15 +7041,17 @@ var MeshShadingPattern = class extends BaseShadingPattern {
|
|
|
7035
7041
|
}
|
|
7036
7042
|
getPattern(ctx, owner, inverse, pathType) {
|
|
7037
7043
|
applyBoundingBox(ctx, this._bbox);
|
|
7038
|
-
|
|
7044
|
+
const scale = new Float32Array(2);
|
|
7039
7045
|
if (pathType === PathType.SHADING) {
|
|
7040
|
-
|
|
7046
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(ctx), scale);
|
|
7047
|
+
} else if (this.matrix) {
|
|
7048
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
7049
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
7050
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
7051
|
+
scale[0] *= matrixScaleX;
|
|
7052
|
+
scale[1] *= matrixScaleY;
|
|
7041
7053
|
} else {
|
|
7042
|
-
|
|
7043
|
-
if (this.matrix) {
|
|
7044
|
-
const matrixScale = Util.singularValueDecompose2dScale(this.matrix);
|
|
7045
|
-
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
|
|
7046
|
-
}
|
|
7054
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
7047
7055
|
}
|
|
7048
7056
|
const temporaryPatternCanvas = this._createMeshCanvas(
|
|
7049
7057
|
scale,
|
|
@@ -7114,12 +7122,12 @@ var _TilingPattern = class _TilingPattern {
|
|
|
7114
7122
|
const x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
|
7115
7123
|
const width = x1 - x0;
|
|
7116
7124
|
const height = y1 - y0;
|
|
7117
|
-
const
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
);
|
|
7121
|
-
const combinedScaleX =
|
|
7122
|
-
const combinedScaleY =
|
|
7125
|
+
const scale = new Float32Array(2);
|
|
7126
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
7127
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
7128
|
+
Util.singularValueDecompose2dScale(this.baseTransform, scale);
|
|
7129
|
+
const combinedScaleX = matrixScaleX * scale[0];
|
|
7130
|
+
const combinedScaleY = matrixScaleY * scale[1];
|
|
7123
7131
|
let canvasWidth = width, canvasHeight = height, redrawHorizontally = false, redrawVertically = false;
|
|
7124
7132
|
const xScaledStep = Math.ceil(xstep * combinedScaleX);
|
|
7125
7133
|
const yScaledStep = Math.ceil(ystep * combinedScaleY);
|
|
@@ -7300,9 +7308,9 @@ var MIN_FONT_SIZE = 16;
|
|
|
7300
7308
|
var MAX_FONT_SIZE = 100;
|
|
7301
7309
|
var EXECUTION_TIME = 15;
|
|
7302
7310
|
var EXECUTION_STEPS = 10;
|
|
7303
|
-
var MAX_SIZE_TO_COMPILE = 1e3;
|
|
7304
7311
|
var FULL_CHUNK_HEIGHT = 16;
|
|
7305
7312
|
var SCALE_MATRIX = new DOMMatrix();
|
|
7313
|
+
var XY = new Float32Array(2);
|
|
7306
7314
|
function mirrorContextOperations(ctx, destCtx) {
|
|
7307
7315
|
if (ctx._removeMirroring) {
|
|
7308
7316
|
throw new Error("Context is already forwarding operations.");
|
|
@@ -7463,145 +7471,6 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
7463
7471
|
const scaleY = Math.hypot(c, d);
|
|
7464
7472
|
return [scaleX * destW, scaleY * destH];
|
|
7465
7473
|
}
|
|
7466
|
-
function compileType3Glyph(imgData) {
|
|
7467
|
-
const { width, height } = imgData;
|
|
7468
|
-
if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
7469
|
-
return null;
|
|
7470
|
-
}
|
|
7471
|
-
const POINT_TO_PROCESS_LIMIT = 1e3;
|
|
7472
|
-
const POINT_TYPES = new Uint8Array([
|
|
7473
|
-
0,
|
|
7474
|
-
2,
|
|
7475
|
-
4,
|
|
7476
|
-
0,
|
|
7477
|
-
1,
|
|
7478
|
-
0,
|
|
7479
|
-
5,
|
|
7480
|
-
4,
|
|
7481
|
-
8,
|
|
7482
|
-
10,
|
|
7483
|
-
0,
|
|
7484
|
-
8,
|
|
7485
|
-
0,
|
|
7486
|
-
2,
|
|
7487
|
-
1,
|
|
7488
|
-
0
|
|
7489
|
-
]);
|
|
7490
|
-
const width1 = width + 1;
|
|
7491
|
-
const points = new Uint8Array(width1 * (height + 1));
|
|
7492
|
-
let i, j, j0;
|
|
7493
|
-
const lineSize = width + 7 & ~7;
|
|
7494
|
-
const data = new Uint8Array(lineSize * height);
|
|
7495
|
-
let pos = 0;
|
|
7496
|
-
for (const elem of imgData.data) {
|
|
7497
|
-
let mask = 128;
|
|
7498
|
-
while (mask > 0) {
|
|
7499
|
-
data[pos++] = elem & mask ? 0 : 255;
|
|
7500
|
-
mask >>= 1;
|
|
7501
|
-
}
|
|
7502
|
-
}
|
|
7503
|
-
let count = 0;
|
|
7504
|
-
pos = 0;
|
|
7505
|
-
if (data[pos] !== 0) {
|
|
7506
|
-
points[0] = 1;
|
|
7507
|
-
++count;
|
|
7508
|
-
}
|
|
7509
|
-
for (j = 1; j < width; j++) {
|
|
7510
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7511
|
-
points[j] = data[pos] ? 2 : 1;
|
|
7512
|
-
++count;
|
|
7513
|
-
}
|
|
7514
|
-
pos++;
|
|
7515
|
-
}
|
|
7516
|
-
if (data[pos] !== 0) {
|
|
7517
|
-
points[j] = 2;
|
|
7518
|
-
++count;
|
|
7519
|
-
}
|
|
7520
|
-
for (i = 1; i < height; i++) {
|
|
7521
|
-
pos = i * lineSize;
|
|
7522
|
-
j0 = i * width1;
|
|
7523
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7524
|
-
points[j0] = data[pos] ? 1 : 8;
|
|
7525
|
-
++count;
|
|
7526
|
-
}
|
|
7527
|
-
let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
|
7528
|
-
for (j = 1; j < width; j++) {
|
|
7529
|
-
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
|
|
7530
|
-
if (POINT_TYPES[sum]) {
|
|
7531
|
-
points[j0 + j] = POINT_TYPES[sum];
|
|
7532
|
-
++count;
|
|
7533
|
-
}
|
|
7534
|
-
pos++;
|
|
7535
|
-
}
|
|
7536
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
7537
|
-
points[j0 + j] = data[pos] ? 2 : 4;
|
|
7538
|
-
++count;
|
|
7539
|
-
}
|
|
7540
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7541
|
-
return null;
|
|
7542
|
-
}
|
|
7543
|
-
}
|
|
7544
|
-
pos = lineSize * (height - 1);
|
|
7545
|
-
j0 = i * width1;
|
|
7546
|
-
if (data[pos] !== 0) {
|
|
7547
|
-
points[j0] = 8;
|
|
7548
|
-
++count;
|
|
7549
|
-
}
|
|
7550
|
-
for (j = 1; j < width; j++) {
|
|
7551
|
-
if (data[pos] !== data[pos + 1]) {
|
|
7552
|
-
points[j0 + j] = data[pos] ? 4 : 8;
|
|
7553
|
-
++count;
|
|
7554
|
-
}
|
|
7555
|
-
pos++;
|
|
7556
|
-
}
|
|
7557
|
-
if (data[pos] !== 0) {
|
|
7558
|
-
points[j0 + j] = 4;
|
|
7559
|
-
++count;
|
|
7560
|
-
}
|
|
7561
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
7562
|
-
return null;
|
|
7563
|
-
}
|
|
7564
|
-
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
7565
|
-
const path = new SvgPath2D();
|
|
7566
|
-
const { a, b, c, d, e, f } = new DOMMatrix().scaleSelf(1 / width, -1 / height).translateSelf(0, -height);
|
|
7567
|
-
for (i = 0; count && i <= height; i++) {
|
|
7568
|
-
let p = i * width1;
|
|
7569
|
-
const end = p + width;
|
|
7570
|
-
while (p < end && !points[p]) {
|
|
7571
|
-
p++;
|
|
7572
|
-
}
|
|
7573
|
-
if (p === end) {
|
|
7574
|
-
continue;
|
|
7575
|
-
}
|
|
7576
|
-
let x = p % width1;
|
|
7577
|
-
let y = i;
|
|
7578
|
-
path.moveTo(a * x + c * y + e, b * x + d * y + f);
|
|
7579
|
-
const p0 = p;
|
|
7580
|
-
let type = points[p];
|
|
7581
|
-
do {
|
|
7582
|
-
const step = steps[type];
|
|
7583
|
-
do {
|
|
7584
|
-
p += step;
|
|
7585
|
-
} while (!points[p]);
|
|
7586
|
-
const pp = points[p];
|
|
7587
|
-
if (pp !== 5 && pp !== 10) {
|
|
7588
|
-
type = pp;
|
|
7589
|
-
points[p] = 0;
|
|
7590
|
-
} else {
|
|
7591
|
-
type = pp & 51 * type >> 4;
|
|
7592
|
-
points[p] &= type >> 2 | type << 2;
|
|
7593
|
-
}
|
|
7594
|
-
x = p % width1;
|
|
7595
|
-
y = p / width1 | 0;
|
|
7596
|
-
path.lineTo(a * x + c * y + e, b * x + d * y + f);
|
|
7597
|
-
if (!points[p]) {
|
|
7598
|
-
--count;
|
|
7599
|
-
}
|
|
7600
|
-
} while (p0 !== p);
|
|
7601
|
-
--i;
|
|
7602
|
-
}
|
|
7603
|
-
return path;
|
|
7604
|
-
}
|
|
7605
7474
|
var CanvasExtraState = class {
|
|
7606
7475
|
constructor(width, height) {
|
|
7607
7476
|
this.alphaIsShape = false;
|
|
@@ -7637,10 +7506,14 @@ var CanvasExtraState = class {
|
|
|
7637
7506
|
return clone;
|
|
7638
7507
|
}
|
|
7639
7508
|
updateRectMinMax(transform, rect) {
|
|
7640
|
-
const p1 =
|
|
7641
|
-
|
|
7642
|
-
const
|
|
7643
|
-
|
|
7509
|
+
const p1 = [rect[0], rect[1]];
|
|
7510
|
+
Util.applyTransform(p1, transform);
|
|
7511
|
+
const p2 = [rect[2], rect[3]];
|
|
7512
|
+
Util.applyTransform(p2, transform);
|
|
7513
|
+
const p3 = [rect[0], rect[3]];
|
|
7514
|
+
Util.applyTransform(p3, transform);
|
|
7515
|
+
const p4 = [rect[2], rect[1]];
|
|
7516
|
+
Util.applyTransform(p4, transform);
|
|
7644
7517
|
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
|
7645
7518
|
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
|
7646
7519
|
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
|
@@ -7652,9 +7525,9 @@ var CanvasExtraState = class {
|
|
|
7652
7525
|
if (!transform) {
|
|
7653
7526
|
unreachable("Stroke bounding box must include transform.");
|
|
7654
7527
|
}
|
|
7655
|
-
|
|
7656
|
-
const xStrokePad =
|
|
7657
|
-
const yStrokePad =
|
|
7528
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7529
|
+
const xStrokePad = XY[0] * this.lineWidth / 2;
|
|
7530
|
+
const yStrokePad = XY[1] * this.lineWidth / 2;
|
|
7658
7531
|
box[0] -= xStrokePad;
|
|
7659
7532
|
box[1] -= yStrokePad;
|
|
7660
7533
|
box[2] += xStrokePad;
|
|
@@ -7849,13 +7722,11 @@ function getImageSmoothingEnabled(transform, interpolate) {
|
|
|
7849
7722
|
if (interpolate) {
|
|
7850
7723
|
return true;
|
|
7851
7724
|
}
|
|
7852
|
-
|
|
7853
|
-
scale[0] = Math.fround(scale[0]);
|
|
7854
|
-
scale[1] = Math.fround(scale[1]);
|
|
7725
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7855
7726
|
const actualScale = Math.fround(
|
|
7856
7727
|
OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS
|
|
7857
7728
|
);
|
|
7858
|
-
return
|
|
7729
|
+
return XY[0] <= actualScale && XY[1] <= actualScale;
|
|
7859
7730
|
}
|
|
7860
7731
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
7861
7732
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
|
@@ -7880,7 +7751,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7880
7751
|
this.canvasFactory = canvasFactory;
|
|
7881
7752
|
this.filterFactory = filterFactory;
|
|
7882
7753
|
this.groupStack = [];
|
|
7883
|
-
this.processingType3 = null;
|
|
7884
7754
|
this.baseTransform = null;
|
|
7885
7755
|
this.baseTransformStack = [];
|
|
7886
7756
|
this.groupLevel = 0;
|
|
@@ -8581,6 +8451,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8581
8451
|
endPath(path) {
|
|
8582
8452
|
this.consumePath(path);
|
|
8583
8453
|
}
|
|
8454
|
+
rawFillPath(path) {
|
|
8455
|
+
this.ctx.fill(path);
|
|
8456
|
+
}
|
|
8584
8457
|
// Clipping
|
|
8585
8458
|
clip() {
|
|
8586
8459
|
this.pendingClip = NORMAL_CLIP;
|
|
@@ -8599,7 +8472,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8599
8472
|
const paths = this.pendingTextPaths;
|
|
8600
8473
|
const ctx = this.ctx;
|
|
8601
8474
|
if (paths === void 0) {
|
|
8602
|
-
ctx.beginPath();
|
|
8603
8475
|
return;
|
|
8604
8476
|
}
|
|
8605
8477
|
const newPath = new SvgPath2D();
|
|
@@ -8611,7 +8483,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8611
8483
|
);
|
|
8612
8484
|
}
|
|
8613
8485
|
ctx.clip(newPath);
|
|
8614
|
-
ctx.beginPath();
|
|
8615
8486
|
delete this.pendingTextPaths;
|
|
8616
8487
|
}
|
|
8617
8488
|
setCharSpacing(spacing) {
|
|
@@ -8730,8 +8601,8 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8730
8601
|
[a, b, c, d, 0, 0],
|
|
8731
8602
|
invPatternTransform
|
|
8732
8603
|
);
|
|
8733
|
-
|
|
8734
|
-
ctx.lineWidth *= Math.max(
|
|
8604
|
+
Util.singularValueDecompose2dScale(transf, XY);
|
|
8605
|
+
ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
|
|
8735
8606
|
ctx.stroke(
|
|
8736
8607
|
__privateMethod(this, _CanvasGraphics_instances, getScaledPath_fn).call(this, path, currentTransform, patternStrokeTransform)
|
|
8737
8608
|
);
|
|
@@ -8972,27 +8843,27 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8972
8843
|
if (!operatorList) {
|
|
8973
8844
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
|
8974
8845
|
} else if (this.contentVisible) {
|
|
8975
|
-
this.processingType3 = glyph;
|
|
8976
8846
|
this.save();
|
|
8977
8847
|
ctx.scale(fontSize, fontSize);
|
|
8978
8848
|
ctx.transform(...fontMatrix);
|
|
8979
8849
|
this.executeOperatorList(operatorList);
|
|
8980
8850
|
this.restore();
|
|
8981
8851
|
}
|
|
8982
|
-
const
|
|
8983
|
-
|
|
8852
|
+
const p = [glyph.width, 0];
|
|
8853
|
+
Util.applyTransform(p, fontMatrix);
|
|
8854
|
+
width = p[0] * fontSize + spacing;
|
|
8984
8855
|
ctx.translate(width, 0);
|
|
8985
8856
|
current.x += width * textHScale;
|
|
8986
8857
|
}
|
|
8987
8858
|
ctx.restore();
|
|
8988
|
-
this.processingType3 = null;
|
|
8989
8859
|
}
|
|
8990
8860
|
// Type3 fonts
|
|
8991
8861
|
setCharWidth(xWidth, yWidth) {
|
|
8992
8862
|
}
|
|
8993
8863
|
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
8994
|
-
|
|
8995
|
-
|
|
8864
|
+
const clip = new SvgPath2D();
|
|
8865
|
+
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
8866
|
+
this.ctx.clip(clip);
|
|
8996
8867
|
this.endPath();
|
|
8997
8868
|
}
|
|
8998
8869
|
// Color
|
|
@@ -9110,11 +8981,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9110
8981
|
}
|
|
9111
8982
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
9112
8983
|
if (bbox) {
|
|
9113
|
-
const width = bbox[2] - bbox[0];
|
|
9114
|
-
const height = bbox[3] - bbox[1];
|
|
9115
|
-
this.ctx.rect(bbox[0], bbox[1], width, height);
|
|
9116
8984
|
this.current.updateRectMinMax(getCurrentTransform(this.ctx), bbox);
|
|
9117
|
-
|
|
8985
|
+
const [x0, y0, x1, y1] = bbox;
|
|
8986
|
+
const clip = new SvgPath2D();
|
|
8987
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
8988
|
+
this.ctx.clip(clip);
|
|
9118
8989
|
this.endPath();
|
|
9119
8990
|
}
|
|
9120
8991
|
}
|
|
@@ -9258,9 +9129,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9258
9129
|
rect[0] = rect[1] = 0;
|
|
9259
9130
|
rect[2] = width;
|
|
9260
9131
|
rect[3] = height;
|
|
9261
|
-
|
|
9262
|
-
getCurrentTransform(this.ctx)
|
|
9263
|
-
);
|
|
9132
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);
|
|
9264
9133
|
const { viewportScale } = this;
|
|
9265
9134
|
const canvasWidth = Math.ceil(
|
|
9266
9135
|
width * this.outputScaleX * viewportScale
|
|
@@ -9277,14 +9146,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9277
9146
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
9278
9147
|
this.ctx = context;
|
|
9279
9148
|
this.ctx.save();
|
|
9280
|
-
this.ctx.setTransform(
|
|
9149
|
+
this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);
|
|
9281
9150
|
resetCtxToDefault(this.ctx);
|
|
9282
9151
|
} else {
|
|
9283
9152
|
resetCtxToDefault(this.ctx);
|
|
9284
9153
|
this.endPath();
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
this.ctx.
|
|
9154
|
+
const clip = new SvgPath2D();
|
|
9155
|
+
clip.rect(rect[0], rect[1], width, height);
|
|
9156
|
+
this.ctx.clip(clip);
|
|
9288
9157
|
}
|
|
9289
9158
|
}
|
|
9290
9159
|
this.current = new CanvasExtraState(
|
|
@@ -9311,16 +9180,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9311
9180
|
img = this.getObject(img.data, img);
|
|
9312
9181
|
img.count = count;
|
|
9313
9182
|
const ctx = this.ctx;
|
|
9314
|
-
const glyph = this.processingType3;
|
|
9315
|
-
if (glyph) {
|
|
9316
|
-
if (glyph.compiled === void 0) {
|
|
9317
|
-
glyph.compiled = compileType3Glyph(img);
|
|
9318
|
-
}
|
|
9319
|
-
if (glyph.compiled) {
|
|
9320
|
-
ctx.fill(glyph.compiled);
|
|
9321
|
-
return;
|
|
9322
|
-
}
|
|
9323
|
-
}
|
|
9324
9183
|
const mask = this._createMaskCanvas(img);
|
|
9325
9184
|
const maskCanvas = mask.canvas;
|
|
9326
9185
|
ctx.save();
|
|
@@ -9356,8 +9215,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9356
9215
|
positions[i],
|
|
9357
9216
|
positions[i + 1]
|
|
9358
9217
|
]);
|
|
9359
|
-
|
|
9360
|
-
ctx.drawImage(mask.canvas, x, y);
|
|
9218
|
+
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
9361
9219
|
}
|
|
9362
9220
|
ctx.restore();
|
|
9363
9221
|
this.compose();
|
|
@@ -9614,7 +9472,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
9614
9472
|
this.pendingClip = null;
|
|
9615
9473
|
}
|
|
9616
9474
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
9617
|
-
ctx.beginPath();
|
|
9618
9475
|
}
|
|
9619
9476
|
getSinglePixelWidth() {
|
|
9620
9477
|
if (!this._cachedGetSinglePixelWidth) {
|
|
@@ -25596,8 +25453,25 @@ var SvgCanvasContext = class {
|
|
|
25596
25453
|
);
|
|
25597
25454
|
this._currentPosition = { x: endX, y: endY };
|
|
25598
25455
|
}
|
|
25599
|
-
stroke() {
|
|
25600
|
-
if (
|
|
25456
|
+
stroke(path) {
|
|
25457
|
+
if (path instanceof SvgPath2D) {
|
|
25458
|
+
const d = toCommands(path);
|
|
25459
|
+
if (d && d !== "Z") {
|
|
25460
|
+
const parent = this._currentGroup;
|
|
25461
|
+
const pathElement = {
|
|
25462
|
+
tag: "path",
|
|
25463
|
+
attrs: {
|
|
25464
|
+
d,
|
|
25465
|
+
fill: "none",
|
|
25466
|
+
stroke: "none",
|
|
25467
|
+
"stroke-width": "0"
|
|
25468
|
+
}
|
|
25469
|
+
};
|
|
25470
|
+
this._applyTransformation(pathElement);
|
|
25471
|
+
this._applyStyle(pathElement, "stroke");
|
|
25472
|
+
parent.children.push(pathElement);
|
|
25473
|
+
}
|
|
25474
|
+
} else if (this._currentElement) {
|
|
25601
25475
|
this._applyStyle(this._currentElement, "stroke");
|
|
25602
25476
|
}
|
|
25603
25477
|
}
|
|
@@ -25908,7 +25782,6 @@ var SvgCanvasContext = class {
|
|
|
25908
25782
|
}
|
|
25909
25783
|
} else {
|
|
25910
25784
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25911
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25912
25785
|
if (strokeStyle instanceof SvgPattern) {
|
|
25913
25786
|
const path = transformPath(commands, transform);
|
|
25914
25787
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25939,9 +25812,7 @@ var SvgCanvasContext = class {
|
|
|
25939
25812
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25940
25813
|
}
|
|
25941
25814
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25942
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25943
|
-
} else {
|
|
25944
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25815
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25945
25816
|
}
|
|
25946
25817
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25947
25818
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|