pdfjs-dist 2.5.207 → 2.6.347
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.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/bower.json +1 -1
- package/build/pdf.js +867 -216
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +10214 -8547
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +2023 -1046
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +22 -0
- package/es5/build/pdf.worker.js +11136 -8144
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +8 -5
- package/es5/web/pdf_viewer.js +195 -51
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +24 -16
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +479 -43
- package/lib/core/cff_parser.js +643 -615
- package/lib/core/chunked_stream.js +64 -50
- package/lib/core/colorspace.js +126 -104
- package/lib/core/crypto.js +37 -0
- package/lib/core/document.js +128 -75
- package/lib/core/evaluator.js +3015 -2754
- package/lib/core/fonts.js +47 -46
- package/lib/core/function.js +79 -6
- package/lib/core/image.js +364 -357
- package/lib/core/image_utils.js +109 -8
- package/lib/core/jpg.js +8 -3
- package/lib/core/obj.js +255 -34
- package/lib/core/operator_list.js +17 -15
- package/lib/core/parser.js +40 -3
- package/lib/core/pattern.js +24 -11
- package/lib/core/primitives.js +112 -53
- package/lib/core/type1_parser.js +2 -0
- package/lib/core/worker.js +102 -37
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +51 -10
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +140 -54
- package/lib/display/canvas.js +215 -46
- package/lib/display/display_utils.js +55 -18
- package/lib/display/fetch_stream.js +6 -0
- package/lib/display/font_loader.js +26 -15
- package/lib/display/metadata.js +1 -7
- package/lib/display/network.js +0 -14
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/svg.js +1 -1
- package/lib/display/text_layer.js +4 -1
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/util.js +13 -10
- package/lib/test/unit/annotation_spec.js +520 -50
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +16 -6
- package/lib/test/unit/cmap_spec.js +4 -4
- package/lib/test/unit/colorspace_spec.js +216 -24
- package/lib/test/unit/crypto_spec.js +51 -4
- package/lib/test/unit/custom_spec.js +129 -1
- package/lib/test/unit/document_spec.js +112 -1
- package/lib/test/unit/evaluator_spec.js +29 -10
- package/lib/test/unit/jasmine-boot.js +1 -1
- package/lib/test/unit/metadata_spec.js +3 -3
- package/lib/test/unit/primitives_spec.js +242 -63
- package/lib/test/unit/test_utils.js +42 -89
- package/lib/test/unit/testreporter.js +17 -6
- package/lib/test/unit/util_spec.js +13 -12
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +13 -9
- package/lib/web/app.js +231 -26
- package/lib/web/app_options.js +1 -6
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +53 -4
- package/lib/web/download_manager.js +3 -10
- package/lib/web/firefox_print_service.js +32 -12
- package/lib/web/firefoxcom.js +20 -6
- package/lib/web/interfaces.js +1 -1
- package/lib/web/pdf_attachment_viewer.js +80 -38
- package/lib/web/pdf_find_controller.js +2 -1
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_outline_viewer.js +24 -57
- package/lib/web/pdf_page_view.js +29 -6
- package/lib/web/pdf_print_service.js +13 -11
- package/lib/web/pdf_sidebar.js +46 -25
- package/lib/web/pdf_thumbnail_view.js +16 -3
- package/lib/web/pdf_thumbnail_viewer.js +17 -1
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/preferences.js +1 -1
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +7 -1
- package/package.json +3 -1
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +8 -5
- package/web/pdf_viewer.js +109 -33
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -9
- package/es5/web/images/texture.png +0 -0
- package/web/images/texture.png +0 -0
package/lib/display/canvas.js
CHANGED
@@ -373,6 +373,7 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
|
|
373
373
|
this.lineWidth = 1;
|
374
374
|
this.activeSMask = null;
|
375
375
|
this.resumeSMaskCtx = null;
|
376
|
+
this.transferMaps = null;
|
376
377
|
}
|
377
378
|
|
378
379
|
CanvasExtraState.prototype = {
|
@@ -391,7 +392,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
391
392
|
var EXECUTION_TIME = 15;
|
392
393
|
var EXECUTION_STEPS = 10;
|
393
394
|
|
394
|
-
function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
|
395
|
+
function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer, optionalContentConfig) {
|
395
396
|
this.ctx = canvasCtx;
|
396
397
|
this.current = new CanvasExtraState();
|
397
398
|
this.stateStack = [];
|
@@ -412,6 +413,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
412
413
|
this.smaskStack = [];
|
413
414
|
this.smaskCounter = 0;
|
414
415
|
this.tempSMask = null;
|
416
|
+
this.contentVisible = true;
|
417
|
+
this.markedContentStack = [];
|
418
|
+
this.optionalContentConfig = optionalContentConfig;
|
415
419
|
this.cachedCanvases = new CachedCanvases(this.canvasFactory);
|
416
420
|
|
417
421
|
if (canvasCtx) {
|
@@ -421,7 +425,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
421
425
|
this._cachedGetSinglePixelWidth = null;
|
422
426
|
}
|
423
427
|
|
424
|
-
function putBinaryImageData(ctx, imgData) {
|
428
|
+
function putBinaryImageData(ctx, imgData, transferMaps = null) {
|
425
429
|
if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
|
426
430
|
ctx.putImageData(imgData, 0, 0);
|
427
431
|
return;
|
@@ -438,6 +442,25 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
438
442
|
var src = imgData.data;
|
439
443
|
var dest = chunkImgData.data;
|
440
444
|
var i, j, thisChunkHeight, elemsInThisChunk;
|
445
|
+
let transferMapRed, transferMapGreen, transferMapBlue, transferMapGray;
|
446
|
+
|
447
|
+
if (transferMaps) {
|
448
|
+
switch (transferMaps.length) {
|
449
|
+
case 1:
|
450
|
+
transferMapRed = transferMaps[0];
|
451
|
+
transferMapGreen = transferMaps[0];
|
452
|
+
transferMapBlue = transferMaps[0];
|
453
|
+
transferMapGray = transferMaps[0];
|
454
|
+
break;
|
455
|
+
|
456
|
+
case 4:
|
457
|
+
transferMapRed = transferMaps[0];
|
458
|
+
transferMapGreen = transferMaps[1];
|
459
|
+
transferMapBlue = transferMaps[2];
|
460
|
+
transferMapGray = transferMaps[3];
|
461
|
+
break;
|
462
|
+
}
|
463
|
+
}
|
441
464
|
|
442
465
|
if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
|
443
466
|
var srcLength = src.byteLength;
|
@@ -447,13 +470,19 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
447
470
|
var white = 0xffffffff;
|
448
471
|
var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
|
449
472
|
|
473
|
+
if (transferMapGray) {
|
474
|
+
if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
|
475
|
+
[white, black] = [black, white];
|
476
|
+
}
|
477
|
+
}
|
478
|
+
|
450
479
|
for (i = 0; i < totalChunks; i++) {
|
451
480
|
thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
452
481
|
destPos = 0;
|
453
482
|
|
454
483
|
for (j = 0; j < thisChunkHeight; j++) {
|
455
484
|
var srcDiff = srcLength - srcPos;
|
456
|
-
|
485
|
+
let k = 0;
|
457
486
|
var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
|
458
487
|
var kEndUnrolled = kEnd & ~7;
|
459
488
|
var mask = 0;
|
@@ -489,12 +518,30 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
489
518
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
490
519
|
}
|
491
520
|
} else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
|
521
|
+
const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
|
492
522
|
j = 0;
|
493
523
|
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
|
494
524
|
|
495
525
|
for (i = 0; i < fullChunks; i++) {
|
496
526
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
497
527
|
srcPos += elemsInThisChunk;
|
528
|
+
|
529
|
+
if (hasTransferMaps) {
|
530
|
+
for (let k = 0; k < elemsInThisChunk; k += 4) {
|
531
|
+
if (transferMapRed) {
|
532
|
+
dest[k + 0] = transferMapRed[dest[k + 0]];
|
533
|
+
}
|
534
|
+
|
535
|
+
if (transferMapGreen) {
|
536
|
+
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
537
|
+
}
|
538
|
+
|
539
|
+
if (transferMapBlue) {
|
540
|
+
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
541
|
+
}
|
542
|
+
}
|
543
|
+
}
|
544
|
+
|
498
545
|
ctx.putImageData(chunkImgData, 0, j);
|
499
546
|
j += FULL_CHUNK_HEIGHT;
|
500
547
|
}
|
@@ -502,9 +549,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
502
549
|
if (i < totalChunks) {
|
503
550
|
elemsInThisChunk = width * partialChunkHeight * 4;
|
504
551
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
552
|
+
|
553
|
+
if (hasTransferMaps) {
|
554
|
+
for (let k = 0; k < elemsInThisChunk; k += 4) {
|
555
|
+
if (transferMapRed) {
|
556
|
+
dest[k + 0] = transferMapRed[dest[k + 0]];
|
557
|
+
}
|
558
|
+
|
559
|
+
if (transferMapGreen) {
|
560
|
+
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
561
|
+
}
|
562
|
+
|
563
|
+
if (transferMapBlue) {
|
564
|
+
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
565
|
+
}
|
566
|
+
}
|
567
|
+
}
|
568
|
+
|
505
569
|
ctx.putImageData(chunkImgData, 0, j);
|
506
570
|
}
|
507
571
|
} else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
|
572
|
+
const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
|
508
573
|
thisChunkHeight = FULL_CHUNK_HEIGHT;
|
509
574
|
elemsInThisChunk = width * thisChunkHeight;
|
510
575
|
|
@@ -523,6 +588,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
523
588
|
dest[destPos++] = 255;
|
524
589
|
}
|
525
590
|
|
591
|
+
if (hasTransferMaps) {
|
592
|
+
for (let k = 0; k < destPos; k += 4) {
|
593
|
+
if (transferMapRed) {
|
594
|
+
dest[k + 0] = transferMapRed[dest[k + 0]];
|
595
|
+
}
|
596
|
+
|
597
|
+
if (transferMapGreen) {
|
598
|
+
dest[k + 1] = transferMapGreen[dest[k + 1]];
|
599
|
+
}
|
600
|
+
|
601
|
+
if (transferMapBlue) {
|
602
|
+
dest[k + 2] = transferMapBlue[dest[k + 2]];
|
603
|
+
}
|
604
|
+
}
|
605
|
+
}
|
606
|
+
|
526
607
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
527
608
|
}
|
528
609
|
} else {
|
@@ -905,6 +986,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
905
986
|
|
906
987
|
this.tempSMask = null;
|
907
988
|
break;
|
989
|
+
|
990
|
+
case "TR":
|
991
|
+
this.current.transferMaps = value;
|
908
992
|
}
|
909
993
|
}
|
910
994
|
},
|
@@ -1006,22 +1090,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1006
1090
|
var width = args[j++];
|
1007
1091
|
var height = args[j++];
|
1008
1092
|
|
1009
|
-
if (width === 0) {
|
1093
|
+
if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
1010
1094
|
width = this.getSinglePixelWidth();
|
1011
1095
|
}
|
1012
1096
|
|
1013
|
-
if (height === 0) {
|
1097
|
+
if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
1014
1098
|
height = this.getSinglePixelWidth();
|
1015
1099
|
}
|
1016
1100
|
|
1017
1101
|
var xw = x + width;
|
1018
1102
|
var yh = y + height;
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1103
|
+
ctx.moveTo(x, y);
|
1104
|
+
ctx.lineTo(xw, y);
|
1105
|
+
ctx.lineTo(xw, yh);
|
1106
|
+
ctx.lineTo(x, yh);
|
1107
|
+
ctx.lineTo(x, y);
|
1108
|
+
ctx.closePath();
|
1025
1109
|
break;
|
1026
1110
|
|
1027
1111
|
case _util.OPS.moveTo:
|
@@ -1074,19 +1158,21 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1074
1158
|
var strokeColor = this.current.strokeColor;
|
1075
1159
|
ctx.globalAlpha = this.current.strokeAlpha;
|
1076
1160
|
|
1077
|
-
if (
|
1078
|
-
|
1079
|
-
|
1161
|
+
if (this.contentVisible) {
|
1162
|
+
if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
|
1163
|
+
ctx.save();
|
1164
|
+
const transform = ctx.mozCurrentTransform;
|
1080
1165
|
|
1081
|
-
|
1166
|
+
const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
|
1082
1167
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1168
|
+
ctx.strokeStyle = strokeColor.getPattern(ctx, this);
|
1169
|
+
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
|
1170
|
+
ctx.stroke();
|
1171
|
+
ctx.restore();
|
1172
|
+
} else {
|
1173
|
+
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
|
1174
|
+
ctx.stroke();
|
1175
|
+
}
|
1090
1176
|
}
|
1091
1177
|
|
1092
1178
|
if (consumePath) {
|
@@ -1117,11 +1203,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1117
1203
|
needRestore = true;
|
1118
1204
|
}
|
1119
1205
|
|
1120
|
-
if (this.
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1206
|
+
if (this.contentVisible) {
|
1207
|
+
if (this.pendingEOFill) {
|
1208
|
+
ctx.fill("evenodd");
|
1209
|
+
this.pendingEOFill = false;
|
1210
|
+
} else {
|
1211
|
+
ctx.fill();
|
1212
|
+
}
|
1125
1213
|
}
|
1126
1214
|
|
1127
1215
|
if (needRestore) {
|
@@ -1466,15 +1554,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1466
1554
|
}
|
1467
1555
|
}
|
1468
1556
|
|
1469
|
-
if (glyph.isInFont || font.missingFile) {
|
1557
|
+
if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
|
1470
1558
|
if (simpleFillText && !accent) {
|
1471
1559
|
ctx.fillText(character, scaledX, scaledY);
|
1472
1560
|
} else {
|
1473
1561
|
this.paintChar(character, scaledX, scaledY, patternTransform);
|
1474
1562
|
|
1475
1563
|
if (accent) {
|
1476
|
-
scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
|
1477
|
-
scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
|
1564
|
+
scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
|
1565
|
+
scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
|
1478
1566
|
this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
|
1479
1567
|
}
|
1480
1568
|
}
|
@@ -1546,12 +1634,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1546
1634
|
continue;
|
1547
1635
|
}
|
1548
1636
|
|
1549
|
-
this.
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1637
|
+
if (this.contentVisible) {
|
1638
|
+
this.processingType3 = glyph;
|
1639
|
+
this.save();
|
1640
|
+
ctx.scale(fontSize, fontSize);
|
1641
|
+
ctx.transform.apply(ctx, fontMatrix);
|
1642
|
+
this.executeOperatorList(operatorList);
|
1643
|
+
this.restore();
|
1644
|
+
}
|
1555
1645
|
|
1556
1646
|
var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
|
1557
1647
|
|
@@ -1608,6 +1698,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1608
1698
|
this.current.patternFill = false;
|
1609
1699
|
},
|
1610
1700
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
1701
|
+
if (!this.contentVisible) {
|
1702
|
+
return;
|
1703
|
+
}
|
1704
|
+
|
1611
1705
|
var ctx = this.ctx;
|
1612
1706
|
this.save();
|
1613
1707
|
var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
|
@@ -1645,6 +1739,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1645
1739
|
(0, _util.unreachable)("Should not call beginImageData");
|
1646
1740
|
},
|
1647
1741
|
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
|
1742
|
+
if (!this.contentVisible) {
|
1743
|
+
return;
|
1744
|
+
}
|
1745
|
+
|
1648
1746
|
this.save();
|
1649
1747
|
this.baseTransformStack.push(this.baseTransform);
|
1650
1748
|
|
@@ -1663,10 +1761,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1663
1761
|
}
|
1664
1762
|
},
|
1665
1763
|
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
|
1764
|
+
if (!this.contentVisible) {
|
1765
|
+
return;
|
1766
|
+
}
|
1767
|
+
|
1666
1768
|
this.restore();
|
1667
1769
|
this.baseTransform = this.baseTransformStack.pop();
|
1668
1770
|
},
|
1669
1771
|
beginGroup: function CanvasGraphics_beginGroup(group) {
|
1772
|
+
if (!this.contentVisible) {
|
1773
|
+
return;
|
1774
|
+
}
|
1775
|
+
|
1670
1776
|
this.save();
|
1671
1777
|
var currentCtx = this.ctx;
|
1672
1778
|
|
@@ -1748,6 +1854,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1748
1854
|
this.current.activeSMask = null;
|
1749
1855
|
},
|
1750
1856
|
endGroup: function CanvasGraphics_endGroup(group) {
|
1857
|
+
if (!this.contentVisible) {
|
1858
|
+
return;
|
1859
|
+
}
|
1860
|
+
|
1751
1861
|
this.groupLevel--;
|
1752
1862
|
var groupCtx = this.ctx;
|
1753
1863
|
this.ctx = this.groupStack.pop();
|
@@ -1796,6 +1906,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1796
1906
|
this.restore();
|
1797
1907
|
},
|
1798
1908
|
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
1909
|
+
if (!this.contentVisible) {
|
1910
|
+
return;
|
1911
|
+
}
|
1912
|
+
|
1799
1913
|
var ctx = this.ctx;
|
1800
1914
|
var width = img.width,
|
1801
1915
|
height = img.height;
|
@@ -1830,7 +1944,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1830
1944
|
maskCtx.restore();
|
1831
1945
|
this.paintInlineImageXObject(maskCanvas.canvas);
|
1832
1946
|
},
|
1833
|
-
|
1947
|
+
|
1948
|
+
paintImageMaskXObjectRepeat(imgData, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
|
1949
|
+
if (!this.contentVisible) {
|
1950
|
+
return;
|
1951
|
+
}
|
1952
|
+
|
1834
1953
|
var width = imgData.width;
|
1835
1954
|
var height = imgData.height;
|
1836
1955
|
var fillColor = this.current.fillColor;
|
@@ -1847,13 +1966,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1847
1966
|
|
1848
1967
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
1849
1968
|
ctx.save();
|
1850
|
-
ctx.transform(scaleX,
|
1969
|
+
ctx.transform(scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]);
|
1851
1970
|
ctx.scale(1, -1);
|
1852
1971
|
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
1853
1972
|
ctx.restore();
|
1854
1973
|
}
|
1855
1974
|
},
|
1975
|
+
|
1856
1976
|
paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
|
1977
|
+
if (!this.contentVisible) {
|
1978
|
+
return;
|
1979
|
+
}
|
1980
|
+
|
1857
1981
|
var ctx = this.ctx;
|
1858
1982
|
var fillColor = this.current.fillColor;
|
1859
1983
|
var isPatternFill = this.current.patternFill;
|
@@ -1878,6 +2002,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1878
2002
|
}
|
1879
2003
|
},
|
1880
2004
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
2005
|
+
if (!this.contentVisible) {
|
2006
|
+
return;
|
2007
|
+
}
|
2008
|
+
|
1881
2009
|
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1882
2010
|
|
1883
2011
|
if (!imgData) {
|
@@ -1888,6 +2016,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1888
2016
|
this.paintInlineImageXObject(imgData);
|
1889
2017
|
},
|
1890
2018
|
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
|
2019
|
+
if (!this.contentVisible) {
|
2020
|
+
return;
|
2021
|
+
}
|
2022
|
+
|
1891
2023
|
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1892
2024
|
|
1893
2025
|
if (!imgData) {
|
@@ -1912,6 +2044,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1912
2044
|
this.paintInlineImageXObjectGroup(imgData, map);
|
1913
2045
|
},
|
1914
2046
|
paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
|
2047
|
+
if (!this.contentVisible) {
|
2048
|
+
return;
|
2049
|
+
}
|
2050
|
+
|
1915
2051
|
var width = imgData.width;
|
1916
2052
|
var height = imgData.height;
|
1917
2053
|
var ctx = this.ctx;
|
@@ -1931,7 +2067,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1931
2067
|
} else {
|
1932
2068
|
tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
|
1933
2069
|
var tmpCtx = tmpCanvas.context;
|
1934
|
-
putBinaryImageData(tmpCtx, imgData);
|
2070
|
+
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
1935
2071
|
imgToPaint = tmpCanvas.canvas;
|
1936
2072
|
}
|
1937
2073
|
|
@@ -1979,12 +2115,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1979
2115
|
this.restore();
|
1980
2116
|
},
|
1981
2117
|
paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
|
2118
|
+
if (!this.contentVisible) {
|
2119
|
+
return;
|
2120
|
+
}
|
2121
|
+
|
1982
2122
|
var ctx = this.ctx;
|
1983
2123
|
var w = imgData.width;
|
1984
2124
|
var h = imgData.height;
|
1985
2125
|
var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
|
1986
2126
|
var tmpCtx = tmpCanvas.context;
|
1987
|
-
putBinaryImageData(tmpCtx, imgData);
|
2127
|
+
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
1988
2128
|
|
1989
2129
|
for (var i = 0, ii = map.length; i < ii; i++) {
|
1990
2130
|
var entry = map[i];
|
@@ -2008,16 +2148,36 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2008
2148
|
}
|
2009
2149
|
},
|
2010
2150
|
paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
|
2151
|
+
if (!this.contentVisible) {
|
2152
|
+
return;
|
2153
|
+
}
|
2154
|
+
|
2011
2155
|
this.ctx.fillRect(0, 0, 1, 1);
|
2012
2156
|
},
|
2013
|
-
paintXObject: function CanvasGraphics_paintXObject() {
|
2014
|
-
(0, _util.warn)("Unsupported 'paintXObject' command.");
|
2015
|
-
},
|
2016
2157
|
markPoint: function CanvasGraphics_markPoint(tag) {},
|
2017
2158
|
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
|
2018
|
-
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
|
2019
|
-
|
2020
|
-
|
2159
|
+
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
|
2160
|
+
this.markedContentStack.push({
|
2161
|
+
visible: true
|
2162
|
+
});
|
2163
|
+
},
|
2164
|
+
beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
|
2165
|
+
if (tag === "OC") {
|
2166
|
+
this.markedContentStack.push({
|
2167
|
+
visible: this.optionalContentConfig.isVisible(properties)
|
2168
|
+
});
|
2169
|
+
} else {
|
2170
|
+
this.markedContentStack.push({
|
2171
|
+
visible: true
|
2172
|
+
});
|
2173
|
+
}
|
2174
|
+
|
2175
|
+
this.contentVisible = this.isContentVisible();
|
2176
|
+
},
|
2177
|
+
endMarkedContent: function CanvasGraphics_endMarkedContent() {
|
2178
|
+
this.markedContentStack.pop();
|
2179
|
+
this.contentVisible = this.isContentVisible();
|
2180
|
+
},
|
2021
2181
|
beginCompat: function CanvasGraphics_beginCompat() {},
|
2022
2182
|
endCompat: function CanvasGraphics_endCompat() {},
|
2023
2183
|
consumePath: function CanvasGraphics_consumePath() {
|
@@ -2048,6 +2208,15 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2048
2208
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
2049
2209
|
var transform = this.ctx.mozCurrentTransform;
|
2050
2210
|
return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
|
2211
|
+
},
|
2212
|
+
isContentVisible: function CanvasGraphics_isContentVisible() {
|
2213
|
+
for (let i = this.markedContentStack.length - 1; i >= 0; i--) {
|
2214
|
+
if (!this.markedContentStack[i].visible) {
|
2215
|
+
return false;
|
2216
|
+
}
|
2217
|
+
}
|
2218
|
+
|
2219
|
+
return true;
|
2051
2220
|
}
|
2052
2221
|
};
|
2053
2222
|
|
@@ -30,7 +30,7 @@ exports.isFetchSupported = isFetchSupported;
|
|
30
30
|
exports.isValidFetchUrl = isValidFetchUrl;
|
31
31
|
exports.loadScript = loadScript;
|
32
32
|
exports.deprecated = deprecated;
|
33
|
-
exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.DOMCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
|
33
|
+
exports.PDFDateString = exports.StatTimer = exports.DOMSVGFactory = exports.DOMCMapReaderFactory = exports.BaseCMapReaderFactory = exports.DOMCanvasFactory = exports.BaseCanvasFactory = exports.DEFAULT_LINK_REL = exports.LinkTarget = exports.RenderingCancelledException = exports.PageViewport = void 0;
|
34
34
|
|
35
35
|
var _util = require("../shared/util.js");
|
36
36
|
|
@@ -38,20 +38,15 @@ const DEFAULT_LINK_REL = "noopener noreferrer nofollow";
|
|
38
38
|
exports.DEFAULT_LINK_REL = DEFAULT_LINK_REL;
|
39
39
|
const SVG_NS = "http://www.w3.org/2000/svg";
|
40
40
|
|
41
|
-
class
|
42
|
-
|
43
|
-
if (
|
44
|
-
|
41
|
+
class BaseCanvasFactory {
|
42
|
+
constructor() {
|
43
|
+
if (this.constructor === BaseCanvasFactory) {
|
44
|
+
(0, _util.unreachable)("Cannot initialize BaseCanvasFactory.");
|
45
45
|
}
|
46
|
+
}
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
canvas.width = width;
|
50
|
-
canvas.height = height;
|
51
|
-
return {
|
52
|
-
canvas,
|
53
|
-
context
|
54
|
-
};
|
48
|
+
create(width, height) {
|
49
|
+
(0, _util.unreachable)("Abstract method `create` called.");
|
55
50
|
}
|
56
51
|
|
57
52
|
reset(canvasAndContext, width, height) {
|
@@ -80,13 +75,45 @@ class DOMCanvasFactory {
|
|
80
75
|
|
81
76
|
}
|
82
77
|
|
78
|
+
exports.BaseCanvasFactory = BaseCanvasFactory;
|
79
|
+
|
80
|
+
class DOMCanvasFactory extends BaseCanvasFactory {
|
81
|
+
constructor({
|
82
|
+
ownerDocument = globalThis.document
|
83
|
+
} = {}) {
|
84
|
+
super();
|
85
|
+
this._document = ownerDocument;
|
86
|
+
}
|
87
|
+
|
88
|
+
create(width, height) {
|
89
|
+
if (width <= 0 || height <= 0) {
|
90
|
+
throw new Error("Invalid canvas size");
|
91
|
+
}
|
92
|
+
|
93
|
+
const canvas = this._document.createElement("canvas");
|
94
|
+
|
95
|
+
const context = canvas.getContext("2d");
|
96
|
+
canvas.width = width;
|
97
|
+
canvas.height = height;
|
98
|
+
return {
|
99
|
+
canvas,
|
100
|
+
context
|
101
|
+
};
|
102
|
+
}
|
103
|
+
|
104
|
+
}
|
105
|
+
|
83
106
|
exports.DOMCanvasFactory = DOMCanvasFactory;
|
84
107
|
|
85
|
-
class
|
108
|
+
class BaseCMapReaderFactory {
|
86
109
|
constructor({
|
87
110
|
baseUrl = null,
|
88
111
|
isCompressed = false
|
89
112
|
}) {
|
113
|
+
if (this.constructor === BaseCMapReaderFactory) {
|
114
|
+
(0, _util.unreachable)("Cannot initialize BaseCMapReaderFactory.");
|
115
|
+
}
|
116
|
+
|
90
117
|
this.baseUrl = baseUrl;
|
91
118
|
this.isCompressed = isCompressed;
|
92
119
|
}
|
@@ -104,7 +131,21 @@ class DOMCMapReaderFactory {
|
|
104
131
|
|
105
132
|
const url = this.baseUrl + name + (this.isCompressed ? ".bcmap" : "");
|
106
133
|
const compressionType = this.isCompressed ? _util.CMapCompressionType.BINARY : _util.CMapCompressionType.NONE;
|
134
|
+
return this._fetchData(url, compressionType).catch(reason => {
|
135
|
+
throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}CMap at: ${url}`);
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
139
|
+
_fetchData(url, compressionType) {
|
140
|
+
(0, _util.unreachable)("Abstract method `_fetchData` called.");
|
141
|
+
}
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
exports.BaseCMapReaderFactory = BaseCMapReaderFactory;
|
107
146
|
|
147
|
+
class DOMCMapReaderFactory extends BaseCMapReaderFactory {
|
148
|
+
_fetchData(url, compressionType) {
|
108
149
|
if (isFetchSupported() && isValidFetchUrl(url, document.baseURI)) {
|
109
150
|
return fetch(url).then(async response => {
|
110
151
|
if (!response.ok) {
|
@@ -123,8 +164,6 @@ class DOMCMapReaderFactory {
|
|
123
164
|
cMapData,
|
124
165
|
compressionType
|
125
166
|
};
|
126
|
-
}).catch(reason => {
|
127
|
-
throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
|
128
167
|
});
|
129
168
|
}
|
130
169
|
|
@@ -163,8 +202,6 @@ class DOMCMapReaderFactory {
|
|
163
202
|
};
|
164
203
|
|
165
204
|
request.send(null);
|
166
|
-
}).catch(reason => {
|
167
|
-
throw new Error(`Unable to load ${this.isCompressed ? "binary " : ""}` + `CMap at: ${url}`);
|
168
205
|
});
|
169
206
|
}
|
170
207
|
|
@@ -253,6 +253,12 @@ class PDFFetchStreamRangeReader {
|
|
253
253
|
this._readCapability.resolve();
|
254
254
|
|
255
255
|
this._reader = response.body.getReader();
|
256
|
+
}).catch(reason => {
|
257
|
+
if (reason && reason.name === "AbortError") {
|
258
|
+
return;
|
259
|
+
}
|
260
|
+
|
261
|
+
throw reason;
|
256
262
|
});
|
257
263
|
this.onProgress = null;
|
258
264
|
}
|