@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
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) {
|
|
@@ -24910,12 +24767,13 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24910
24767
|
} else {
|
|
24911
24768
|
let firstStroke = true;
|
|
24912
24769
|
let firstFill = true;
|
|
24770
|
+
let firstText = true;
|
|
24913
24771
|
let currentFillColor = null;
|
|
24914
24772
|
let currentLineWidth = null;
|
|
24915
24773
|
for (const { fn, args } of opList) {
|
|
24916
24774
|
const finalFn = fn === OPS.constructPath ? args[0] : fn;
|
|
24917
24775
|
if (finalFn === OPS.fill) {
|
|
24918
|
-
if (currentFillColor) {
|
|
24776
|
+
if (currentFillColor && firstFill) {
|
|
24919
24777
|
annotation.interiorColor = currentFillColor;
|
|
24920
24778
|
currentFillColor = null;
|
|
24921
24779
|
}
|
|
@@ -24927,7 +24785,7 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24927
24785
|
continue;
|
|
24928
24786
|
}
|
|
24929
24787
|
if (finalFn === OPS.stroke || finalFn === OPS.closeStroke) {
|
|
24930
|
-
if (currentLineWidth === null) {
|
|
24788
|
+
if (currentLineWidth === null && firstStroke) {
|
|
24931
24789
|
annotation.borderStyle.width = 1;
|
|
24932
24790
|
}
|
|
24933
24791
|
firstStroke = false;
|
|
@@ -24935,11 +24793,11 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24935
24793
|
continue;
|
|
24936
24794
|
}
|
|
24937
24795
|
if (finalFn === OPS.fillStroke || finalFn === OPS.closeFillStroke) {
|
|
24938
|
-
if (currentFillColor) {
|
|
24796
|
+
if (currentFillColor && firstFill) {
|
|
24939
24797
|
annotation.interiorColor = currentFillColor;
|
|
24940
24798
|
currentFillColor = null;
|
|
24941
24799
|
}
|
|
24942
|
-
if (currentLineWidth === null) {
|
|
24800
|
+
if (currentLineWidth === null && firstStroke) {
|
|
24943
24801
|
annotation.borderStyle.width = 1;
|
|
24944
24802
|
}
|
|
24945
24803
|
firstStroke = false;
|
|
@@ -24972,6 +24830,16 @@ PDFPageProxy.prototype.getAnnotations = async function(params) {
|
|
|
24972
24830
|
}
|
|
24973
24831
|
}
|
|
24974
24832
|
}
|
|
24833
|
+
if (fn === OPS.setFont && firstText) {
|
|
24834
|
+
const fontName = args[0];
|
|
24835
|
+
const font = fontName.startsWith("g_") ? this.commonObjs.get(fontName) : this.objs.get(fontName);
|
|
24836
|
+
if (font) {
|
|
24837
|
+
annotation.defaultAppearanceData.fontName = font.fallbackName;
|
|
24838
|
+
}
|
|
24839
|
+
}
|
|
24840
|
+
if (fn === OPS.endText) {
|
|
24841
|
+
firstText = false;
|
|
24842
|
+
}
|
|
24975
24843
|
}
|
|
24976
24844
|
}
|
|
24977
24845
|
}
|
|
@@ -25596,8 +25464,25 @@ var SvgCanvasContext = class {
|
|
|
25596
25464
|
);
|
|
25597
25465
|
this._currentPosition = { x: endX, y: endY };
|
|
25598
25466
|
}
|
|
25599
|
-
stroke() {
|
|
25600
|
-
if (
|
|
25467
|
+
stroke(path) {
|
|
25468
|
+
if (path instanceof SvgPath2D) {
|
|
25469
|
+
const d = toCommands(path);
|
|
25470
|
+
if (d && d !== "Z") {
|
|
25471
|
+
const parent = this._currentGroup;
|
|
25472
|
+
const pathElement = {
|
|
25473
|
+
tag: "path",
|
|
25474
|
+
attrs: {
|
|
25475
|
+
d,
|
|
25476
|
+
fill: "none",
|
|
25477
|
+
stroke: "none",
|
|
25478
|
+
"stroke-width": "0"
|
|
25479
|
+
}
|
|
25480
|
+
};
|
|
25481
|
+
this._applyTransformation(pathElement);
|
|
25482
|
+
this._applyStyle(pathElement, "stroke");
|
|
25483
|
+
parent.children.push(pathElement);
|
|
25484
|
+
}
|
|
25485
|
+
} else if (this._currentElement) {
|
|
25601
25486
|
this._applyStyle(this._currentElement, "stroke");
|
|
25602
25487
|
}
|
|
25603
25488
|
}
|
|
@@ -25908,7 +25793,6 @@ var SvgCanvasContext = class {
|
|
|
25908
25793
|
}
|
|
25909
25794
|
} else {
|
|
25910
25795
|
const strokeStyle = this._currentStyle.strokeStyle;
|
|
25911
|
-
const lineWidth = this._currentStyle.lineWidth * Math.max(scale.x, scale.y);
|
|
25912
25796
|
if (strokeStyle instanceof SvgPattern) {
|
|
25913
25797
|
const path = transformPath(commands, transform);
|
|
25914
25798
|
const bbox = calculateBoundingBox(path);
|
|
@@ -25939,9 +25823,7 @@ var SvgCanvasContext = class {
|
|
|
25939
25823
|
currentElement.attrs["stroke-miterlimit"] = `${this._currentStyle.miterLimit}`;
|
|
25940
25824
|
}
|
|
25941
25825
|
if (this._currentStyle.lineWidth !== 1) {
|
|
25942
|
-
currentElement.attrs["stroke-width"] = `${lineWidth}`;
|
|
25943
|
-
} else {
|
|
25944
|
-
currentElement.attrs["vector-effect"] = "non-scaling-stroke";
|
|
25826
|
+
currentElement.attrs["stroke-width"] = `${this._currentStyle.lineWidth}`;
|
|
25945
25827
|
}
|
|
25946
25828
|
if (this._currentStyle.lineDash.length > 0) {
|
|
25947
25829
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|