pdfjs-dist 2.2.228 → 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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- 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/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- 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 +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
package/lib/display/canvas.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -26,9 +26,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
26
26
|
});
|
27
27
|
exports.CanvasGraphics = void 0;
|
28
28
|
|
29
|
-
var _util = require("../shared/util");
|
29
|
+
var _util = require("../shared/util.js");
|
30
30
|
|
31
|
-
var _pattern_helper = require("./pattern_helper");
|
31
|
+
var _pattern_helper = require("./pattern_helper.js");
|
32
32
|
|
33
33
|
var MIN_FONT_SIZE = 16;
|
34
34
|
var MAX_FONT_SIZE = 100;
|
@@ -37,12 +37,6 @@ var MIN_WIDTH_FACTOR = 0.65;
|
|
37
37
|
var COMPILE_TYPE3_GLYPHS = true;
|
38
38
|
var MAX_SIZE_TO_COMPILE = 1000;
|
39
39
|
var FULL_CHUNK_HEIGHT = 16;
|
40
|
-
var IsLittleEndianCached = {
|
41
|
-
get value() {
|
42
|
-
return (0, _util.shadow)(IsLittleEndianCached, 'value', (0, _util.isLittleEndian)());
|
43
|
-
}
|
44
|
-
|
45
|
-
};
|
46
40
|
|
47
41
|
function addContextCurrentTransform(ctx) {
|
48
42
|
if (!ctx.mozCurrentTransform) {
|
@@ -55,12 +49,12 @@ function addContextCurrentTransform(ctx) {
|
|
55
49
|
ctx._originalSetTransform = ctx.setTransform;
|
56
50
|
ctx._transformMatrix = ctx._transformMatrix || [1, 0, 0, 1, 0, 0];
|
57
51
|
ctx._transformStack = [];
|
58
|
-
Object.defineProperty(ctx,
|
52
|
+
Object.defineProperty(ctx, "mozCurrentTransform", {
|
59
53
|
get: function getCurrentTransform() {
|
60
54
|
return this._transformMatrix;
|
61
55
|
}
|
62
56
|
});
|
63
|
-
Object.defineProperty(ctx,
|
57
|
+
Object.defineProperty(ctx, "mozCurrentTransformInverse", {
|
64
58
|
get: function getCurrentTransformInverse() {
|
65
59
|
var m = this._transformMatrix;
|
66
60
|
var a = m[0],
|
@@ -162,13 +156,15 @@ var CachedCanvases = function CachedCanvasesClosure() {
|
|
162
156
|
|
163
157
|
return canvasEntry;
|
164
158
|
},
|
165
|
-
|
159
|
+
|
160
|
+
clear() {
|
166
161
|
for (var id in this.cache) {
|
167
162
|
var canvasEntry = this.cache[id];
|
168
163
|
this.canvasFactory.destroy(canvasEntry);
|
169
164
|
delete this.cache[id];
|
170
165
|
}
|
171
166
|
}
|
167
|
+
|
172
168
|
};
|
173
169
|
return CachedCanvases;
|
174
170
|
}();
|
@@ -328,18 +324,18 @@ function compileType3Glyph(imgData) {
|
|
328
324
|
--i;
|
329
325
|
}
|
330
326
|
|
331
|
-
var drawOutline = function
|
327
|
+
var drawOutline = function (c) {
|
332
328
|
c.save();
|
333
329
|
c.scale(1 / width, -1 / height);
|
334
330
|
c.translate(0, -height);
|
335
331
|
c.beginPath();
|
336
332
|
|
337
|
-
for (
|
338
|
-
var o = outlines[
|
333
|
+
for (let k = 0, kk = outlines.length; k < kk; k++) {
|
334
|
+
var o = outlines[k];
|
339
335
|
c.moveTo(o[0], o[1]);
|
340
336
|
|
341
|
-
for (
|
342
|
-
c.lineTo(o[
|
337
|
+
for (let l = 2, ll = o.length; l < ll; l += 2) {
|
338
|
+
c.lineTo(o[l], o[l + 1]);
|
343
339
|
}
|
344
340
|
}
|
345
341
|
|
@@ -369,14 +365,15 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
|
|
369
365
|
this.textHScale = 1;
|
370
366
|
this.textRenderingMode = _util.TextRenderingMode.FILL;
|
371
367
|
this.textRise = 0;
|
372
|
-
this.fillColor =
|
373
|
-
this.strokeColor =
|
368
|
+
this.fillColor = "#000000";
|
369
|
+
this.strokeColor = "#000000";
|
374
370
|
this.patternFill = false;
|
375
371
|
this.fillAlpha = 1;
|
376
372
|
this.strokeAlpha = 1;
|
377
373
|
this.lineWidth = 1;
|
378
374
|
this.activeSMask = null;
|
379
375
|
this.resumeSMaskCtx = null;
|
376
|
+
this.transferMaps = null;
|
380
377
|
}
|
381
378
|
|
382
379
|
CanvasExtraState.prototype = {
|
@@ -395,7 +392,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
395
392
|
var EXECUTION_TIME = 15;
|
396
393
|
var EXECUTION_STEPS = 10;
|
397
394
|
|
398
|
-
function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer) {
|
395
|
+
function CanvasGraphics(canvasCtx, commonObjs, objs, canvasFactory, webGLContext, imageLayer, optionalContentConfig) {
|
399
396
|
this.ctx = canvasCtx;
|
400
397
|
this.current = new CanvasExtraState();
|
401
398
|
this.stateStack = [];
|
@@ -416,6 +413,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
416
413
|
this.smaskStack = [];
|
417
414
|
this.smaskCounter = 0;
|
418
415
|
this.tempSMask = null;
|
416
|
+
this.contentVisible = true;
|
417
|
+
this.markedContentStack = [];
|
418
|
+
this.optionalContentConfig = optionalContentConfig;
|
419
419
|
this.cachedCanvases = new CachedCanvases(this.canvasFactory);
|
420
420
|
|
421
421
|
if (canvasCtx) {
|
@@ -425,8 +425,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
425
425
|
this._cachedGetSinglePixelWidth = null;
|
426
426
|
}
|
427
427
|
|
428
|
-
function putBinaryImageData(ctx, imgData) {
|
429
|
-
if (typeof ImageData !==
|
428
|
+
function putBinaryImageData(ctx, imgData, transferMaps = null) {
|
429
|
+
if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
|
430
430
|
ctx.putImageData(imgData, 0, 0);
|
431
431
|
return;
|
432
432
|
}
|
@@ -442,14 +442,39 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
442
442
|
var src = imgData.data;
|
443
443
|
var dest = chunkImgData.data;
|
444
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
|
+
}
|
445
464
|
|
446
465
|
if (imgData.kind === _util.ImageKind.GRAYSCALE_1BPP) {
|
447
466
|
var srcLength = src.byteLength;
|
448
467
|
var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
|
449
468
|
var dest32DataLength = dest32.length;
|
450
469
|
var fullSrcDiff = width + 7 >> 3;
|
451
|
-
var white =
|
452
|
-
var black = IsLittleEndianCached.value ?
|
470
|
+
var white = 0xffffffff;
|
471
|
+
var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
|
472
|
+
|
473
|
+
if (transferMapGray) {
|
474
|
+
if (transferMapGray[0] === 0xff && transferMapGray[0xff] === 0) {
|
475
|
+
[white, black] = [black, white];
|
476
|
+
}
|
477
|
+
}
|
453
478
|
|
454
479
|
for (i = 0; i < totalChunks; i++) {
|
455
480
|
thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
@@ -457,7 +482,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
457
482
|
|
458
483
|
for (j = 0; j < thisChunkHeight; j++) {
|
459
484
|
var srcDiff = srcLength - srcPos;
|
460
|
-
|
485
|
+
let k = 0;
|
461
486
|
var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
|
462
487
|
var kEndUnrolled = kEnd & ~7;
|
463
488
|
var mask = 0;
|
@@ -493,12 +518,30 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
493
518
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
494
519
|
}
|
495
520
|
} else if (imgData.kind === _util.ImageKind.RGBA_32BPP) {
|
521
|
+
const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
|
496
522
|
j = 0;
|
497
523
|
elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
|
498
524
|
|
499
525
|
for (i = 0; i < fullChunks; i++) {
|
500
526
|
dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
|
501
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
|
+
|
502
545
|
ctx.putImageData(chunkImgData, 0, j);
|
503
546
|
j += FULL_CHUNK_HEIGHT;
|
504
547
|
}
|
@@ -506,9 +549,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
506
549
|
if (i < totalChunks) {
|
507
550
|
elemsInThisChunk = width * partialChunkHeight * 4;
|
508
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
|
+
|
509
569
|
ctx.putImageData(chunkImgData, 0, j);
|
510
570
|
}
|
511
571
|
} else if (imgData.kind === _util.ImageKind.RGB_24BPP) {
|
572
|
+
const hasTransferMaps = !!(transferMapRed || transferMapGreen || transferMapBlue);
|
512
573
|
thisChunkHeight = FULL_CHUNK_HEIGHT;
|
513
574
|
elemsInThisChunk = width * thisChunkHeight;
|
514
575
|
|
@@ -527,10 +588,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
527
588
|
dest[destPos++] = 255;
|
528
589
|
}
|
529
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
|
+
|
530
607
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
531
608
|
}
|
532
609
|
} else {
|
533
|
-
throw new Error(
|
610
|
+
throw new Error(`bad image kind: ${imgData.kind}`);
|
534
611
|
}
|
535
612
|
}
|
536
613
|
|
@@ -569,7 +646,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
569
646
|
}
|
570
647
|
|
571
648
|
function copyCtxState(sourceCtx, destCtx) {
|
572
|
-
var properties = [
|
649
|
+
var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
|
573
650
|
|
574
651
|
for (var i = 0, ii = properties.length; i < ii; i++) {
|
575
652
|
var property = properties[i];
|
@@ -586,16 +663,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
586
663
|
}
|
587
664
|
|
588
665
|
function resetCtxToDefault(ctx) {
|
589
|
-
ctx.strokeStyle =
|
590
|
-
ctx.fillStyle =
|
591
|
-
ctx.fillRule =
|
666
|
+
ctx.strokeStyle = "#000000";
|
667
|
+
ctx.fillStyle = "#000000";
|
668
|
+
ctx.fillRule = "nonzero";
|
592
669
|
ctx.globalAlpha = 1;
|
593
670
|
ctx.lineWidth = 1;
|
594
|
-
ctx.lineCap =
|
595
|
-
ctx.lineJoin =
|
671
|
+
ctx.lineCap = "butt";
|
672
|
+
ctx.lineJoin = "miter";
|
596
673
|
ctx.miterLimit = 10;
|
597
|
-
ctx.globalCompositeOperation =
|
598
|
-
ctx.font =
|
674
|
+
ctx.globalCompositeOperation = "source-over";
|
675
|
+
ctx.font = "10px sans-serif";
|
599
676
|
|
600
677
|
if (ctx.setLineDash !== undefined) {
|
601
678
|
ctx.setLineDash([]);
|
@@ -648,7 +725,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
648
725
|
var b0 = hasBackdrop ? backdrop[2] : 0;
|
649
726
|
var composeFn;
|
650
727
|
|
651
|
-
if (subtype ===
|
728
|
+
if (subtype === "Luminosity") {
|
652
729
|
composeFn = composeSMaskLuminosity;
|
653
730
|
} else {
|
654
731
|
composeFn = composeSMaskAlpha;
|
@@ -678,12 +755,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
678
755
|
var backdrop = smask.backdrop || null;
|
679
756
|
|
680
757
|
if (!smask.transferMap && webGLContext.isEnabled) {
|
681
|
-
|
758
|
+
const composed = webGLContext.composeSMask({
|
682
759
|
layer: layerCtx.canvas,
|
683
|
-
mask
|
760
|
+
mask,
|
684
761
|
properties: {
|
685
762
|
subtype: smask.subtype,
|
686
|
-
backdrop
|
763
|
+
backdrop
|
687
764
|
}
|
688
765
|
});
|
689
766
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
@@ -695,27 +772,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
695
772
|
ctx.drawImage(mask, 0, 0);
|
696
773
|
}
|
697
774
|
|
698
|
-
var LINE_CAP_STYLES = [
|
699
|
-
var LINE_JOIN_STYLES = [
|
775
|
+
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
776
|
+
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
700
777
|
var NORMAL_CLIP = {};
|
701
778
|
var EO_CLIP = {};
|
702
779
|
CanvasGraphics.prototype = {
|
703
|
-
beginDrawing
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
background = _ref$background === void 0 ? null : _ref$background;
|
780
|
+
beginDrawing({
|
781
|
+
transform,
|
782
|
+
viewport,
|
783
|
+
transparency = false,
|
784
|
+
background = null
|
785
|
+
}) {
|
710
786
|
var width = this.ctx.canvas.width;
|
711
787
|
var height = this.ctx.canvas.height;
|
712
788
|
this.ctx.save();
|
713
|
-
this.ctx.fillStyle = background ||
|
789
|
+
this.ctx.fillStyle = background || "rgb(255, 255, 255)";
|
714
790
|
this.ctx.fillRect(0, 0, width, height);
|
715
791
|
this.ctx.restore();
|
716
792
|
|
717
793
|
if (transparency) {
|
718
|
-
var transparentCanvas = this.cachedCanvases.getCanvas(
|
794
|
+
var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
|
719
795
|
this.compositeCtx = this.ctx;
|
720
796
|
this.transparentCanvas = transparentCanvas.canvas;
|
721
797
|
this.ctx = transparentCanvas.context;
|
@@ -737,6 +813,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
737
813
|
this.imageLayer.beginLayout();
|
738
814
|
}
|
739
815
|
},
|
816
|
+
|
740
817
|
executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
|
741
818
|
var argsArray = operatorList.argsArray;
|
742
819
|
var fnArray = operatorList.fnArray;
|
@@ -747,7 +824,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
747
824
|
return i;
|
748
825
|
}
|
749
826
|
|
750
|
-
var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback ===
|
827
|
+
var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
|
751
828
|
var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
|
752
829
|
var steps = 0;
|
753
830
|
var commonObjs = this.commonObjs;
|
@@ -765,32 +842,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
765
842
|
if (fnId !== _util.OPS.dependency) {
|
766
843
|
this[fnId].apply(this, argsArray[i]);
|
767
844
|
} else {
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
var depObjId = _step.value;
|
775
|
-
var objsPool = depObjId.startsWith('g_') ? commonObjs : objs;
|
776
|
-
|
777
|
-
if (!objsPool.has(depObjId)) {
|
778
|
-
objsPool.get(depObjId, continueCallback);
|
779
|
-
return i;
|
780
|
-
}
|
781
|
-
}
|
782
|
-
} catch (err) {
|
783
|
-
_didIteratorError = true;
|
784
|
-
_iteratorError = err;
|
785
|
-
} finally {
|
786
|
-
try {
|
787
|
-
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
|
788
|
-
_iterator["return"]();
|
789
|
-
}
|
790
|
-
} finally {
|
791
|
-
if (_didIteratorError) {
|
792
|
-
throw _iteratorError;
|
793
|
-
}
|
845
|
+
for (const depObjId of argsArray[i]) {
|
846
|
+
const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
|
847
|
+
|
848
|
+
if (!objsPool.has(depObjId)) {
|
849
|
+
objsPool.get(depObjId, continueCallback);
|
850
|
+
return i;
|
794
851
|
}
|
795
852
|
}
|
796
853
|
}
|
@@ -855,8 +912,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
855
912
|
ctx.lineDashOffset = dashPhase;
|
856
913
|
}
|
857
914
|
},
|
858
|
-
|
859
|
-
|
915
|
+
|
916
|
+
setRenderingIntent(intent) {},
|
917
|
+
|
918
|
+
setFlatness(flatness) {},
|
919
|
+
|
860
920
|
setGState: function CanvasGraphics_setGState(states) {
|
861
921
|
for (var i = 0, ii = states.length; i < ii; i++) {
|
862
922
|
var state = states[i];
|
@@ -864,52 +924,52 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
864
924
|
var value = state[1];
|
865
925
|
|
866
926
|
switch (key) {
|
867
|
-
case
|
927
|
+
case "LW":
|
868
928
|
this.setLineWidth(value);
|
869
929
|
break;
|
870
930
|
|
871
|
-
case
|
931
|
+
case "LC":
|
872
932
|
this.setLineCap(value);
|
873
933
|
break;
|
874
934
|
|
875
|
-
case
|
935
|
+
case "LJ":
|
876
936
|
this.setLineJoin(value);
|
877
937
|
break;
|
878
938
|
|
879
|
-
case
|
939
|
+
case "ML":
|
880
940
|
this.setMiterLimit(value);
|
881
941
|
break;
|
882
942
|
|
883
|
-
case
|
943
|
+
case "D":
|
884
944
|
this.setDash(value[0], value[1]);
|
885
945
|
break;
|
886
946
|
|
887
|
-
case
|
947
|
+
case "RI":
|
888
948
|
this.setRenderingIntent(value);
|
889
949
|
break;
|
890
950
|
|
891
|
-
case
|
951
|
+
case "FL":
|
892
952
|
this.setFlatness(value);
|
893
953
|
break;
|
894
954
|
|
895
|
-
case
|
955
|
+
case "Font":
|
896
956
|
this.setFont(value[0], value[1]);
|
897
957
|
break;
|
898
958
|
|
899
|
-
case
|
959
|
+
case "CA":
|
900
960
|
this.current.strokeAlpha = state[1];
|
901
961
|
break;
|
902
962
|
|
903
|
-
case
|
963
|
+
case "ca":
|
904
964
|
this.current.fillAlpha = state[1];
|
905
965
|
this.ctx.globalAlpha = state[1];
|
906
966
|
break;
|
907
967
|
|
908
|
-
case
|
968
|
+
case "BM":
|
909
969
|
this.ctx.globalCompositeOperation = value;
|
910
970
|
break;
|
911
971
|
|
912
|
-
case
|
972
|
+
case "SMask":
|
913
973
|
if (this.current.activeSMask) {
|
914
974
|
if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
|
915
975
|
this.suspendSMaskGroup();
|
@@ -926,6 +986,9 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
926
986
|
|
927
987
|
this.tempSMask = null;
|
928
988
|
break;
|
989
|
+
|
990
|
+
case "TR":
|
991
|
+
this.current.transferMaps = value;
|
929
992
|
}
|
930
993
|
}
|
931
994
|
},
|
@@ -933,7 +996,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
933
996
|
var activeSMask = this.current.activeSMask;
|
934
997
|
var drawnWidth = activeSMask.canvas.width;
|
935
998
|
var drawnHeight = activeSMask.canvas.height;
|
936
|
-
var cacheId =
|
999
|
+
var cacheId = "smaskGroupAt" + this.groupLevel;
|
937
1000
|
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
938
1001
|
var currentCtx = this.ctx;
|
939
1002
|
var currentTransform = currentCtx.mozCurrentTransform;
|
@@ -945,7 +1008,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
945
1008
|
activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
|
946
1009
|
copyCtxState(currentCtx, groupCtx);
|
947
1010
|
this.ctx = groupCtx;
|
948
|
-
this.setGState([[
|
1011
|
+
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
949
1012
|
this.groupStack.push(currentCtx);
|
950
1013
|
this.groupLevel++;
|
951
1014
|
},
|
@@ -1027,22 +1090,22 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1027
1090
|
var width = args[j++];
|
1028
1091
|
var height = args[j++];
|
1029
1092
|
|
1030
|
-
if (width === 0) {
|
1093
|
+
if (width === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
1031
1094
|
width = this.getSinglePixelWidth();
|
1032
1095
|
}
|
1033
1096
|
|
1034
|
-
if (height === 0) {
|
1097
|
+
if (height === 0 && ctx.lineWidth < this.getSinglePixelWidth()) {
|
1035
1098
|
height = this.getSinglePixelWidth();
|
1036
1099
|
}
|
1037
1100
|
|
1038
1101
|
var xw = x + width;
|
1039
1102
|
var yh = y + height;
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
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();
|
1046
1109
|
break;
|
1047
1110
|
|
1048
1111
|
case _util.OPS.moveTo:
|
@@ -1090,19 +1153,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1090
1153
|
this.ctx.closePath();
|
1091
1154
|
},
|
1092
1155
|
stroke: function CanvasGraphics_stroke(consumePath) {
|
1093
|
-
consumePath = typeof consumePath !==
|
1156
|
+
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
1094
1157
|
var ctx = this.ctx;
|
1095
1158
|
var strokeColor = this.current.strokeColor;
|
1096
|
-
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
|
1097
1159
|
ctx.globalAlpha = this.current.strokeAlpha;
|
1098
1160
|
|
1099
|
-
if (
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1161
|
+
if (this.contentVisible) {
|
1162
|
+
if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
|
1163
|
+
ctx.save();
|
1164
|
+
const transform = ctx.mozCurrentTransform;
|
1165
|
+
|
1166
|
+
const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
|
1167
|
+
|
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
|
+
}
|
1106
1176
|
}
|
1107
1177
|
|
1108
1178
|
if (consumePath) {
|
@@ -1116,7 +1186,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1116
1186
|
this.stroke();
|
1117
1187
|
},
|
1118
1188
|
fill: function CanvasGraphics_fill(consumePath) {
|
1119
|
-
consumePath = typeof consumePath !==
|
1189
|
+
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
1120
1190
|
var ctx = this.ctx;
|
1121
1191
|
var fillColor = this.current.fillColor;
|
1122
1192
|
var isPatternFill = this.current.patternFill;
|
@@ -1133,11 +1203,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1133
1203
|
needRestore = true;
|
1134
1204
|
}
|
1135
1205
|
|
1136
|
-
if (this.
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1206
|
+
if (this.contentVisible) {
|
1207
|
+
if (this.pendingEOFill) {
|
1208
|
+
ctx.fill("evenodd");
|
1209
|
+
this.pendingEOFill = false;
|
1210
|
+
} else {
|
1211
|
+
ctx.fill();
|
1212
|
+
}
|
1141
1213
|
}
|
1142
1214
|
|
1143
1215
|
if (needRestore) {
|
@@ -1226,13 +1298,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1226
1298
|
var current = this.current;
|
1227
1299
|
|
1228
1300
|
if (!fontObj) {
|
1229
|
-
throw new Error(
|
1301
|
+
throw new Error(`Can't find font for ${fontRefName}`);
|
1230
1302
|
}
|
1231
1303
|
|
1232
1304
|
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
|
1233
1305
|
|
1234
1306
|
if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
|
1235
|
-
(0, _util.warn)(
|
1307
|
+
(0, _util.warn)("Invalid font matrix for font " + fontRefName);
|
1236
1308
|
}
|
1237
1309
|
|
1238
1310
|
if (size < 0) {
|
@@ -1249,13 +1321,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1249
1321
|
return;
|
1250
1322
|
}
|
1251
1323
|
|
1252
|
-
var name = fontObj.loadedName ||
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1324
|
+
var name = fontObj.loadedName || "sans-serif";
|
1325
|
+
let bold = "normal";
|
1326
|
+
|
1327
|
+
if (fontObj.black) {
|
1328
|
+
bold = "900";
|
1329
|
+
} else if (fontObj.bold) {
|
1330
|
+
bold = "bold";
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
var italic = fontObj.italic ? "italic" : "normal";
|
1334
|
+
var typeface = `"${name}", ${fontObj.fallbackName}`;
|
1335
|
+
let browserFontSize = size;
|
1336
|
+
|
1337
|
+
if (size < MIN_FONT_SIZE) {
|
1338
|
+
browserFontSize = MIN_FONT_SIZE;
|
1339
|
+
} else if (size > MAX_FONT_SIZE) {
|
1340
|
+
browserFontSize = MAX_FONT_SIZE;
|
1341
|
+
}
|
1342
|
+
|
1257
1343
|
this.current.fontSizeScale = size / browserFontSize;
|
1258
|
-
this.ctx.font =
|
1344
|
+
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
1259
1345
|
},
|
1260
1346
|
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
|
1261
1347
|
this.current.textRenderingMode = mode;
|
@@ -1280,7 +1366,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1280
1366
|
nextLine: function CanvasGraphics_nextLine() {
|
1281
1367
|
this.moveText(0, this.current.leading);
|
1282
1368
|
},
|
1283
|
-
|
1369
|
+
|
1370
|
+
paintChar(character, x, y, patternTransform) {
|
1284
1371
|
var ctx = this.ctx;
|
1285
1372
|
var current = this.current;
|
1286
1373
|
var font = current.font;
|
@@ -1288,7 +1375,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1288
1375
|
var fontSize = current.fontSize / current.fontSizeScale;
|
1289
1376
|
var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
|
1290
1377
|
var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
|
1291
|
-
|
1378
|
+
const patternFill = current.patternFill && !font.missingFile;
|
1292
1379
|
var addToPath;
|
1293
1380
|
|
1294
1381
|
if (font.disableFontFace || isAddToPathSet || patternFill) {
|
@@ -1328,20 +1415,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1328
1415
|
var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
1329
1416
|
paths.push({
|
1330
1417
|
transform: ctx.mozCurrentTransform,
|
1331
|
-
x
|
1332
|
-
y
|
1333
|
-
fontSize
|
1334
|
-
addToPath
|
1418
|
+
x,
|
1419
|
+
y,
|
1420
|
+
fontSize,
|
1421
|
+
addToPath
|
1335
1422
|
});
|
1336
1423
|
}
|
1337
1424
|
},
|
1338
1425
|
|
1339
1426
|
get isFontSubpixelAAEnabled() {
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1427
|
+
const {
|
1428
|
+
context: ctx
|
1429
|
+
} = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
|
1343
1430
|
ctx.scale(1.5, 1);
|
1344
|
-
ctx.fillText(
|
1431
|
+
ctx.fillText("I", 0, 10);
|
1345
1432
|
var data = ctx.getImageData(0, 0, 10, 10).data;
|
1346
1433
|
var enabled = false;
|
1347
1434
|
|
@@ -1352,7 +1439,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1352
1439
|
}
|
1353
1440
|
}
|
1354
1441
|
|
1355
|
-
return (0, _util.shadow)(this,
|
1442
|
+
return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
|
1356
1443
|
},
|
1357
1444
|
|
1358
1445
|
showText: function CanvasGraphics_showText(glyphs) {
|
@@ -1382,11 +1469,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1382
1469
|
var widthAdvanceScale = fontSize * current.fontMatrix[0];
|
1383
1470
|
var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
1384
1471
|
ctx.save();
|
1385
|
-
|
1472
|
+
let patternTransform;
|
1386
1473
|
|
1387
1474
|
if (current.patternFill) {
|
1388
1475
|
ctx.save();
|
1389
|
-
|
1476
|
+
const pattern = current.fillColor.getPattern(ctx, this);
|
1390
1477
|
patternTransform = ctx.mozCurrentTransform;
|
1391
1478
|
ctx.restore();
|
1392
1479
|
ctx.fillStyle = pattern;
|
@@ -1467,21 +1554,28 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1467
1554
|
}
|
1468
1555
|
}
|
1469
1556
|
|
1470
|
-
if (glyph.isInFont || font.missingFile) {
|
1557
|
+
if (this.contentVisible && (glyph.isInFont || font.missingFile)) {
|
1471
1558
|
if (simpleFillText && !accent) {
|
1472
1559
|
ctx.fillText(character, scaledX, scaledY);
|
1473
1560
|
} else {
|
1474
1561
|
this.paintChar(character, scaledX, scaledY, patternTransform);
|
1475
1562
|
|
1476
1563
|
if (accent) {
|
1477
|
-
scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
|
1478
|
-
scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
|
1564
|
+
scaledAccentX = scaledX + fontSize * accent.offset.x / fontSizeScale;
|
1565
|
+
scaledAccentY = scaledY - fontSize * accent.offset.y / fontSizeScale;
|
1479
1566
|
this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY, patternTransform);
|
1480
1567
|
}
|
1481
1568
|
}
|
1482
1569
|
}
|
1483
1570
|
|
1484
|
-
var charWidth
|
1571
|
+
var charWidth;
|
1572
|
+
|
1573
|
+
if (vertical) {
|
1574
|
+
charWidth = width * widthAdvanceScale - spacing * fontDirection;
|
1575
|
+
} else {
|
1576
|
+
charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
1577
|
+
}
|
1578
|
+
|
1485
1579
|
x += charWidth;
|
1486
1580
|
|
1487
1581
|
if (restoreNeeded) {
|
@@ -1490,7 +1584,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1490
1584
|
}
|
1491
1585
|
|
1492
1586
|
if (vertical) {
|
1493
|
-
current.y -= x
|
1587
|
+
current.y -= x;
|
1494
1588
|
} else {
|
1495
1589
|
current.x += x * textHScale;
|
1496
1590
|
}
|
@@ -1536,16 +1630,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1536
1630
|
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
1537
1631
|
|
1538
1632
|
if (!operatorList) {
|
1539
|
-
(0, _util.warn)(
|
1633
|
+
(0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
|
1540
1634
|
continue;
|
1541
1635
|
}
|
1542
1636
|
|
1543
|
-
this.
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
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
|
+
}
|
1549
1645
|
|
1550
1646
|
var transformed = _util.Util.applyTransform([glyph.width, 0], fontMatrix);
|
1551
1647
|
|
@@ -1564,16 +1660,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1564
1660
|
this.endPath();
|
1565
1661
|
},
|
1566
1662
|
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
|
1567
|
-
var _this = this;
|
1568
|
-
|
1569
1663
|
var pattern;
|
1570
1664
|
|
1571
|
-
if (IR[0] ===
|
1665
|
+
if (IR[0] === "TilingPattern") {
|
1572
1666
|
var color = IR[1];
|
1573
1667
|
var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
|
1574
1668
|
var canvasGraphicsFactory = {
|
1575
|
-
createCanvasGraphics:
|
1576
|
-
return new CanvasGraphics(ctx,
|
1669
|
+
createCanvasGraphics: ctx => {
|
1670
|
+
return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext);
|
1577
1671
|
}
|
1578
1672
|
};
|
1579
1673
|
pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
|
@@ -1604,6 +1698,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1604
1698
|
this.current.patternFill = false;
|
1605
1699
|
},
|
1606
1700
|
shadingFill: function CanvasGraphics_shadingFill(patternIR) {
|
1701
|
+
if (!this.contentVisible) {
|
1702
|
+
return;
|
1703
|
+
}
|
1704
|
+
|
1607
1705
|
var ctx = this.ctx;
|
1608
1706
|
this.save();
|
1609
1707
|
var pattern = (0, _pattern_helper.getShadingPatternFromIR)(patternIR);
|
@@ -1635,12 +1733,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1635
1733
|
this.restore();
|
1636
1734
|
},
|
1637
1735
|
beginInlineImage: function CanvasGraphics_beginInlineImage() {
|
1638
|
-
(0, _util.unreachable)(
|
1736
|
+
(0, _util.unreachable)("Should not call beginInlineImage");
|
1639
1737
|
},
|
1640
1738
|
beginImageData: function CanvasGraphics_beginImageData() {
|
1641
|
-
(0, _util.unreachable)(
|
1739
|
+
(0, _util.unreachable)("Should not call beginImageData");
|
1642
1740
|
},
|
1643
1741
|
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
|
1742
|
+
if (!this.contentVisible) {
|
1743
|
+
return;
|
1744
|
+
}
|
1745
|
+
|
1644
1746
|
this.save();
|
1645
1747
|
this.baseTransformStack.push(this.baseTransform);
|
1646
1748
|
|
@@ -1659,19 +1761,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1659
1761
|
}
|
1660
1762
|
},
|
1661
1763
|
paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
|
1764
|
+
if (!this.contentVisible) {
|
1765
|
+
return;
|
1766
|
+
}
|
1767
|
+
|
1662
1768
|
this.restore();
|
1663
1769
|
this.baseTransform = this.baseTransformStack.pop();
|
1664
1770
|
},
|
1665
1771
|
beginGroup: function CanvasGraphics_beginGroup(group) {
|
1772
|
+
if (!this.contentVisible) {
|
1773
|
+
return;
|
1774
|
+
}
|
1775
|
+
|
1666
1776
|
this.save();
|
1667
1777
|
var currentCtx = this.ctx;
|
1668
1778
|
|
1669
1779
|
if (!group.isolated) {
|
1670
|
-
(0, _util.info)(
|
1780
|
+
(0, _util.info)("TODO: Support non-isolated groups.");
|
1671
1781
|
}
|
1672
1782
|
|
1673
1783
|
if (group.knockout) {
|
1674
|
-
(0, _util.warn)(
|
1784
|
+
(0, _util.warn)("Knockout groups not supported.");
|
1675
1785
|
}
|
1676
1786
|
|
1677
1787
|
var currentTransform = currentCtx.mozCurrentTransform;
|
@@ -1681,7 +1791,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1681
1791
|
}
|
1682
1792
|
|
1683
1793
|
if (!group.bbox) {
|
1684
|
-
throw new Error(
|
1794
|
+
throw new Error("Bounding box is required.");
|
1685
1795
|
}
|
1686
1796
|
|
1687
1797
|
var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
|
@@ -1705,10 +1815,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1705
1815
|
drawnHeight = MAX_GROUP_SIZE;
|
1706
1816
|
}
|
1707
1817
|
|
1708
|
-
var cacheId =
|
1818
|
+
var cacheId = "groupAt" + this.groupLevel;
|
1709
1819
|
|
1710
1820
|
if (group.smask) {
|
1711
|
-
cacheId +=
|
1821
|
+
cacheId += "_smask_" + this.smaskCounter++ % 2;
|
1712
1822
|
}
|
1713
1823
|
|
1714
1824
|
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
@@ -1721,10 +1831,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1721
1831
|
this.smaskStack.push({
|
1722
1832
|
canvas: scratchCanvas.canvas,
|
1723
1833
|
context: groupCtx,
|
1724
|
-
offsetX
|
1725
|
-
offsetY
|
1726
|
-
scaleX
|
1727
|
-
scaleY
|
1834
|
+
offsetX,
|
1835
|
+
offsetY,
|
1836
|
+
scaleX,
|
1837
|
+
scaleY,
|
1728
1838
|
subtype: group.smask.subtype,
|
1729
1839
|
backdrop: group.smask.backdrop,
|
1730
1840
|
transferMap: group.smask.transferMap || null,
|
@@ -1738,12 +1848,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1738
1848
|
|
1739
1849
|
copyCtxState(currentCtx, groupCtx);
|
1740
1850
|
this.ctx = groupCtx;
|
1741
|
-
this.setGState([[
|
1851
|
+
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
1742
1852
|
this.groupStack.push(currentCtx);
|
1743
1853
|
this.groupLevel++;
|
1744
1854
|
this.current.activeSMask = null;
|
1745
1855
|
},
|
1746
1856
|
endGroup: function CanvasGraphics_endGroup(group) {
|
1857
|
+
if (!this.contentVisible) {
|
1858
|
+
return;
|
1859
|
+
}
|
1860
|
+
|
1747
1861
|
this.groupLevel--;
|
1748
1862
|
var groupCtx = this.ctx;
|
1749
1863
|
this.ctx = this.groupStack.pop();
|
@@ -1791,34 +1905,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1791
1905
|
endAnnotation: function CanvasGraphics_endAnnotation() {
|
1792
1906
|
this.restore();
|
1793
1907
|
},
|
1794
|
-
|
1795
|
-
|
1796
|
-
|
1797
|
-
if (!domImage) {
|
1798
|
-
(0, _util.warn)('Dependent image isn\'t ready yet');
|
1908
|
+
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
1909
|
+
if (!this.contentVisible) {
|
1799
1910
|
return;
|
1800
1911
|
}
|
1801
1912
|
|
1802
|
-
this.save();
|
1803
|
-
var ctx = this.ctx;
|
1804
|
-
ctx.scale(1 / w, -1 / h);
|
1805
|
-
ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
|
1806
|
-
|
1807
|
-
if (this.imageLayer) {
|
1808
|
-
var currentTransform = ctx.mozCurrentTransformInverse;
|
1809
|
-
var position = this.getCanvasPosition(0, 0);
|
1810
|
-
this.imageLayer.appendImage({
|
1811
|
-
objId: objId,
|
1812
|
-
left: position[0],
|
1813
|
-
top: position[1],
|
1814
|
-
width: w / currentTransform[0],
|
1815
|
-
height: h / currentTransform[3]
|
1816
|
-
});
|
1817
|
-
}
|
1818
|
-
|
1819
|
-
this.restore();
|
1820
|
-
},
|
1821
|
-
paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
|
1822
1913
|
var ctx = this.ctx;
|
1823
1914
|
var width = img.width,
|
1824
1915
|
height = img.height;
|
@@ -1830,8 +1921,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1830
1921
|
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
1831
1922
|
glyph.compiled = compileType3Glyph({
|
1832
1923
|
data: img.data,
|
1833
|
-
width
|
1834
|
-
height
|
1924
|
+
width,
|
1925
|
+
height
|
1835
1926
|
});
|
1836
1927
|
} else {
|
1837
1928
|
glyph.compiled = null;
|
@@ -1843,26 +1934,31 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1843
1934
|
return;
|
1844
1935
|
}
|
1845
1936
|
|
1846
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1937
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1847
1938
|
var maskCtx = maskCanvas.context;
|
1848
1939
|
maskCtx.save();
|
1849
1940
|
putBinaryImageMask(maskCtx, img);
|
1850
|
-
maskCtx.globalCompositeOperation =
|
1941
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1851
1942
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1852
1943
|
maskCtx.fillRect(0, 0, width, height);
|
1853
1944
|
maskCtx.restore();
|
1854
1945
|
this.paintInlineImageXObject(maskCanvas.canvas);
|
1855
1946
|
},
|
1856
|
-
|
1947
|
+
|
1948
|
+
paintImageMaskXObjectRepeat(imgData, scaleX, skewX = 0, skewY = 0, scaleY, positions) {
|
1949
|
+
if (!this.contentVisible) {
|
1950
|
+
return;
|
1951
|
+
}
|
1952
|
+
|
1857
1953
|
var width = imgData.width;
|
1858
1954
|
var height = imgData.height;
|
1859
1955
|
var fillColor = this.current.fillColor;
|
1860
1956
|
var isPatternFill = this.current.patternFill;
|
1861
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1957
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1862
1958
|
var maskCtx = maskCanvas.context;
|
1863
1959
|
maskCtx.save();
|
1864
1960
|
putBinaryImageMask(maskCtx, imgData);
|
1865
|
-
maskCtx.globalCompositeOperation =
|
1961
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1866
1962
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1867
1963
|
maskCtx.fillRect(0, 0, width, height);
|
1868
1964
|
maskCtx.restore();
|
@@ -1870,13 +1966,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1870
1966
|
|
1871
1967
|
for (var i = 0, ii = positions.length; i < ii; i += 2) {
|
1872
1968
|
ctx.save();
|
1873
|
-
ctx.transform(scaleX,
|
1969
|
+
ctx.transform(scaleX, skewX, skewY, scaleY, positions[i], positions[i + 1]);
|
1874
1970
|
ctx.scale(1, -1);
|
1875
1971
|
ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
|
1876
1972
|
ctx.restore();
|
1877
1973
|
}
|
1878
1974
|
},
|
1975
|
+
|
1879
1976
|
paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
|
1977
|
+
if (!this.contentVisible) {
|
1978
|
+
return;
|
1979
|
+
}
|
1980
|
+
|
1880
1981
|
var ctx = this.ctx;
|
1881
1982
|
var fillColor = this.current.fillColor;
|
1882
1983
|
var isPatternFill = this.current.patternFill;
|
@@ -1885,11 +1986,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1885
1986
|
var image = images[i];
|
1886
1987
|
var width = image.width,
|
1887
1988
|
height = image.height;
|
1888
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1989
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1889
1990
|
var maskCtx = maskCanvas.context;
|
1890
1991
|
maskCtx.save();
|
1891
1992
|
putBinaryImageMask(maskCtx, image);
|
1892
|
-
maskCtx.globalCompositeOperation =
|
1993
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1893
1994
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1894
1995
|
maskCtx.fillRect(0, 0, width, height);
|
1895
1996
|
maskCtx.restore();
|
@@ -1901,20 +2002,28 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1901
2002
|
}
|
1902
2003
|
},
|
1903
2004
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
1904
|
-
|
2005
|
+
if (!this.contentVisible) {
|
2006
|
+
return;
|
2007
|
+
}
|
2008
|
+
|
2009
|
+
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1905
2010
|
|
1906
2011
|
if (!imgData) {
|
1907
|
-
(0, _util.warn)(
|
2012
|
+
(0, _util.warn)("Dependent image isn't ready yet");
|
1908
2013
|
return;
|
1909
2014
|
}
|
1910
2015
|
|
1911
2016
|
this.paintInlineImageXObject(imgData);
|
1912
2017
|
},
|
1913
2018
|
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
|
1914
|
-
|
2019
|
+
if (!this.contentVisible) {
|
2020
|
+
return;
|
2021
|
+
}
|
2022
|
+
|
2023
|
+
const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1915
2024
|
|
1916
2025
|
if (!imgData) {
|
1917
|
-
(0, _util.warn)(
|
2026
|
+
(0, _util.warn)("Dependent image isn't ready yet");
|
1918
2027
|
return;
|
1919
2028
|
}
|
1920
2029
|
|
@@ -1935,6 +2044,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1935
2044
|
this.paintInlineImageXObjectGroup(imgData, map);
|
1936
2045
|
},
|
1937
2046
|
paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
|
2047
|
+
if (!this.contentVisible) {
|
2048
|
+
return;
|
2049
|
+
}
|
2050
|
+
|
1938
2051
|
var width = imgData.width;
|
1939
2052
|
var height = imgData.height;
|
1940
2053
|
var ctx = this.ctx;
|
@@ -1949,18 +2062,18 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1949
2062
|
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
|
1950
2063
|
var imgToPaint, tmpCanvas;
|
1951
2064
|
|
1952
|
-
if (typeof HTMLElement ===
|
2065
|
+
if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
|
1953
2066
|
imgToPaint = imgData;
|
1954
2067
|
} else {
|
1955
|
-
tmpCanvas = this.cachedCanvases.getCanvas(
|
2068
|
+
tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
|
1956
2069
|
var tmpCtx = tmpCanvas.context;
|
1957
|
-
putBinaryImageData(tmpCtx, imgData);
|
2070
|
+
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
1958
2071
|
imgToPaint = tmpCanvas.canvas;
|
1959
2072
|
}
|
1960
2073
|
|
1961
2074
|
var paintWidth = width,
|
1962
2075
|
paintHeight = height;
|
1963
|
-
var tmpCanvasId =
|
2076
|
+
var tmpCanvasId = "prescale1";
|
1964
2077
|
|
1965
2078
|
while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
|
1966
2079
|
var newWidth = paintWidth,
|
@@ -1983,7 +2096,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1983
2096
|
imgToPaint = tmpCanvas.canvas;
|
1984
2097
|
paintWidth = newWidth;
|
1985
2098
|
paintHeight = newHeight;
|
1986
|
-
tmpCanvasId = tmpCanvasId ===
|
2099
|
+
tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
|
1987
2100
|
}
|
1988
2101
|
|
1989
2102
|
ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
|
@@ -1991,7 +2104,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1991
2104
|
if (this.imageLayer) {
|
1992
2105
|
var position = this.getCanvasPosition(0, -height);
|
1993
2106
|
this.imageLayer.appendImage({
|
1994
|
-
imgData
|
2107
|
+
imgData,
|
1995
2108
|
left: position[0],
|
1996
2109
|
top: position[1],
|
1997
2110
|
width: width / currentTransform[0],
|
@@ -2002,12 +2115,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2002
2115
|
this.restore();
|
2003
2116
|
},
|
2004
2117
|
paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
|
2118
|
+
if (!this.contentVisible) {
|
2119
|
+
return;
|
2120
|
+
}
|
2121
|
+
|
2005
2122
|
var ctx = this.ctx;
|
2006
2123
|
var w = imgData.width;
|
2007
2124
|
var h = imgData.height;
|
2008
|
-
var tmpCanvas = this.cachedCanvases.getCanvas(
|
2125
|
+
var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
|
2009
2126
|
var tmpCtx = tmpCanvas.context;
|
2010
|
-
putBinaryImageData(tmpCtx, imgData);
|
2127
|
+
putBinaryImageData(tmpCtx, imgData, this.current.transferMaps);
|
2011
2128
|
|
2012
2129
|
for (var i = 0, ii = map.length; i < ii; i++) {
|
2013
2130
|
var entry = map[i];
|
@@ -2019,7 +2136,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2019
2136
|
if (this.imageLayer) {
|
2020
2137
|
var position = this.getCanvasPosition(entry.x, entry.y);
|
2021
2138
|
this.imageLayer.appendImage({
|
2022
|
-
imgData
|
2139
|
+
imgData,
|
2023
2140
|
left: position[0],
|
2024
2141
|
top: position[1],
|
2025
2142
|
width: w,
|
@@ -2031,16 +2148,36 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2031
2148
|
}
|
2032
2149
|
},
|
2033
2150
|
paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
|
2151
|
+
if (!this.contentVisible) {
|
2152
|
+
return;
|
2153
|
+
}
|
2154
|
+
|
2034
2155
|
this.ctx.fillRect(0, 0, 1, 1);
|
2035
2156
|
},
|
2036
|
-
paintXObject: function CanvasGraphics_paintXObject() {
|
2037
|
-
(0, _util.warn)('Unsupported \'paintXObject\' command.');
|
2038
|
-
},
|
2039
2157
|
markPoint: function CanvasGraphics_markPoint(tag) {},
|
2040
2158
|
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
|
2041
|
-
beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
|
2042
|
-
|
2043
|
-
|
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
|
+
},
|
2044
2181
|
beginCompat: function CanvasGraphics_beginCompat() {},
|
2045
2182
|
endCompat: function CanvasGraphics_endCompat() {},
|
2046
2183
|
consumePath: function CanvasGraphics_consumePath() {
|
@@ -2048,7 +2185,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2048
2185
|
|
2049
2186
|
if (this.pendingClip) {
|
2050
2187
|
if (this.pendingClip === EO_CLIP) {
|
2051
|
-
ctx.clip(
|
2188
|
+
ctx.clip("evenodd");
|
2052
2189
|
} else {
|
2053
2190
|
ctx.clip();
|
2054
2191
|
}
|
@@ -2058,17 +2195,28 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2058
2195
|
|
2059
2196
|
ctx.beginPath();
|
2060
2197
|
},
|
2061
|
-
|
2198
|
+
|
2199
|
+
getSinglePixelWidth(scale) {
|
2062
2200
|
if (this._cachedGetSinglePixelWidth === null) {
|
2063
|
-
|
2201
|
+
const inverse = this.ctx.mozCurrentTransformInverse;
|
2064
2202
|
this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
|
2065
2203
|
}
|
2066
2204
|
|
2067
2205
|
return this._cachedGetSinglePixelWidth;
|
2068
2206
|
},
|
2207
|
+
|
2069
2208
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
2070
2209
|
var transform = this.ctx.mozCurrentTransform;
|
2071
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;
|
2072
2220
|
}
|
2073
2221
|
};
|
2074
2222
|
|