@chialab/pdfjs-lib 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +96 -214
- 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 +96 -214
- 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
|
@@ -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/browser/index.js
CHANGED
|
@@ -46,7 +46,7 @@ import {
|
|
|
46
46
|
unreachable,
|
|
47
47
|
warn,
|
|
48
48
|
wrapReason
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-LJIJQE3F.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 {
|
|
@@ -6377,15 +6383,17 @@ var MeshShadingPattern = class extends BaseShadingPattern {
|
|
|
6377
6383
|
}
|
|
6378
6384
|
getPattern(ctx, owner, inverse, pathType) {
|
|
6379
6385
|
applyBoundingBox(ctx, this._bbox);
|
|
6380
|
-
|
|
6386
|
+
const scale = new Float32Array(2);
|
|
6381
6387
|
if (pathType === PathType.SHADING) {
|
|
6382
|
-
|
|
6388
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(ctx), scale);
|
|
6389
|
+
} else if (this.matrix) {
|
|
6390
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
6391
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
6392
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
6393
|
+
scale[0] *= matrixScaleX;
|
|
6394
|
+
scale[1] *= matrixScaleY;
|
|
6383
6395
|
} else {
|
|
6384
|
-
|
|
6385
|
-
if (this.matrix) {
|
|
6386
|
-
const matrixScale = Util.singularValueDecompose2dScale(this.matrix);
|
|
6387
|
-
scale = [scale[0] * matrixScale[0], scale[1] * matrixScale[1]];
|
|
6388
|
-
}
|
|
6396
|
+
Util.singularValueDecompose2dScale(owner.baseTransform, scale);
|
|
6389
6397
|
}
|
|
6390
6398
|
const temporaryPatternCanvas = this._createMeshCanvas(
|
|
6391
6399
|
scale,
|
|
@@ -6456,12 +6464,12 @@ var _TilingPattern = class _TilingPattern {
|
|
|
6456
6464
|
const x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
|
|
6457
6465
|
const width = x1 - x0;
|
|
6458
6466
|
const height = y1 - y0;
|
|
6459
|
-
const
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
);
|
|
6463
|
-
const combinedScaleX =
|
|
6464
|
-
const combinedScaleY =
|
|
6467
|
+
const scale = new Float32Array(2);
|
|
6468
|
+
Util.singularValueDecompose2dScale(this.matrix, scale);
|
|
6469
|
+
const [matrixScaleX, matrixScaleY] = scale;
|
|
6470
|
+
Util.singularValueDecompose2dScale(this.baseTransform, scale);
|
|
6471
|
+
const combinedScaleX = matrixScaleX * scale[0];
|
|
6472
|
+
const combinedScaleY = matrixScaleY * scale[1];
|
|
6465
6473
|
let canvasWidth = width, canvasHeight = height, redrawHorizontally = false, redrawVertically = false;
|
|
6466
6474
|
const xScaledStep = Math.ceil(xstep * combinedScaleX);
|
|
6467
6475
|
const yScaledStep = Math.ceil(ystep * combinedScaleY);
|
|
@@ -6642,9 +6650,9 @@ var MIN_FONT_SIZE = 16;
|
|
|
6642
6650
|
var MAX_FONT_SIZE = 100;
|
|
6643
6651
|
var EXECUTION_TIME = 15;
|
|
6644
6652
|
var EXECUTION_STEPS = 10;
|
|
6645
|
-
var MAX_SIZE_TO_COMPILE = 1e3;
|
|
6646
6653
|
var FULL_CHUNK_HEIGHT = 16;
|
|
6647
6654
|
var SCALE_MATRIX = new DOMMatrix();
|
|
6655
|
+
var XY = new Float32Array(2);
|
|
6648
6656
|
function mirrorContextOperations(ctx, destCtx) {
|
|
6649
6657
|
if (ctx._removeMirroring) {
|
|
6650
6658
|
throw new Error("Context is already forwarding operations.");
|
|
@@ -6805,145 +6813,6 @@ function drawImageAtIntegerCoords(ctx, srcImg, srcX, srcY, srcW, srcH, destX, de
|
|
|
6805
6813
|
const scaleY = Math.hypot(c, d);
|
|
6806
6814
|
return [scaleX * destW, scaleY * destH];
|
|
6807
6815
|
}
|
|
6808
|
-
function compileType3Glyph(imgData) {
|
|
6809
|
-
const { width, height } = imgData;
|
|
6810
|
-
if (width > MAX_SIZE_TO_COMPILE || height > MAX_SIZE_TO_COMPILE) {
|
|
6811
|
-
return null;
|
|
6812
|
-
}
|
|
6813
|
-
const POINT_TO_PROCESS_LIMIT = 1e3;
|
|
6814
|
-
const POINT_TYPES = new Uint8Array([
|
|
6815
|
-
0,
|
|
6816
|
-
2,
|
|
6817
|
-
4,
|
|
6818
|
-
0,
|
|
6819
|
-
1,
|
|
6820
|
-
0,
|
|
6821
|
-
5,
|
|
6822
|
-
4,
|
|
6823
|
-
8,
|
|
6824
|
-
10,
|
|
6825
|
-
0,
|
|
6826
|
-
8,
|
|
6827
|
-
0,
|
|
6828
|
-
2,
|
|
6829
|
-
1,
|
|
6830
|
-
0
|
|
6831
|
-
]);
|
|
6832
|
-
const width1 = width + 1;
|
|
6833
|
-
const points = new Uint8Array(width1 * (height + 1));
|
|
6834
|
-
let i, j, j0;
|
|
6835
|
-
const lineSize = width + 7 & ~7;
|
|
6836
|
-
const data = new Uint8Array(lineSize * height);
|
|
6837
|
-
let pos = 0;
|
|
6838
|
-
for (const elem of imgData.data) {
|
|
6839
|
-
let mask = 128;
|
|
6840
|
-
while (mask > 0) {
|
|
6841
|
-
data[pos++] = elem & mask ? 0 : 255;
|
|
6842
|
-
mask >>= 1;
|
|
6843
|
-
}
|
|
6844
|
-
}
|
|
6845
|
-
let count = 0;
|
|
6846
|
-
pos = 0;
|
|
6847
|
-
if (data[pos] !== 0) {
|
|
6848
|
-
points[0] = 1;
|
|
6849
|
-
++count;
|
|
6850
|
-
}
|
|
6851
|
-
for (j = 1; j < width; j++) {
|
|
6852
|
-
if (data[pos] !== data[pos + 1]) {
|
|
6853
|
-
points[j] = data[pos] ? 2 : 1;
|
|
6854
|
-
++count;
|
|
6855
|
-
}
|
|
6856
|
-
pos++;
|
|
6857
|
-
}
|
|
6858
|
-
if (data[pos] !== 0) {
|
|
6859
|
-
points[j] = 2;
|
|
6860
|
-
++count;
|
|
6861
|
-
}
|
|
6862
|
-
for (i = 1; i < height; i++) {
|
|
6863
|
-
pos = i * lineSize;
|
|
6864
|
-
j0 = i * width1;
|
|
6865
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
6866
|
-
points[j0] = data[pos] ? 1 : 8;
|
|
6867
|
-
++count;
|
|
6868
|
-
}
|
|
6869
|
-
let sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
|
|
6870
|
-
for (j = 1; j < width; j++) {
|
|
6871
|
-
sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
|
|
6872
|
-
if (POINT_TYPES[sum]) {
|
|
6873
|
-
points[j0 + j] = POINT_TYPES[sum];
|
|
6874
|
-
++count;
|
|
6875
|
-
}
|
|
6876
|
-
pos++;
|
|
6877
|
-
}
|
|
6878
|
-
if (data[pos - lineSize] !== data[pos]) {
|
|
6879
|
-
points[j0 + j] = data[pos] ? 2 : 4;
|
|
6880
|
-
++count;
|
|
6881
|
-
}
|
|
6882
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
6883
|
-
return null;
|
|
6884
|
-
}
|
|
6885
|
-
}
|
|
6886
|
-
pos = lineSize * (height - 1);
|
|
6887
|
-
j0 = i * width1;
|
|
6888
|
-
if (data[pos] !== 0) {
|
|
6889
|
-
points[j0] = 8;
|
|
6890
|
-
++count;
|
|
6891
|
-
}
|
|
6892
|
-
for (j = 1; j < width; j++) {
|
|
6893
|
-
if (data[pos] !== data[pos + 1]) {
|
|
6894
|
-
points[j0 + j] = data[pos] ? 4 : 8;
|
|
6895
|
-
++count;
|
|
6896
|
-
}
|
|
6897
|
-
pos++;
|
|
6898
|
-
}
|
|
6899
|
-
if (data[pos] !== 0) {
|
|
6900
|
-
points[j0 + j] = 4;
|
|
6901
|
-
++count;
|
|
6902
|
-
}
|
|
6903
|
-
if (count > POINT_TO_PROCESS_LIMIT) {
|
|
6904
|
-
return null;
|
|
6905
|
-
}
|
|
6906
|
-
const steps = new Int32Array([0, width1, -1, 0, -width1, 0, 0, 0, 1]);
|
|
6907
|
-
const path = new SvgPath2D();
|
|
6908
|
-
const { a, b, c, d, e, f } = new DOMMatrix().scaleSelf(1 / width, -1 / height).translateSelf(0, -height);
|
|
6909
|
-
for (i = 0; count && i <= height; i++) {
|
|
6910
|
-
let p = i * width1;
|
|
6911
|
-
const end = p + width;
|
|
6912
|
-
while (p < end && !points[p]) {
|
|
6913
|
-
p++;
|
|
6914
|
-
}
|
|
6915
|
-
if (p === end) {
|
|
6916
|
-
continue;
|
|
6917
|
-
}
|
|
6918
|
-
let x = p % width1;
|
|
6919
|
-
let y = i;
|
|
6920
|
-
path.moveTo(a * x + c * y + e, b * x + d * y + f);
|
|
6921
|
-
const p0 = p;
|
|
6922
|
-
let type = points[p];
|
|
6923
|
-
do {
|
|
6924
|
-
const step = steps[type];
|
|
6925
|
-
do {
|
|
6926
|
-
p += step;
|
|
6927
|
-
} while (!points[p]);
|
|
6928
|
-
const pp = points[p];
|
|
6929
|
-
if (pp !== 5 && pp !== 10) {
|
|
6930
|
-
type = pp;
|
|
6931
|
-
points[p] = 0;
|
|
6932
|
-
} else {
|
|
6933
|
-
type = pp & 51 * type >> 4;
|
|
6934
|
-
points[p] &= type >> 2 | type << 2;
|
|
6935
|
-
}
|
|
6936
|
-
x = p % width1;
|
|
6937
|
-
y = p / width1 | 0;
|
|
6938
|
-
path.lineTo(a * x + c * y + e, b * x + d * y + f);
|
|
6939
|
-
if (!points[p]) {
|
|
6940
|
-
--count;
|
|
6941
|
-
}
|
|
6942
|
-
} while (p0 !== p);
|
|
6943
|
-
--i;
|
|
6944
|
-
}
|
|
6945
|
-
return path;
|
|
6946
|
-
}
|
|
6947
6816
|
var CanvasExtraState = class {
|
|
6948
6817
|
constructor(width, height) {
|
|
6949
6818
|
this.alphaIsShape = false;
|
|
@@ -6979,10 +6848,14 @@ var CanvasExtraState = class {
|
|
|
6979
6848
|
return clone;
|
|
6980
6849
|
}
|
|
6981
6850
|
updateRectMinMax(transform, rect) {
|
|
6982
|
-
const p1 =
|
|
6983
|
-
|
|
6984
|
-
const
|
|
6985
|
-
|
|
6851
|
+
const p1 = [rect[0], rect[1]];
|
|
6852
|
+
Util.applyTransform(p1, transform);
|
|
6853
|
+
const p2 = [rect[2], rect[3]];
|
|
6854
|
+
Util.applyTransform(p2, transform);
|
|
6855
|
+
const p3 = [rect[0], rect[3]];
|
|
6856
|
+
Util.applyTransform(p3, transform);
|
|
6857
|
+
const p4 = [rect[2], rect[1]];
|
|
6858
|
+
Util.applyTransform(p4, transform);
|
|
6986
6859
|
this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]);
|
|
6987
6860
|
this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]);
|
|
6988
6861
|
this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]);
|
|
@@ -6994,9 +6867,9 @@ var CanvasExtraState = class {
|
|
|
6994
6867
|
if (!transform) {
|
|
6995
6868
|
unreachable("Stroke bounding box must include transform.");
|
|
6996
6869
|
}
|
|
6997
|
-
|
|
6998
|
-
const xStrokePad =
|
|
6999
|
-
const yStrokePad =
|
|
6870
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
6871
|
+
const xStrokePad = XY[0] * this.lineWidth / 2;
|
|
6872
|
+
const yStrokePad = XY[1] * this.lineWidth / 2;
|
|
7000
6873
|
box[0] -= xStrokePad;
|
|
7001
6874
|
box[1] -= yStrokePad;
|
|
7002
6875
|
box[2] += xStrokePad;
|
|
@@ -7191,13 +7064,11 @@ function getImageSmoothingEnabled(transform, interpolate) {
|
|
|
7191
7064
|
if (interpolate) {
|
|
7192
7065
|
return true;
|
|
7193
7066
|
}
|
|
7194
|
-
|
|
7195
|
-
scale[0] = Math.fround(scale[0]);
|
|
7196
|
-
scale[1] = Math.fround(scale[1]);
|
|
7067
|
+
Util.singularValueDecompose2dScale(transform, XY);
|
|
7197
7068
|
const actualScale = Math.fround(
|
|
7198
7069
|
OutputScale.pixelRatio * PixelsPerInch.PDF_TO_CSS_UNITS
|
|
7199
7070
|
);
|
|
7200
|
-
return
|
|
7071
|
+
return XY[0] <= actualScale && XY[1] <= actualScale;
|
|
7201
7072
|
}
|
|
7202
7073
|
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
|
7203
7074
|
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
|
@@ -7222,7 +7093,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7222
7093
|
this.canvasFactory = canvasFactory;
|
|
7223
7094
|
this.filterFactory = filterFactory;
|
|
7224
7095
|
this.groupStack = [];
|
|
7225
|
-
this.processingType3 = null;
|
|
7226
7096
|
this.baseTransform = null;
|
|
7227
7097
|
this.baseTransformStack = [];
|
|
7228
7098
|
this.groupLevel = 0;
|
|
@@ -7923,6 +7793,9 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7923
7793
|
endPath(path) {
|
|
7924
7794
|
this.consumePath(path);
|
|
7925
7795
|
}
|
|
7796
|
+
rawFillPath(path) {
|
|
7797
|
+
this.ctx.fill(path);
|
|
7798
|
+
}
|
|
7926
7799
|
// Clipping
|
|
7927
7800
|
clip() {
|
|
7928
7801
|
this.pendingClip = NORMAL_CLIP;
|
|
@@ -7941,7 +7814,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7941
7814
|
const paths = this.pendingTextPaths;
|
|
7942
7815
|
const ctx = this.ctx;
|
|
7943
7816
|
if (paths === void 0) {
|
|
7944
|
-
ctx.beginPath();
|
|
7945
7817
|
return;
|
|
7946
7818
|
}
|
|
7947
7819
|
const newPath = new SvgPath2D();
|
|
@@ -7953,7 +7825,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
7953
7825
|
);
|
|
7954
7826
|
}
|
|
7955
7827
|
ctx.clip(newPath);
|
|
7956
|
-
ctx.beginPath();
|
|
7957
7828
|
delete this.pendingTextPaths;
|
|
7958
7829
|
}
|
|
7959
7830
|
setCharSpacing(spacing) {
|
|
@@ -8072,8 +7943,8 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8072
7943
|
[a, b, c, d, 0, 0],
|
|
8073
7944
|
invPatternTransform
|
|
8074
7945
|
);
|
|
8075
|
-
|
|
8076
|
-
ctx.lineWidth *= Math.max(
|
|
7946
|
+
Util.singularValueDecompose2dScale(transf, XY);
|
|
7947
|
+
ctx.lineWidth *= Math.max(XY[0], XY[1]) / fontSize;
|
|
8077
7948
|
ctx.stroke(
|
|
8078
7949
|
__privateMethod(this, _CanvasGraphics_instances, getScaledPath_fn).call(this, path, currentTransform, patternStrokeTransform)
|
|
8079
7950
|
);
|
|
@@ -8314,27 +8185,27 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8314
8185
|
if (!operatorList) {
|
|
8315
8186
|
warn(`Type3 character "${glyph.operatorListId}" is not available.`);
|
|
8316
8187
|
} else if (this.contentVisible) {
|
|
8317
|
-
this.processingType3 = glyph;
|
|
8318
8188
|
this.save();
|
|
8319
8189
|
ctx.scale(fontSize, fontSize);
|
|
8320
8190
|
ctx.transform(...fontMatrix);
|
|
8321
8191
|
this.executeOperatorList(operatorList);
|
|
8322
8192
|
this.restore();
|
|
8323
8193
|
}
|
|
8324
|
-
const
|
|
8325
|
-
|
|
8194
|
+
const p = [glyph.width, 0];
|
|
8195
|
+
Util.applyTransform(p, fontMatrix);
|
|
8196
|
+
width = p[0] * fontSize + spacing;
|
|
8326
8197
|
ctx.translate(width, 0);
|
|
8327
8198
|
current.x += width * textHScale;
|
|
8328
8199
|
}
|
|
8329
8200
|
ctx.restore();
|
|
8330
|
-
this.processingType3 = null;
|
|
8331
8201
|
}
|
|
8332
8202
|
// Type3 fonts
|
|
8333
8203
|
setCharWidth(xWidth, yWidth) {
|
|
8334
8204
|
}
|
|
8335
8205
|
setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
|
|
8336
|
-
|
|
8337
|
-
|
|
8206
|
+
const clip = new SvgPath2D();
|
|
8207
|
+
clip.rect(llx, lly, urx - llx, ury - lly);
|
|
8208
|
+
this.ctx.clip(clip);
|
|
8338
8209
|
this.endPath();
|
|
8339
8210
|
}
|
|
8340
8211
|
// Color
|
|
@@ -8452,11 +8323,11 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8452
8323
|
}
|
|
8453
8324
|
this.baseTransform = getCurrentTransform(this.ctx);
|
|
8454
8325
|
if (bbox) {
|
|
8455
|
-
const width = bbox[2] - bbox[0];
|
|
8456
|
-
const height = bbox[3] - bbox[1];
|
|
8457
|
-
this.ctx.rect(bbox[0], bbox[1], width, height);
|
|
8458
8326
|
this.current.updateRectMinMax(getCurrentTransform(this.ctx), bbox);
|
|
8459
|
-
|
|
8327
|
+
const [x0, y0, x1, y1] = bbox;
|
|
8328
|
+
const clip = new SvgPath2D();
|
|
8329
|
+
clip.rect(x0, y0, x1 - x0, y1 - y0);
|
|
8330
|
+
this.ctx.clip(clip);
|
|
8460
8331
|
this.endPath();
|
|
8461
8332
|
}
|
|
8462
8333
|
}
|
|
@@ -8600,9 +8471,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8600
8471
|
rect[0] = rect[1] = 0;
|
|
8601
8472
|
rect[2] = width;
|
|
8602
8473
|
rect[3] = height;
|
|
8603
|
-
|
|
8604
|
-
getCurrentTransform(this.ctx)
|
|
8605
|
-
);
|
|
8474
|
+
Util.singularValueDecompose2dScale(getCurrentTransform(this.ctx), XY);
|
|
8606
8475
|
const { viewportScale } = this;
|
|
8607
8476
|
const canvasWidth = Math.ceil(
|
|
8608
8477
|
width * this.outputScaleX * viewportScale
|
|
@@ -8619,14 +8488,14 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8619
8488
|
this.annotationCanvas.savedCtx = this.ctx;
|
|
8620
8489
|
this.ctx = context;
|
|
8621
8490
|
this.ctx.save();
|
|
8622
|
-
this.ctx.setTransform(
|
|
8491
|
+
this.ctx.setTransform(XY[0], 0, 0, -XY[1], 0, height * XY[1]);
|
|
8623
8492
|
resetCtxToDefault(this.ctx);
|
|
8624
8493
|
} else {
|
|
8625
8494
|
resetCtxToDefault(this.ctx);
|
|
8626
8495
|
this.endPath();
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
this.ctx.
|
|
8496
|
+
const clip = new SvgPath2D();
|
|
8497
|
+
clip.rect(rect[0], rect[1], width, height);
|
|
8498
|
+
this.ctx.clip(clip);
|
|
8630
8499
|
}
|
|
8631
8500
|
}
|
|
8632
8501
|
this.current = new CanvasExtraState(
|
|
@@ -8653,16 +8522,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8653
8522
|
img = this.getObject(img.data, img);
|
|
8654
8523
|
img.count = count;
|
|
8655
8524
|
const ctx = this.ctx;
|
|
8656
|
-
const glyph = this.processingType3;
|
|
8657
|
-
if (glyph) {
|
|
8658
|
-
if (glyph.compiled === void 0) {
|
|
8659
|
-
glyph.compiled = compileType3Glyph(img);
|
|
8660
|
-
}
|
|
8661
|
-
if (glyph.compiled) {
|
|
8662
|
-
ctx.fill(glyph.compiled);
|
|
8663
|
-
return;
|
|
8664
|
-
}
|
|
8665
|
-
}
|
|
8666
8525
|
const mask = this._createMaskCanvas(img);
|
|
8667
8526
|
const maskCanvas = mask.canvas;
|
|
8668
8527
|
ctx.save();
|
|
@@ -8698,8 +8557,7 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8698
8557
|
positions[i],
|
|
8699
8558
|
positions[i + 1]
|
|
8700
8559
|
]);
|
|
8701
|
-
|
|
8702
|
-
ctx.drawImage(mask.canvas, x, y);
|
|
8560
|
+
ctx.drawImage(mask.canvas, trans[4], trans[5]);
|
|
8703
8561
|
}
|
|
8704
8562
|
ctx.restore();
|
|
8705
8563
|
this.compose();
|
|
@@ -8956,7 +8814,6 @@ var _CanvasGraphics = class _CanvasGraphics {
|
|
|
8956
8814
|
this.pendingClip = null;
|
|
8957
8815
|
}
|
|
8958
8816
|
this.current.startNewPathAndClipBox(this.current.clipBox);
|
|
8959
|
-
ctx.beginPath();
|
|
8960
8817
|
}
|
|
8961
8818
|
getSinglePixelWidth() {
|
|
8962
8819
|
if (!this._cachedGetSinglePixelWidth) {
|
|
@@ -24600,12 +24457,13 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24600
24457
|
} else {
|
|
24601
24458
|
let firstStroke = true;
|
|
24602
24459
|
let firstFill = true;
|
|
24460
|
+
let firstText = true;
|
|
24603
24461
|
let currentFillColor = null;
|
|
24604
24462
|
let currentLineWidth = null;
|
|
24605
24463
|
for (const { fn, args } of opList) {
|
|
24606
24464
|
const finalFn = fn === OPS.constructPath ? args[0] : fn;
|
|
24607
24465
|
if (finalFn === OPS.fill) {
|
|
24608
|
-
if (currentFillColor) {
|
|
24466
|
+
if (currentFillColor && firstFill) {
|
|
24609
24467
|
annotation.interiorColor = currentFillColor;
|
|
24610
24468
|
currentFillColor = null;
|
|
24611
24469
|
}
|
|
@@ -24617,7 +24475,7 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24617
24475
|
continue;
|
|
24618
24476
|
}
|
|
24619
24477
|
if (finalFn === OPS.stroke || finalFn === OPS.closeStroke) {
|
|
24620
|
-
if (currentLineWidth === null) {
|
|
24478
|
+
if (currentLineWidth === null && firstStroke) {
|
|
24621
24479
|
annotation.borderStyle.width = 1;
|
|
24622
24480
|
}
|
|
24623
24481
|
firstStroke = false;
|
|
@@ -24625,11 +24483,11 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24625
24483
|
continue;
|
|
24626
24484
|
}
|
|
24627
24485
|
if (finalFn === OPS.fillStroke || finalFn === OPS.closeFillStroke) {
|
|
24628
|
-
if (currentFillColor) {
|
|
24486
|
+
if (currentFillColor && firstFill) {
|
|
24629
24487
|
annotation.interiorColor = currentFillColor;
|
|
24630
24488
|
currentFillColor = null;
|
|
24631
24489
|
}
|
|
24632
|
-
if (currentLineWidth === null) {
|
|
24490
|
+
if (currentLineWidth === null && firstStroke) {
|
|
24633
24491
|
annotation.borderStyle.width = 1;
|
|
24634
24492
|
}
|
|
24635
24493
|
firstStroke = false;
|
|
@@ -24662,6 +24520,16 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24662
24520
|
}
|
|
24663
24521
|
}
|
|
24664
24522
|
}
|
|
24523
|
+
if (fn === OPS.setFont && firstText) {
|
|
24524
|
+
const fontName = args[0];
|
|
24525
|
+
const font = fontName.startsWith("g_") ? this.commonObjs.get(fontName) : this.objs.get(fontName);
|
|
24526
|
+
if (font) {
|
|
24527
|
+
annotation.defaultAppearanceData.fontName = font.fallbackName;
|
|
24528
|
+
}
|
|
24529
|
+
}
|
|
24530
|
+
if (fn === OPS.endText) {
|
|
24531
|
+
firstText = false;
|
|
24532
|
+
}
|
|
24665
24533
|
}
|
|
24666
24534
|
}
|
|
24667
24535
|
}
|
|
@@ -25286,8 +25154,25 @@ var SvgCanvasContext = class {
|
|
|
25286
25154
|
);
|
|
25287
25155
|
this._currentPosition = { x: endX, y: endY };
|
|
25288
25156
|
}
|
|
25289
|
-
stroke() {
|
|
25290
|
-
if (
|
|
25157
|
+
stroke(path) {
|
|
25158
|
+
if (path instanceof SvgPath2D) {
|
|
25159
|
+
const d = toCommands(path);
|
|
25160
|
+
if (d && d !== "Z") {
|
|
25161
|
+
const parent = this._currentGroup;
|
|
25162
|
+
const pathElement = {
|
|
25163
|
+
tag: "path",
|
|
25164
|
+
attrs: {
|
|
25165
|
+
d,
|
|
25166
|
+
fill: "none",
|
|
25167
|
+
stroke: "none",
|
|
25168
|
+
"stroke-width": "0"
|
|
25169
|
+
}
|
|
25170
|
+
};
|
|
25171
|
+
this._applyTransformation(pathElement);
|
|
25172
|
+
this._applyStyle(pathElement, "stroke");
|
|
25173
|
+
parent.children.push(pathElement);
|
|
25174
|
+
}
|
|
25175
|
+
} else if (this._currentElement) {
|
|
25291
25176
|
this._applyStyle(this._currentElement, "stroke");
|
|
25292
25177
|
}
|
|
25293
25178
|
}
|
|
@@ -25598,7 +25483,6 @@ var SvgCanvasContext = class {
|
|
|
25598
25483
|
}
|
|
25599
25484
|
} else {
|
|
25600
25485
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25601
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25602
25486
|
if (strokeStyle instanceof SvgPattern) {
|
|
25603
25487
|
const path = transformPath(commands, transform);
|
|
25604
25488
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25629,9 +25513,7 @@ var SvgCanvasContext = class {
|
|
|
25629
25513
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25630
25514
|
}
|
|
25631
25515
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25632
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25633
|
-
} else {
|
|
25634
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25516
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25635
25517
|
}
|
|
25636
25518
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25637
25519
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|