pdfjs-dist 2.3.200 → 2.4.456
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 +6499 -17971
- 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 +19303 -29896
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -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/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1333 -4839
- 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 +683 -1066
- 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 +196 -193
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +441 -569
- package/lib/core/cmap.js +220 -279
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +59 -80
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +564 -673
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +983 -889
- package/lib/core/font_renderer.js +128 -171
- package/lib/core/fonts.js +451 -400
- package/lib/core/function.js +289 -285
- package/lib/core/glyphlist.js +4527 -4527
- package/lib/core/image.js +138 -117
- package/lib/core/image_utils.js +46 -63
- package/lib/core/jbig2.js +324 -332
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +133 -24
- package/lib/core/jpg.js +238 -210
- package/lib/core/jpx.js +158 -157
- 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 +1111 -1302
- package/lib/core/operator_list.js +55 -42
- package/lib/core/parser.js +956 -987
- package/lib/core/pattern.js +69 -69
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +45 -77
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +83 -77
- package/lib/core/type1_parser.js +78 -68
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +148 -196
- package/lib/core/worker_stream.js +101 -210
- package/lib/display/annotation_layer.js +733 -1155
- package/lib/display/api.js +1539 -1928
- package/lib/display/api_compatibility.js +10 -8
- package/lib/display/canvas.js +159 -158
- package/lib/display/content_disposition.js +36 -55
- package/lib/display/display_utils.js +298 -551
- package/lib/display/fetch_stream.js +181 -305
- package/lib/display/font_loader.js +273 -416
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +376 -511
- package/lib/display/network_utils.js +20 -19
- package/lib/display/node_stream.js +276 -460
- package/lib/display/pattern_helper.js +76 -44
- package/lib/display/svg.js +1137 -1405
- package/lib/display/text_layer.js +75 -82
- package/lib/display/transport_stream.js +236 -374
- 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 +22 -21
- package/lib/pdf.worker.js +5 -5
- package/lib/shared/compatibility.js +2 -251
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +222 -194
- package/lib/shared/util.js +269 -405
- package/lib/test/unit/annotation_spec.js +1089 -1014
- package/lib/test/unit/api_spec.js +617 -544
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +63 -62
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +84 -86
- package/lib/test/unit/colorspace_spec.js +154 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +22 -24
- package/lib/test/unit/display_svg_spec.js +35 -36
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +16 -16
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +81 -95
- package/lib/test/unit/fetch_stream_spec.js +30 -30
- 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 +172 -162
- package/lib/test/unit/metadata_spec.js +69 -69
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +12 -12
- package/lib/test/unit/network_utils_spec.js +152 -152
- package/lib/test/unit/node_stream_spec.js +74 -90
- package/lib/test/unit/parser_spec.js +107 -113
- 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 +117 -115
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +119 -285
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +41 -41
- package/lib/test/unit/ui_utils_spec.js +318 -426
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +122 -143
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1166 -1196
- package/lib/web/app_options.js +61 -77
- package/lib/web/base_viewer.js +804 -850
- package/lib/web/chromecom.js +164 -249
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +38 -57
- package/lib/web/firefox_print_service.js +35 -30
- package/lib/web/firefoxcom.js +175 -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 -258
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +105 -130
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +227 -376
- package/lib/web/pdf_find_bar.js +137 -171
- package/lib/web/pdf_find_controller.js +492 -549
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +395 -406
- package/lib/web/pdf_link_service.js +302 -349
- package/lib/web/pdf_outline_viewer.js +148 -209
- package/lib/web/pdf_page_view.js +449 -507
- package/lib/web/pdf_presentation_mode.js +304 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +264 -304
- 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 +276 -297
- package/lib/web/pdf_thumbnail_viewer.js +186 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +66 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -317
- package/lib/web/toolbar.js +216 -211
- package/lib/web/ui_utils.js +303 -404
- package/lib/web/view_history.js +49 -222
- package/lib/web/viewer_compatibility.js +7 -5
- package/package.json +2 -9
- package/web/pdf_viewer.css +25 -18
- package/web/pdf_viewer.js +3481 -4764
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/lib/shared/streams_polyfill.js +0 -43
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,7 +324,7 @@ 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);
|
@@ -369,8 +365,8 @@ 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;
|
@@ -426,7 +422,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
426
422
|
}
|
427
423
|
|
428
424
|
function putBinaryImageData(ctx, imgData) {
|
429
|
-
if (typeof ImageData !==
|
425
|
+
if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
|
430
426
|
ctx.putImageData(imgData, 0, 0);
|
431
427
|
return;
|
432
428
|
}
|
@@ -448,8 +444,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
448
444
|
var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
|
449
445
|
var dest32DataLength = dest32.length;
|
450
446
|
var fullSrcDiff = width + 7 >> 3;
|
451
|
-
var white =
|
452
|
-
var black = IsLittleEndianCached.value ?
|
447
|
+
var white = 0xffffffff;
|
448
|
+
var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
|
453
449
|
|
454
450
|
for (i = 0; i < totalChunks; i++) {
|
455
451
|
thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
@@ -530,7 +526,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
530
526
|
ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
|
531
527
|
}
|
532
528
|
} else {
|
533
|
-
throw new Error(
|
529
|
+
throw new Error(`bad image kind: ${imgData.kind}`);
|
534
530
|
}
|
535
531
|
}
|
536
532
|
|
@@ -569,7 +565,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
569
565
|
}
|
570
566
|
|
571
567
|
function copyCtxState(sourceCtx, destCtx) {
|
572
|
-
var properties = [
|
568
|
+
var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
|
573
569
|
|
574
570
|
for (var i = 0, ii = properties.length; i < ii; i++) {
|
575
571
|
var property = properties[i];
|
@@ -586,16 +582,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
586
582
|
}
|
587
583
|
|
588
584
|
function resetCtxToDefault(ctx) {
|
589
|
-
ctx.strokeStyle =
|
590
|
-
ctx.fillStyle =
|
591
|
-
ctx.fillRule =
|
585
|
+
ctx.strokeStyle = "#000000";
|
586
|
+
ctx.fillStyle = "#000000";
|
587
|
+
ctx.fillRule = "nonzero";
|
592
588
|
ctx.globalAlpha = 1;
|
593
589
|
ctx.lineWidth = 1;
|
594
|
-
ctx.lineCap =
|
595
|
-
ctx.lineJoin =
|
590
|
+
ctx.lineCap = "butt";
|
591
|
+
ctx.lineJoin = "miter";
|
596
592
|
ctx.miterLimit = 10;
|
597
|
-
ctx.globalCompositeOperation =
|
598
|
-
ctx.font =
|
593
|
+
ctx.globalCompositeOperation = "source-over";
|
594
|
+
ctx.font = "10px sans-serif";
|
599
595
|
|
600
596
|
if (ctx.setLineDash !== undefined) {
|
601
597
|
ctx.setLineDash([]);
|
@@ -648,7 +644,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
648
644
|
var b0 = hasBackdrop ? backdrop[2] : 0;
|
649
645
|
var composeFn;
|
650
646
|
|
651
|
-
if (subtype ===
|
647
|
+
if (subtype === "Luminosity") {
|
652
648
|
composeFn = composeSMaskLuminosity;
|
653
649
|
} else {
|
654
650
|
composeFn = composeSMaskAlpha;
|
@@ -678,12 +674,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
678
674
|
var backdrop = smask.backdrop || null;
|
679
675
|
|
680
676
|
if (!smask.transferMap && webGLContext.isEnabled) {
|
681
|
-
|
677
|
+
const composed = webGLContext.composeSMask({
|
682
678
|
layer: layerCtx.canvas,
|
683
|
-
mask
|
679
|
+
mask,
|
684
680
|
properties: {
|
685
681
|
subtype: smask.subtype,
|
686
|
-
backdrop
|
682
|
+
backdrop
|
687
683
|
}
|
688
684
|
});
|
689
685
|
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
@@ -695,27 +691,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
695
691
|
ctx.drawImage(mask, 0, 0);
|
696
692
|
}
|
697
693
|
|
698
|
-
var LINE_CAP_STYLES = [
|
699
|
-
var LINE_JOIN_STYLES = [
|
694
|
+
var LINE_CAP_STYLES = ["butt", "round", "square"];
|
695
|
+
var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
|
700
696
|
var NORMAL_CLIP = {};
|
701
697
|
var EO_CLIP = {};
|
702
698
|
CanvasGraphics.prototype = {
|
703
|
-
beginDrawing
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
background = _ref$background === void 0 ? null : _ref$background;
|
699
|
+
beginDrawing({
|
700
|
+
transform,
|
701
|
+
viewport,
|
702
|
+
transparency = false,
|
703
|
+
background = null
|
704
|
+
}) {
|
710
705
|
var width = this.ctx.canvas.width;
|
711
706
|
var height = this.ctx.canvas.height;
|
712
707
|
this.ctx.save();
|
713
|
-
this.ctx.fillStyle = background ||
|
708
|
+
this.ctx.fillStyle = background || "rgb(255, 255, 255)";
|
714
709
|
this.ctx.fillRect(0, 0, width, height);
|
715
710
|
this.ctx.restore();
|
716
711
|
|
717
712
|
if (transparency) {
|
718
|
-
var transparentCanvas = this.cachedCanvases.getCanvas(
|
713
|
+
var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
|
719
714
|
this.compositeCtx = this.ctx;
|
720
715
|
this.transparentCanvas = transparentCanvas.canvas;
|
721
716
|
this.ctx = transparentCanvas.context;
|
@@ -737,6 +732,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
737
732
|
this.imageLayer.beginLayout();
|
738
733
|
}
|
739
734
|
},
|
735
|
+
|
740
736
|
executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
|
741
737
|
var argsArray = operatorList.argsArray;
|
742
738
|
var fnArray = operatorList.fnArray;
|
@@ -747,7 +743,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
747
743
|
return i;
|
748
744
|
}
|
749
745
|
|
750
|
-
var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback ===
|
746
|
+
var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
|
751
747
|
var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
|
752
748
|
var steps = 0;
|
753
749
|
var commonObjs = this.commonObjs;
|
@@ -765,32 +761,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
765
761
|
if (fnId !== _util.OPS.dependency) {
|
766
762
|
this[fnId].apply(this, argsArray[i]);
|
767
763
|
} 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
|
-
}
|
764
|
+
for (const depObjId of argsArray[i]) {
|
765
|
+
const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
|
766
|
+
|
767
|
+
if (!objsPool.has(depObjId)) {
|
768
|
+
objsPool.get(depObjId, continueCallback);
|
769
|
+
return i;
|
794
770
|
}
|
795
771
|
}
|
796
772
|
}
|
@@ -855,8 +831,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
855
831
|
ctx.lineDashOffset = dashPhase;
|
856
832
|
}
|
857
833
|
},
|
858
|
-
|
859
|
-
|
834
|
+
|
835
|
+
setRenderingIntent(intent) {},
|
836
|
+
|
837
|
+
setFlatness(flatness) {},
|
838
|
+
|
860
839
|
setGState: function CanvasGraphics_setGState(states) {
|
861
840
|
for (var i = 0, ii = states.length; i < ii; i++) {
|
862
841
|
var state = states[i];
|
@@ -864,52 +843,52 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
864
843
|
var value = state[1];
|
865
844
|
|
866
845
|
switch (key) {
|
867
|
-
case
|
846
|
+
case "LW":
|
868
847
|
this.setLineWidth(value);
|
869
848
|
break;
|
870
849
|
|
871
|
-
case
|
850
|
+
case "LC":
|
872
851
|
this.setLineCap(value);
|
873
852
|
break;
|
874
853
|
|
875
|
-
case
|
854
|
+
case "LJ":
|
876
855
|
this.setLineJoin(value);
|
877
856
|
break;
|
878
857
|
|
879
|
-
case
|
858
|
+
case "ML":
|
880
859
|
this.setMiterLimit(value);
|
881
860
|
break;
|
882
861
|
|
883
|
-
case
|
862
|
+
case "D":
|
884
863
|
this.setDash(value[0], value[1]);
|
885
864
|
break;
|
886
865
|
|
887
|
-
case
|
866
|
+
case "RI":
|
888
867
|
this.setRenderingIntent(value);
|
889
868
|
break;
|
890
869
|
|
891
|
-
case
|
870
|
+
case "FL":
|
892
871
|
this.setFlatness(value);
|
893
872
|
break;
|
894
873
|
|
895
|
-
case
|
874
|
+
case "Font":
|
896
875
|
this.setFont(value[0], value[1]);
|
897
876
|
break;
|
898
877
|
|
899
|
-
case
|
878
|
+
case "CA":
|
900
879
|
this.current.strokeAlpha = state[1];
|
901
880
|
break;
|
902
881
|
|
903
|
-
case
|
882
|
+
case "ca":
|
904
883
|
this.current.fillAlpha = state[1];
|
905
884
|
this.ctx.globalAlpha = state[1];
|
906
885
|
break;
|
907
886
|
|
908
|
-
case
|
887
|
+
case "BM":
|
909
888
|
this.ctx.globalCompositeOperation = value;
|
910
889
|
break;
|
911
890
|
|
912
|
-
case
|
891
|
+
case "SMask":
|
913
892
|
if (this.current.activeSMask) {
|
914
893
|
if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
|
915
894
|
this.suspendSMaskGroup();
|
@@ -933,7 +912,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
933
912
|
var activeSMask = this.current.activeSMask;
|
934
913
|
var drawnWidth = activeSMask.canvas.width;
|
935
914
|
var drawnHeight = activeSMask.canvas.height;
|
936
|
-
var cacheId =
|
915
|
+
var cacheId = "smaskGroupAt" + this.groupLevel;
|
937
916
|
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
938
917
|
var currentCtx = this.ctx;
|
939
918
|
var currentTransform = currentCtx.mozCurrentTransform;
|
@@ -945,7 +924,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
945
924
|
activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
|
946
925
|
copyCtxState(currentCtx, groupCtx);
|
947
926
|
this.ctx = groupCtx;
|
948
|
-
this.setGState([[
|
927
|
+
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
949
928
|
this.groupStack.push(currentCtx);
|
950
929
|
this.groupLevel++;
|
951
930
|
},
|
@@ -1090,16 +1069,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1090
1069
|
this.ctx.closePath();
|
1091
1070
|
},
|
1092
1071
|
stroke: function CanvasGraphics_stroke(consumePath) {
|
1093
|
-
consumePath = typeof consumePath !==
|
1072
|
+
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
1094
1073
|
var ctx = this.ctx;
|
1095
1074
|
var strokeColor = this.current.strokeColor;
|
1096
1075
|
ctx.globalAlpha = this.current.strokeAlpha;
|
1097
1076
|
|
1098
|
-
if (strokeColor && strokeColor.hasOwnProperty(
|
1077
|
+
if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
|
1099
1078
|
ctx.save();
|
1100
|
-
|
1079
|
+
const transform = ctx.mozCurrentTransform;
|
1101
1080
|
|
1102
|
-
|
1081
|
+
const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
|
1103
1082
|
|
1104
1083
|
ctx.strokeStyle = strokeColor.getPattern(ctx, this);
|
1105
1084
|
ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
|
@@ -1121,7 +1100,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1121
1100
|
this.stroke();
|
1122
1101
|
},
|
1123
1102
|
fill: function CanvasGraphics_fill(consumePath) {
|
1124
|
-
consumePath = typeof consumePath !==
|
1103
|
+
consumePath = typeof consumePath !== "undefined" ? consumePath : true;
|
1125
1104
|
var ctx = this.ctx;
|
1126
1105
|
var fillColor = this.current.fillColor;
|
1127
1106
|
var isPatternFill = this.current.patternFill;
|
@@ -1139,7 +1118,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1139
1118
|
}
|
1140
1119
|
|
1141
1120
|
if (this.pendingEOFill) {
|
1142
|
-
ctx.fill(
|
1121
|
+
ctx.fill("evenodd");
|
1143
1122
|
this.pendingEOFill = false;
|
1144
1123
|
} else {
|
1145
1124
|
ctx.fill();
|
@@ -1231,13 +1210,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1231
1210
|
var current = this.current;
|
1232
1211
|
|
1233
1212
|
if (!fontObj) {
|
1234
|
-
throw new Error(
|
1213
|
+
throw new Error(`Can't find font for ${fontRefName}`);
|
1235
1214
|
}
|
1236
1215
|
|
1237
1216
|
current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
|
1238
1217
|
|
1239
1218
|
if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
|
1240
|
-
(0, _util.warn)(
|
1219
|
+
(0, _util.warn)("Invalid font matrix for font " + fontRefName);
|
1241
1220
|
}
|
1242
1221
|
|
1243
1222
|
if (size < 0) {
|
@@ -1254,13 +1233,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1254
1233
|
return;
|
1255
1234
|
}
|
1256
1235
|
|
1257
|
-
var name = fontObj.loadedName ||
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1236
|
+
var name = fontObj.loadedName || "sans-serif";
|
1237
|
+
let bold = "normal";
|
1238
|
+
|
1239
|
+
if (fontObj.black) {
|
1240
|
+
bold = "900";
|
1241
|
+
} else if (fontObj.bold) {
|
1242
|
+
bold = "bold";
|
1243
|
+
}
|
1244
|
+
|
1245
|
+
var italic = fontObj.italic ? "italic" : "normal";
|
1246
|
+
var typeface = `"${name}", ${fontObj.fallbackName}`;
|
1247
|
+
let browserFontSize = size;
|
1248
|
+
|
1249
|
+
if (size < MIN_FONT_SIZE) {
|
1250
|
+
browserFontSize = MIN_FONT_SIZE;
|
1251
|
+
} else if (size > MAX_FONT_SIZE) {
|
1252
|
+
browserFontSize = MAX_FONT_SIZE;
|
1253
|
+
}
|
1254
|
+
|
1262
1255
|
this.current.fontSizeScale = size / browserFontSize;
|
1263
|
-
this.ctx.font =
|
1256
|
+
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
1264
1257
|
},
|
1265
1258
|
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
|
1266
1259
|
this.current.textRenderingMode = mode;
|
@@ -1285,7 +1278,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1285
1278
|
nextLine: function CanvasGraphics_nextLine() {
|
1286
1279
|
this.moveText(0, this.current.leading);
|
1287
1280
|
},
|
1288
|
-
|
1281
|
+
|
1282
|
+
paintChar(character, x, y, patternTransform) {
|
1289
1283
|
var ctx = this.ctx;
|
1290
1284
|
var current = this.current;
|
1291
1285
|
var font = current.font;
|
@@ -1293,7 +1287,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1293
1287
|
var fontSize = current.fontSize / current.fontSizeScale;
|
1294
1288
|
var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
|
1295
1289
|
var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
|
1296
|
-
|
1290
|
+
const patternFill = current.patternFill && font.data;
|
1297
1291
|
var addToPath;
|
1298
1292
|
|
1299
1293
|
if (font.disableFontFace || isAddToPathSet || patternFill) {
|
@@ -1333,20 +1327,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1333
1327
|
var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
|
1334
1328
|
paths.push({
|
1335
1329
|
transform: ctx.mozCurrentTransform,
|
1336
|
-
x
|
1337
|
-
y
|
1338
|
-
fontSize
|
1339
|
-
addToPath
|
1330
|
+
x,
|
1331
|
+
y,
|
1332
|
+
fontSize,
|
1333
|
+
addToPath
|
1340
1334
|
});
|
1341
1335
|
}
|
1342
1336
|
},
|
1343
1337
|
|
1344
1338
|
get isFontSubpixelAAEnabled() {
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1339
|
+
const {
|
1340
|
+
context: ctx
|
1341
|
+
} = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
|
1348
1342
|
ctx.scale(1.5, 1);
|
1349
|
-
ctx.fillText(
|
1343
|
+
ctx.fillText("I", 0, 10);
|
1350
1344
|
var data = ctx.getImageData(0, 0, 10, 10).data;
|
1351
1345
|
var enabled = false;
|
1352
1346
|
|
@@ -1357,7 +1351,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1357
1351
|
}
|
1358
1352
|
}
|
1359
1353
|
|
1360
|
-
return (0, _util.shadow)(this,
|
1354
|
+
return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
|
1361
1355
|
},
|
1362
1356
|
|
1363
1357
|
showText: function CanvasGraphics_showText(glyphs) {
|
@@ -1387,11 +1381,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1387
1381
|
var widthAdvanceScale = fontSize * current.fontMatrix[0];
|
1388
1382
|
var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
|
1389
1383
|
ctx.save();
|
1390
|
-
|
1384
|
+
let patternTransform;
|
1391
1385
|
|
1392
1386
|
if (current.patternFill) {
|
1393
1387
|
ctx.save();
|
1394
|
-
|
1388
|
+
const pattern = current.fillColor.getPattern(ctx, this);
|
1395
1389
|
patternTransform = ctx.mozCurrentTransform;
|
1396
1390
|
ctx.restore();
|
1397
1391
|
ctx.fillStyle = pattern;
|
@@ -1486,7 +1480,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1486
1480
|
}
|
1487
1481
|
}
|
1488
1482
|
|
1489
|
-
var charWidth
|
1483
|
+
var charWidth;
|
1484
|
+
|
1485
|
+
if (vertical) {
|
1486
|
+
charWidth = width * widthAdvanceScale - spacing * fontDirection;
|
1487
|
+
} else {
|
1488
|
+
charWidth = width * widthAdvanceScale + spacing * fontDirection;
|
1489
|
+
}
|
1490
|
+
|
1490
1491
|
x += charWidth;
|
1491
1492
|
|
1492
1493
|
if (restoreNeeded) {
|
@@ -1495,7 +1496,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1495
1496
|
}
|
1496
1497
|
|
1497
1498
|
if (vertical) {
|
1498
|
-
current.y -= x
|
1499
|
+
current.y -= x;
|
1499
1500
|
} else {
|
1500
1501
|
current.x += x * textHScale;
|
1501
1502
|
}
|
@@ -1541,7 +1542,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1541
1542
|
var operatorList = font.charProcOperatorList[glyph.operatorListId];
|
1542
1543
|
|
1543
1544
|
if (!operatorList) {
|
1544
|
-
(0, _util.warn)(
|
1545
|
+
(0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
|
1545
1546
|
continue;
|
1546
1547
|
}
|
1547
1548
|
|
@@ -1569,16 +1570,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1569
1570
|
this.endPath();
|
1570
1571
|
},
|
1571
1572
|
getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
|
1572
|
-
var _this = this;
|
1573
|
-
|
1574
1573
|
var pattern;
|
1575
1574
|
|
1576
|
-
if (IR[0] ===
|
1575
|
+
if (IR[0] === "TilingPattern") {
|
1577
1576
|
var color = IR[1];
|
1578
1577
|
var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
|
1579
1578
|
var canvasGraphicsFactory = {
|
1580
|
-
createCanvasGraphics:
|
1581
|
-
return new CanvasGraphics(ctx,
|
1579
|
+
createCanvasGraphics: ctx => {
|
1580
|
+
return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext);
|
1582
1581
|
}
|
1583
1582
|
};
|
1584
1583
|
pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
|
@@ -1640,10 +1639,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1640
1639
|
this.restore();
|
1641
1640
|
},
|
1642
1641
|
beginInlineImage: function CanvasGraphics_beginInlineImage() {
|
1643
|
-
(0, _util.unreachable)(
|
1642
|
+
(0, _util.unreachable)("Should not call beginInlineImage");
|
1644
1643
|
},
|
1645
1644
|
beginImageData: function CanvasGraphics_beginImageData() {
|
1646
|
-
(0, _util.unreachable)(
|
1645
|
+
(0, _util.unreachable)("Should not call beginImageData");
|
1647
1646
|
},
|
1648
1647
|
paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
|
1649
1648
|
this.save();
|
@@ -1672,11 +1671,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1672
1671
|
var currentCtx = this.ctx;
|
1673
1672
|
|
1674
1673
|
if (!group.isolated) {
|
1675
|
-
(0, _util.info)(
|
1674
|
+
(0, _util.info)("TODO: Support non-isolated groups.");
|
1676
1675
|
}
|
1677
1676
|
|
1678
1677
|
if (group.knockout) {
|
1679
|
-
(0, _util.warn)(
|
1678
|
+
(0, _util.warn)("Knockout groups not supported.");
|
1680
1679
|
}
|
1681
1680
|
|
1682
1681
|
var currentTransform = currentCtx.mozCurrentTransform;
|
@@ -1686,7 +1685,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1686
1685
|
}
|
1687
1686
|
|
1688
1687
|
if (!group.bbox) {
|
1689
|
-
throw new Error(
|
1688
|
+
throw new Error("Bounding box is required.");
|
1690
1689
|
}
|
1691
1690
|
|
1692
1691
|
var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
|
@@ -1710,10 +1709,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1710
1709
|
drawnHeight = MAX_GROUP_SIZE;
|
1711
1710
|
}
|
1712
1711
|
|
1713
|
-
var cacheId =
|
1712
|
+
var cacheId = "groupAt" + this.groupLevel;
|
1714
1713
|
|
1715
1714
|
if (group.smask) {
|
1716
|
-
cacheId +=
|
1715
|
+
cacheId += "_smask_" + this.smaskCounter++ % 2;
|
1717
1716
|
}
|
1718
1717
|
|
1719
1718
|
var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
|
@@ -1726,10 +1725,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1726
1725
|
this.smaskStack.push({
|
1727
1726
|
canvas: scratchCanvas.canvas,
|
1728
1727
|
context: groupCtx,
|
1729
|
-
offsetX
|
1730
|
-
offsetY
|
1731
|
-
scaleX
|
1732
|
-
scaleY
|
1728
|
+
offsetX,
|
1729
|
+
offsetY,
|
1730
|
+
scaleX,
|
1731
|
+
scaleY,
|
1733
1732
|
subtype: group.smask.subtype,
|
1734
1733
|
backdrop: group.smask.backdrop,
|
1735
1734
|
transferMap: group.smask.transferMap || null,
|
@@ -1743,7 +1742,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1743
1742
|
|
1744
1743
|
copyCtxState(currentCtx, groupCtx);
|
1745
1744
|
this.ctx = groupCtx;
|
1746
|
-
this.setGState([[
|
1745
|
+
this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
|
1747
1746
|
this.groupStack.push(currentCtx);
|
1748
1747
|
this.groupLevel++;
|
1749
1748
|
this.current.activeSMask = null;
|
@@ -1797,10 +1796,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1797
1796
|
this.restore();
|
1798
1797
|
},
|
1799
1798
|
paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
|
1800
|
-
|
1799
|
+
const domImage = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1801
1800
|
|
1802
1801
|
if (!domImage) {
|
1803
|
-
(0, _util.warn)(
|
1802
|
+
(0, _util.warn)("Dependent image isn't ready yet");
|
1804
1803
|
return;
|
1805
1804
|
}
|
1806
1805
|
|
@@ -1813,7 +1812,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1813
1812
|
var currentTransform = ctx.mozCurrentTransformInverse;
|
1814
1813
|
var position = this.getCanvasPosition(0, 0);
|
1815
1814
|
this.imageLayer.appendImage({
|
1816
|
-
objId
|
1815
|
+
objId,
|
1817
1816
|
left: position[0],
|
1818
1817
|
top: position[1],
|
1819
1818
|
width: w / currentTransform[0],
|
@@ -1835,8 +1834,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1835
1834
|
if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
|
1836
1835
|
glyph.compiled = compileType3Glyph({
|
1837
1836
|
data: img.data,
|
1838
|
-
width
|
1839
|
-
height
|
1837
|
+
width,
|
1838
|
+
height
|
1840
1839
|
});
|
1841
1840
|
} else {
|
1842
1841
|
glyph.compiled = null;
|
@@ -1848,11 +1847,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1848
1847
|
return;
|
1849
1848
|
}
|
1850
1849
|
|
1851
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1850
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1852
1851
|
var maskCtx = maskCanvas.context;
|
1853
1852
|
maskCtx.save();
|
1854
1853
|
putBinaryImageMask(maskCtx, img);
|
1855
|
-
maskCtx.globalCompositeOperation =
|
1854
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1856
1855
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1857
1856
|
maskCtx.fillRect(0, 0, width, height);
|
1858
1857
|
maskCtx.restore();
|
@@ -1863,11 +1862,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1863
1862
|
var height = imgData.height;
|
1864
1863
|
var fillColor = this.current.fillColor;
|
1865
1864
|
var isPatternFill = this.current.patternFill;
|
1866
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1865
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1867
1866
|
var maskCtx = maskCanvas.context;
|
1868
1867
|
maskCtx.save();
|
1869
1868
|
putBinaryImageMask(maskCtx, imgData);
|
1870
|
-
maskCtx.globalCompositeOperation =
|
1869
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1871
1870
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1872
1871
|
maskCtx.fillRect(0, 0, width, height);
|
1873
1872
|
maskCtx.restore();
|
@@ -1890,11 +1889,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1890
1889
|
var image = images[i];
|
1891
1890
|
var width = image.width,
|
1892
1891
|
height = image.height;
|
1893
|
-
var maskCanvas = this.cachedCanvases.getCanvas(
|
1892
|
+
var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
|
1894
1893
|
var maskCtx = maskCanvas.context;
|
1895
1894
|
maskCtx.save();
|
1896
1895
|
putBinaryImageMask(maskCtx, image);
|
1897
|
-
maskCtx.globalCompositeOperation =
|
1896
|
+
maskCtx.globalCompositeOperation = "source-in";
|
1898
1897
|
maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
|
1899
1898
|
maskCtx.fillRect(0, 0, width, height);
|
1900
1899
|
maskCtx.restore();
|
@@ -1906,20 +1905,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1906
1905
|
}
|
1907
1906
|
},
|
1908
1907
|
paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
|
1909
|
-
|
1908
|
+
const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1910
1909
|
|
1911
1910
|
if (!imgData) {
|
1912
|
-
(0, _util.warn)(
|
1911
|
+
(0, _util.warn)("Dependent image isn't ready yet");
|
1913
1912
|
return;
|
1914
1913
|
}
|
1915
1914
|
|
1916
1915
|
this.paintInlineImageXObject(imgData);
|
1917
1916
|
},
|
1918
1917
|
paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
|
1919
|
-
|
1918
|
+
const imgData = this.processingType3 ? this.commonObjs.get(objId) : this.objs.get(objId);
|
1920
1919
|
|
1921
1920
|
if (!imgData) {
|
1922
|
-
(0, _util.warn)(
|
1921
|
+
(0, _util.warn)("Dependent image isn't ready yet");
|
1923
1922
|
return;
|
1924
1923
|
}
|
1925
1924
|
|
@@ -1954,10 +1953,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1954
1953
|
var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
|
1955
1954
|
var imgToPaint, tmpCanvas;
|
1956
1955
|
|
1957
|
-
if (typeof HTMLElement ===
|
1956
|
+
if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
|
1958
1957
|
imgToPaint = imgData;
|
1959
1958
|
} else {
|
1960
|
-
tmpCanvas = this.cachedCanvases.getCanvas(
|
1959
|
+
tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
|
1961
1960
|
var tmpCtx = tmpCanvas.context;
|
1962
1961
|
putBinaryImageData(tmpCtx, imgData);
|
1963
1962
|
imgToPaint = tmpCanvas.canvas;
|
@@ -1965,7 +1964,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1965
1964
|
|
1966
1965
|
var paintWidth = width,
|
1967
1966
|
paintHeight = height;
|
1968
|
-
var tmpCanvasId =
|
1967
|
+
var tmpCanvasId = "prescale1";
|
1969
1968
|
|
1970
1969
|
while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
|
1971
1970
|
var newWidth = paintWidth,
|
@@ -1988,7 +1987,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1988
1987
|
imgToPaint = tmpCanvas.canvas;
|
1989
1988
|
paintWidth = newWidth;
|
1990
1989
|
paintHeight = newHeight;
|
1991
|
-
tmpCanvasId = tmpCanvasId ===
|
1990
|
+
tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
|
1992
1991
|
}
|
1993
1992
|
|
1994
1993
|
ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
|
@@ -1996,7 +1995,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
1996
1995
|
if (this.imageLayer) {
|
1997
1996
|
var position = this.getCanvasPosition(0, -height);
|
1998
1997
|
this.imageLayer.appendImage({
|
1999
|
-
imgData
|
1998
|
+
imgData,
|
2000
1999
|
left: position[0],
|
2001
2000
|
top: position[1],
|
2002
2001
|
width: width / currentTransform[0],
|
@@ -2010,7 +2009,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2010
2009
|
var ctx = this.ctx;
|
2011
2010
|
var w = imgData.width;
|
2012
2011
|
var h = imgData.height;
|
2013
|
-
var tmpCanvas = this.cachedCanvases.getCanvas(
|
2012
|
+
var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
|
2014
2013
|
var tmpCtx = tmpCanvas.context;
|
2015
2014
|
putBinaryImageData(tmpCtx, imgData);
|
2016
2015
|
|
@@ -2024,7 +2023,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2024
2023
|
if (this.imageLayer) {
|
2025
2024
|
var position = this.getCanvasPosition(entry.x, entry.y);
|
2026
2025
|
this.imageLayer.appendImage({
|
2027
|
-
imgData
|
2026
|
+
imgData,
|
2028
2027
|
left: position[0],
|
2029
2028
|
top: position[1],
|
2030
2029
|
width: w,
|
@@ -2039,7 +2038,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2039
2038
|
this.ctx.fillRect(0, 0, 1, 1);
|
2040
2039
|
},
|
2041
2040
|
paintXObject: function CanvasGraphics_paintXObject() {
|
2042
|
-
(0, _util.warn)(
|
2041
|
+
(0, _util.warn)("Unsupported 'paintXObject' command.");
|
2043
2042
|
},
|
2044
2043
|
markPoint: function CanvasGraphics_markPoint(tag) {},
|
2045
2044
|
markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
|
@@ -2053,7 +2052,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2053
2052
|
|
2054
2053
|
if (this.pendingClip) {
|
2055
2054
|
if (this.pendingClip === EO_CLIP) {
|
2056
|
-
ctx.clip(
|
2055
|
+
ctx.clip("evenodd");
|
2057
2056
|
} else {
|
2058
2057
|
ctx.clip();
|
2059
2058
|
}
|
@@ -2063,14 +2062,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|
2063
2062
|
|
2064
2063
|
ctx.beginPath();
|
2065
2064
|
},
|
2066
|
-
|
2065
|
+
|
2066
|
+
getSinglePixelWidth(scale) {
|
2067
2067
|
if (this._cachedGetSinglePixelWidth === null) {
|
2068
|
-
|
2068
|
+
const inverse = this.ctx.mozCurrentTransformInverse;
|
2069
2069
|
this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
|
2070
2070
|
}
|
2071
2071
|
|
2072
2072
|
return this._cachedGetSinglePixelWidth;
|
2073
2073
|
},
|
2074
|
+
|
2074
2075
|
getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
|
2075
2076
|
var transform = this.ctx.mozCurrentTransform;
|
2076
2077
|
return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];
|