pdfjs-dist 2.1.266 → 2.5.207

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.

Files changed (191) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8382 -18492
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +58239 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -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 2018 Mozilla Foundation
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, 'mozCurrentTransform', {
52
+ Object.defineProperty(ctx, "mozCurrentTransform", {
59
53
  get: function getCurrentTransform() {
60
54
  return this._transformMatrix;
61
55
  }
62
56
  });
63
- Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
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
- clear: function clear() {
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
  }();
@@ -318,25 +314,28 @@ function compileType3Glyph(imgData) {
318
314
 
319
315
  coords.push(p % width1);
320
316
  coords.push(p / width1 | 0);
321
- --count;
317
+
318
+ if (!points[p]) {
319
+ --count;
320
+ }
322
321
  } while (p0 !== p);
323
322
 
324
323
  outlines.push(coords);
325
324
  --i;
326
325
  }
327
326
 
328
- var drawOutline = function drawOutline(c) {
327
+ var drawOutline = function (c) {
329
328
  c.save();
330
329
  c.scale(1 / width, -1 / height);
331
330
  c.translate(0, -height);
332
331
  c.beginPath();
333
332
 
334
- for (var i = 0, ii = outlines.length; i < ii; i++) {
335
- var o = outlines[i];
333
+ for (let k = 0, kk = outlines.length; k < kk; k++) {
334
+ var o = outlines[k];
336
335
  c.moveTo(o[0], o[1]);
337
336
 
338
- for (var j = 2, jj = o.length; j < jj; j += 2) {
339
- c.lineTo(o[j], o[j + 1]);
337
+ for (let l = 2, ll = o.length; l < ll; l += 2) {
338
+ c.lineTo(o[l], o[l + 1]);
340
339
  }
341
340
  }
342
341
 
@@ -366,8 +365,8 @@ var CanvasExtraState = function CanvasExtraStateClosure() {
366
365
  this.textHScale = 1;
367
366
  this.textRenderingMode = _util.TextRenderingMode.FILL;
368
367
  this.textRise = 0;
369
- this.fillColor = '#000000';
370
- this.strokeColor = '#000000';
368
+ this.fillColor = "#000000";
369
+ this.strokeColor = "#000000";
371
370
  this.patternFill = false;
372
371
  this.fillAlpha = 1;
373
372
  this.strokeAlpha = 1;
@@ -423,7 +422,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
423
422
  }
424
423
 
425
424
  function putBinaryImageData(ctx, imgData) {
426
- if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
425
+ if (typeof ImageData !== "undefined" && imgData instanceof ImageData) {
427
426
  ctx.putImageData(imgData, 0, 0);
428
427
  return;
429
428
  }
@@ -445,8 +444,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
445
444
  var dest32 = new Uint32Array(dest.buffer, 0, dest.byteLength >> 2);
446
445
  var dest32DataLength = dest32.length;
447
446
  var fullSrcDiff = width + 7 >> 3;
448
- var white = 0xFFFFFFFF;
449
- var black = IsLittleEndianCached.value ? 0xFF000000 : 0x000000FF;
447
+ var white = 0xffffffff;
448
+ var black = _util.IsLittleEndianCached.value ? 0xff000000 : 0x000000ff;
450
449
 
451
450
  for (i = 0; i < totalChunks; i++) {
452
451
  thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
@@ -527,7 +526,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
527
526
  ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
528
527
  }
529
528
  } else {
530
- throw new Error("bad image kind: ".concat(imgData.kind));
529
+ throw new Error(`bad image kind: ${imgData.kind}`);
531
530
  }
532
531
  }
533
532
 
@@ -566,7 +565,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
566
565
  }
567
566
 
568
567
  function copyCtxState(sourceCtx, destCtx) {
569
- var properties = ['strokeStyle', 'fillStyle', 'fillRule', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'miterLimit', 'globalCompositeOperation', 'font'];
568
+ var properties = ["strokeStyle", "fillStyle", "fillRule", "globalAlpha", "lineWidth", "lineCap", "lineJoin", "miterLimit", "globalCompositeOperation", "font"];
570
569
 
571
570
  for (var i = 0, ii = properties.length; i < ii; i++) {
572
571
  var property = properties[i];
@@ -583,16 +582,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
583
582
  }
584
583
 
585
584
  function resetCtxToDefault(ctx) {
586
- ctx.strokeStyle = '#000000';
587
- ctx.fillStyle = '#000000';
588
- ctx.fillRule = 'nonzero';
585
+ ctx.strokeStyle = "#000000";
586
+ ctx.fillStyle = "#000000";
587
+ ctx.fillRule = "nonzero";
589
588
  ctx.globalAlpha = 1;
590
589
  ctx.lineWidth = 1;
591
- ctx.lineCap = 'butt';
592
- ctx.lineJoin = 'miter';
590
+ ctx.lineCap = "butt";
591
+ ctx.lineJoin = "miter";
593
592
  ctx.miterLimit = 10;
594
- ctx.globalCompositeOperation = 'source-over';
595
- ctx.font = '10px sans-serif';
593
+ ctx.globalCompositeOperation = "source-over";
594
+ ctx.font = "10px sans-serif";
596
595
 
597
596
  if (ctx.setLineDash !== undefined) {
598
597
  ctx.setLineDash([]);
@@ -645,7 +644,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
645
644
  var b0 = hasBackdrop ? backdrop[2] : 0;
646
645
  var composeFn;
647
646
 
648
- if (subtype === 'Luminosity') {
647
+ if (subtype === "Luminosity") {
649
648
  composeFn = composeSMaskLuminosity;
650
649
  } else {
651
650
  composeFn = composeSMaskAlpha;
@@ -675,12 +674,12 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
675
674
  var backdrop = smask.backdrop || null;
676
675
 
677
676
  if (!smask.transferMap && webGLContext.isEnabled) {
678
- var composed = webGLContext.composeSMask({
677
+ const composed = webGLContext.composeSMask({
679
678
  layer: layerCtx.canvas,
680
- mask: mask,
679
+ mask,
681
680
  properties: {
682
681
  subtype: smask.subtype,
683
- backdrop: backdrop
682
+ backdrop
684
683
  }
685
684
  });
686
685
  ctx.setTransform(1, 0, 0, 1, 0, 0);
@@ -692,27 +691,26 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
692
691
  ctx.drawImage(mask, 0, 0);
693
692
  }
694
693
 
695
- var LINE_CAP_STYLES = ['butt', 'round', 'square'];
696
- var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
694
+ var LINE_CAP_STYLES = ["butt", "round", "square"];
695
+ var LINE_JOIN_STYLES = ["miter", "round", "bevel"];
697
696
  var NORMAL_CLIP = {};
698
697
  var EO_CLIP = {};
699
698
  CanvasGraphics.prototype = {
700
- beginDrawing: function beginDrawing(_ref) {
701
- var transform = _ref.transform,
702
- viewport = _ref.viewport,
703
- _ref$transparency = _ref.transparency,
704
- transparency = _ref$transparency === void 0 ? false : _ref$transparency,
705
- _ref$background = _ref.background,
706
- background = _ref$background === void 0 ? null : _ref$background;
699
+ beginDrawing({
700
+ transform,
701
+ viewport,
702
+ transparency = false,
703
+ background = null
704
+ }) {
707
705
  var width = this.ctx.canvas.width;
708
706
  var height = this.ctx.canvas.height;
709
707
  this.ctx.save();
710
- this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
708
+ this.ctx.fillStyle = background || "rgb(255, 255, 255)";
711
709
  this.ctx.fillRect(0, 0, width, height);
712
710
  this.ctx.restore();
713
711
 
714
712
  if (transparency) {
715
- var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
713
+ var transparentCanvas = this.cachedCanvases.getCanvas("transparent", width, height, true);
716
714
  this.compositeCtx = this.ctx;
717
715
  this.transparentCanvas = transparentCanvas.canvas;
718
716
  this.ctx = transparentCanvas.context;
@@ -734,6 +732,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
734
732
  this.imageLayer.beginLayout();
735
733
  }
736
734
  },
735
+
737
736
  executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
738
737
  var argsArray = operatorList.argsArray;
739
738
  var fnArray = operatorList.fnArray;
@@ -744,7 +743,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
744
743
  return i;
745
744
  }
746
745
 
747
- var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
746
+ var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === "function";
748
747
  var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
749
748
  var steps = 0;
750
749
  var commonObjs = this.commonObjs;
@@ -762,12 +761,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
762
761
  if (fnId !== _util.OPS.dependency) {
763
762
  this[fnId].apply(this, argsArray[i]);
764
763
  } else {
765
- var deps = argsArray[i];
766
-
767
- for (var n = 0, nn = deps.length; n < nn; n++) {
768
- var depObjId = deps[n];
769
- var common = depObjId[0] === 'g' && depObjId[1] === '_';
770
- var objsPool = common ? commonObjs : objs;
764
+ for (const depObjId of argsArray[i]) {
765
+ const objsPool = depObjId.startsWith("g_") ? commonObjs : objs;
771
766
 
772
767
  if (!objsPool.has(depObjId)) {
773
768
  objsPool.get(depObjId, continueCallback);
@@ -836,8 +831,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
836
831
  ctx.lineDashOffset = dashPhase;
837
832
  }
838
833
  },
839
- setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {},
840
- setFlatness: function CanvasGraphics_setFlatness(flatness) {},
834
+
835
+ setRenderingIntent(intent) {},
836
+
837
+ setFlatness(flatness) {},
838
+
841
839
  setGState: function CanvasGraphics_setGState(states) {
842
840
  for (var i = 0, ii = states.length; i < ii; i++) {
843
841
  var state = states[i];
@@ -845,52 +843,52 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
845
843
  var value = state[1];
846
844
 
847
845
  switch (key) {
848
- case 'LW':
846
+ case "LW":
849
847
  this.setLineWidth(value);
850
848
  break;
851
849
 
852
- case 'LC':
850
+ case "LC":
853
851
  this.setLineCap(value);
854
852
  break;
855
853
 
856
- case 'LJ':
854
+ case "LJ":
857
855
  this.setLineJoin(value);
858
856
  break;
859
857
 
860
- case 'ML':
858
+ case "ML":
861
859
  this.setMiterLimit(value);
862
860
  break;
863
861
 
864
- case 'D':
862
+ case "D":
865
863
  this.setDash(value[0], value[1]);
866
864
  break;
867
865
 
868
- case 'RI':
866
+ case "RI":
869
867
  this.setRenderingIntent(value);
870
868
  break;
871
869
 
872
- case 'FL':
870
+ case "FL":
873
871
  this.setFlatness(value);
874
872
  break;
875
873
 
876
- case 'Font':
874
+ case "Font":
877
875
  this.setFont(value[0], value[1]);
878
876
  break;
879
877
 
880
- case 'CA':
878
+ case "CA":
881
879
  this.current.strokeAlpha = state[1];
882
880
  break;
883
881
 
884
- case 'ca':
882
+ case "ca":
885
883
  this.current.fillAlpha = state[1];
886
884
  this.ctx.globalAlpha = state[1];
887
885
  break;
888
886
 
889
- case 'BM':
887
+ case "BM":
890
888
  this.ctx.globalCompositeOperation = value;
891
889
  break;
892
890
 
893
- case 'SMask':
891
+ case "SMask":
894
892
  if (this.current.activeSMask) {
895
893
  if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
896
894
  this.suspendSMaskGroup();
@@ -914,7 +912,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
914
912
  var activeSMask = this.current.activeSMask;
915
913
  var drawnWidth = activeSMask.canvas.width;
916
914
  var drawnHeight = activeSMask.canvas.height;
917
- var cacheId = 'smaskGroupAt' + this.groupLevel;
915
+ var cacheId = "smaskGroupAt" + this.groupLevel;
918
916
  var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
919
917
  var currentCtx = this.ctx;
920
918
  var currentTransform = currentCtx.mozCurrentTransform;
@@ -926,7 +924,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
926
924
  activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
927
925
  copyCtxState(currentCtx, groupCtx);
928
926
  this.ctx = groupCtx;
929
- this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
927
+ this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
930
928
  this.groupStack.push(currentCtx);
931
929
  this.groupLevel++;
932
930
  },
@@ -1071,18 +1069,23 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1071
1069
  this.ctx.closePath();
1072
1070
  },
1073
1071
  stroke: function CanvasGraphics_stroke(consumePath) {
1074
- consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
1072
+ consumePath = typeof consumePath !== "undefined" ? consumePath : true;
1075
1073
  var ctx = this.ctx;
1076
1074
  var strokeColor = this.current.strokeColor;
1077
- ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
1078
1075
  ctx.globalAlpha = this.current.strokeAlpha;
1079
1076
 
1080
- if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
1077
+ if (strokeColor && strokeColor.hasOwnProperty("type") && strokeColor.type === "Pattern") {
1081
1078
  ctx.save();
1079
+ const transform = ctx.mozCurrentTransform;
1080
+
1081
+ const scale = _util.Util.singularValueDecompose2dScale(transform)[0];
1082
+
1082
1083
  ctx.strokeStyle = strokeColor.getPattern(ctx, this);
1084
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth * scale);
1083
1085
  ctx.stroke();
1084
1086
  ctx.restore();
1085
1087
  } else {
1088
+ ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
1086
1089
  ctx.stroke();
1087
1090
  }
1088
1091
 
@@ -1097,7 +1100,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1097
1100
  this.stroke();
1098
1101
  },
1099
1102
  fill: function CanvasGraphics_fill(consumePath) {
1100
- consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
1103
+ consumePath = typeof consumePath !== "undefined" ? consumePath : true;
1101
1104
  var ctx = this.ctx;
1102
1105
  var fillColor = this.current.fillColor;
1103
1106
  var isPatternFill = this.current.patternFill;
@@ -1115,7 +1118,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1115
1118
  }
1116
1119
 
1117
1120
  if (this.pendingEOFill) {
1118
- ctx.fill('evenodd');
1121
+ ctx.fill("evenodd");
1119
1122
  this.pendingEOFill = false;
1120
1123
  } else {
1121
1124
  ctx.fill();
@@ -1207,13 +1210,13 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1207
1210
  var current = this.current;
1208
1211
 
1209
1212
  if (!fontObj) {
1210
- throw new Error("Can't find font for ".concat(fontRefName));
1213
+ throw new Error(`Can't find font for ${fontRefName}`);
1211
1214
  }
1212
1215
 
1213
1216
  current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
1214
1217
 
1215
1218
  if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
1216
- (0, _util.warn)('Invalid font matrix for font ' + fontRefName);
1219
+ (0, _util.warn)("Invalid font matrix for font " + fontRefName);
1217
1220
  }
1218
1221
 
1219
1222
  if (size < 0) {
@@ -1230,13 +1233,27 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1230
1233
  return;
1231
1234
  }
1232
1235
 
1233
- var name = fontObj.loadedName || 'sans-serif';
1234
- var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
1235
- var italic = fontObj.italic ? 'italic' : 'normal';
1236
- var typeface = "\"".concat(name, "\", ").concat(fontObj.fallbackName);
1237
- var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
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
+
1238
1255
  this.current.fontSizeScale = size / browserFontSize;
1239
- this.ctx.font = "".concat(italic, " ").concat(bold, " ").concat(browserFontSize, "px ").concat(typeface);
1256
+ this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
1240
1257
  },
1241
1258
  setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
1242
1259
  this.current.textRenderingMode = mode;
@@ -1261,7 +1278,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1261
1278
  nextLine: function CanvasGraphics_nextLine() {
1262
1279
  this.moveText(0, this.current.leading);
1263
1280
  },
1264
- paintChar: function paintChar(character, x, y, patternTransform) {
1281
+
1282
+ paintChar(character, x, y, patternTransform) {
1265
1283
  var ctx = this.ctx;
1266
1284
  var current = this.current;
1267
1285
  var font = current.font;
@@ -1269,7 +1287,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1269
1287
  var fontSize = current.fontSize / current.fontSizeScale;
1270
1288
  var fillStrokeMode = textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
1271
1289
  var isAddToPathSet = !!(textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG);
1272
- var patternFill = current.patternFill && font.data;
1290
+ const patternFill = current.patternFill && !font.missingFile;
1273
1291
  var addToPath;
1274
1292
 
1275
1293
  if (font.disableFontFace || isAddToPathSet || patternFill) {
@@ -1309,18 +1327,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1309
1327
  var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
1310
1328
  paths.push({
1311
1329
  transform: ctx.mozCurrentTransform,
1312
- x: x,
1313
- y: y,
1314
- fontSize: fontSize,
1315
- addToPath: addToPath
1330
+ x,
1331
+ y,
1332
+ fontSize,
1333
+ addToPath
1316
1334
  });
1317
1335
  }
1318
1336
  },
1319
1337
 
1320
1338
  get isFontSubpixelAAEnabled() {
1321
- var ctx = this.canvasFactory.create(10, 10).context;
1339
+ const {
1340
+ context: ctx
1341
+ } = this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled", 10, 10);
1322
1342
  ctx.scale(1.5, 1);
1323
- ctx.fillText('I', 0, 10);
1343
+ ctx.fillText("I", 0, 10);
1324
1344
  var data = ctx.getImageData(0, 0, 10, 10).data;
1325
1345
  var enabled = false;
1326
1346
 
@@ -1331,7 +1351,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1331
1351
  }
1332
1352
  }
1333
1353
 
1334
- return (0, _util.shadow)(this, 'isFontSubpixelAAEnabled', enabled);
1354
+ return (0, _util.shadow)(this, "isFontSubpixelAAEnabled", enabled);
1335
1355
  },
1336
1356
 
1337
1357
  showText: function CanvasGraphics_showText(glyphs) {
@@ -1345,7 +1365,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1345
1365
  var fontSize = current.fontSize;
1346
1366
 
1347
1367
  if (fontSize === 0) {
1348
- return;
1368
+ return undefined;
1349
1369
  }
1350
1370
 
1351
1371
  var ctx = this.ctx;
@@ -1361,11 +1381,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1361
1381
  var widthAdvanceScale = fontSize * current.fontMatrix[0];
1362
1382
  var simpleFillText = current.textRenderingMode === _util.TextRenderingMode.FILL && !font.disableFontFace && !current.patternFill;
1363
1383
  ctx.save();
1364
- var patternTransform;
1384
+ let patternTransform;
1365
1385
 
1366
1386
  if (current.patternFill) {
1367
1387
  ctx.save();
1368
- var pattern = current.fillColor.getPattern(ctx, this);
1388
+ const pattern = current.fillColor.getPattern(ctx, this);
1369
1389
  patternTransform = ctx.mozCurrentTransform;
1370
1390
  ctx.restore();
1371
1391
  ctx.fillStyle = pattern;
@@ -1460,7 +1480,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1460
1480
  }
1461
1481
  }
1462
1482
 
1463
- var charWidth = width * widthAdvanceScale + spacing * fontDirection;
1483
+ var charWidth;
1484
+
1485
+ if (vertical) {
1486
+ charWidth = width * widthAdvanceScale - spacing * fontDirection;
1487
+ } else {
1488
+ charWidth = width * widthAdvanceScale + spacing * fontDirection;
1489
+ }
1490
+
1464
1491
  x += charWidth;
1465
1492
 
1466
1493
  if (restoreNeeded) {
@@ -1469,7 +1496,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1469
1496
  }
1470
1497
 
1471
1498
  if (vertical) {
1472
- current.y -= x * textHScale;
1499
+ current.y -= x;
1473
1500
  } else {
1474
1501
  current.x += x * textHScale;
1475
1502
  }
@@ -1515,7 +1542,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1515
1542
  var operatorList = font.charProcOperatorList[glyph.operatorListId];
1516
1543
 
1517
1544
  if (!operatorList) {
1518
- (0, _util.warn)("Type3 character \"".concat(glyph.operatorListId, "\" is not available."));
1545
+ (0, _util.warn)(`Type3 character "${glyph.operatorListId}" is not available.`);
1519
1546
  continue;
1520
1547
  }
1521
1548
 
@@ -1543,16 +1570,14 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1543
1570
  this.endPath();
1544
1571
  },
1545
1572
  getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
1546
- var _this = this;
1547
-
1548
1573
  var pattern;
1549
1574
 
1550
- if (IR[0] === 'TilingPattern') {
1575
+ if (IR[0] === "TilingPattern") {
1551
1576
  var color = IR[1];
1552
1577
  var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
1553
1578
  var canvasGraphicsFactory = {
1554
- createCanvasGraphics: function createCanvasGraphics(ctx) {
1555
- return new CanvasGraphics(ctx, _this.commonObjs, _this.objs, _this.canvasFactory, _this.webGLContext);
1579
+ createCanvasGraphics: ctx => {
1580
+ return new CanvasGraphics(ctx, this.commonObjs, this.objs, this.canvasFactory, this.webGLContext);
1556
1581
  }
1557
1582
  };
1558
1583
  pattern = new _pattern_helper.TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
@@ -1614,10 +1639,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1614
1639
  this.restore();
1615
1640
  },
1616
1641
  beginInlineImage: function CanvasGraphics_beginInlineImage() {
1617
- (0, _util.unreachable)('Should not call beginInlineImage');
1642
+ (0, _util.unreachable)("Should not call beginInlineImage");
1618
1643
  },
1619
1644
  beginImageData: function CanvasGraphics_beginImageData() {
1620
- (0, _util.unreachable)('Should not call beginImageData');
1645
+ (0, _util.unreachable)("Should not call beginImageData");
1621
1646
  },
1622
1647
  paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
1623
1648
  this.save();
@@ -1646,11 +1671,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1646
1671
  var currentCtx = this.ctx;
1647
1672
 
1648
1673
  if (!group.isolated) {
1649
- (0, _util.info)('TODO: Support non-isolated groups.');
1674
+ (0, _util.info)("TODO: Support non-isolated groups.");
1650
1675
  }
1651
1676
 
1652
1677
  if (group.knockout) {
1653
- (0, _util.warn)('Knockout groups not supported.');
1678
+ (0, _util.warn)("Knockout groups not supported.");
1654
1679
  }
1655
1680
 
1656
1681
  var currentTransform = currentCtx.mozCurrentTransform;
@@ -1660,7 +1685,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1660
1685
  }
1661
1686
 
1662
1687
  if (!group.bbox) {
1663
- throw new Error('Bounding box is required.');
1688
+ throw new Error("Bounding box is required.");
1664
1689
  }
1665
1690
 
1666
1691
  var bounds = _util.Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
@@ -1684,10 +1709,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1684
1709
  drawnHeight = MAX_GROUP_SIZE;
1685
1710
  }
1686
1711
 
1687
- var cacheId = 'groupAt' + this.groupLevel;
1712
+ var cacheId = "groupAt" + this.groupLevel;
1688
1713
 
1689
1714
  if (group.smask) {
1690
- cacheId += '_smask_' + this.smaskCounter++ % 2;
1715
+ cacheId += "_smask_" + this.smaskCounter++ % 2;
1691
1716
  }
1692
1717
 
1693
1718
  var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
@@ -1700,10 +1725,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1700
1725
  this.smaskStack.push({
1701
1726
  canvas: scratchCanvas.canvas,
1702
1727
  context: groupCtx,
1703
- offsetX: offsetX,
1704
- offsetY: offsetY,
1705
- scaleX: scaleX,
1706
- scaleY: scaleY,
1728
+ offsetX,
1729
+ offsetY,
1730
+ scaleX,
1731
+ scaleY,
1707
1732
  subtype: group.smask.subtype,
1708
1733
  backdrop: group.smask.backdrop,
1709
1734
  transferMap: group.smask.transferMap || null,
@@ -1717,7 +1742,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1717
1742
 
1718
1743
  copyCtxState(currentCtx, groupCtx);
1719
1744
  this.ctx = groupCtx;
1720
- this.setGState([['BM', 'source-over'], ['ca', 1], ['CA', 1]]);
1745
+ this.setGState([["BM", "source-over"], ["ca", 1], ["CA", 1]]);
1721
1746
  this.groupStack.push(currentCtx);
1722
1747
  this.groupLevel++;
1723
1748
  this.current.activeSMask = null;
@@ -1770,33 +1795,6 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1770
1795
  endAnnotation: function CanvasGraphics_endAnnotation() {
1771
1796
  this.restore();
1772
1797
  },
1773
- paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
1774
- var domImage = this.objs.get(objId);
1775
-
1776
- if (!domImage) {
1777
- (0, _util.warn)('Dependent image isn\'t ready yet');
1778
- return;
1779
- }
1780
-
1781
- this.save();
1782
- var ctx = this.ctx;
1783
- ctx.scale(1 / w, -1 / h);
1784
- ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
1785
-
1786
- if (this.imageLayer) {
1787
- var currentTransform = ctx.mozCurrentTransformInverse;
1788
- var position = this.getCanvasPosition(0, 0);
1789
- this.imageLayer.appendImage({
1790
- objId: objId,
1791
- left: position[0],
1792
- top: position[1],
1793
- width: w / currentTransform[0],
1794
- height: h / currentTransform[3]
1795
- });
1796
- }
1797
-
1798
- this.restore();
1799
- },
1800
1798
  paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
1801
1799
  var ctx = this.ctx;
1802
1800
  var width = img.width,
@@ -1809,8 +1807,8 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1809
1807
  if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
1810
1808
  glyph.compiled = compileType3Glyph({
1811
1809
  data: img.data,
1812
- width: width,
1813
- height: height
1810
+ width,
1811
+ height
1814
1812
  });
1815
1813
  } else {
1816
1814
  glyph.compiled = null;
@@ -1822,11 +1820,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1822
1820
  return;
1823
1821
  }
1824
1822
 
1825
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1823
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1826
1824
  var maskCtx = maskCanvas.context;
1827
1825
  maskCtx.save();
1828
1826
  putBinaryImageMask(maskCtx, img);
1829
- maskCtx.globalCompositeOperation = 'source-in';
1827
+ maskCtx.globalCompositeOperation = "source-in";
1830
1828
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1831
1829
  maskCtx.fillRect(0, 0, width, height);
1832
1830
  maskCtx.restore();
@@ -1837,11 +1835,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1837
1835
  var height = imgData.height;
1838
1836
  var fillColor = this.current.fillColor;
1839
1837
  var isPatternFill = this.current.patternFill;
1840
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1838
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1841
1839
  var maskCtx = maskCanvas.context;
1842
1840
  maskCtx.save();
1843
1841
  putBinaryImageMask(maskCtx, imgData);
1844
- maskCtx.globalCompositeOperation = 'source-in';
1842
+ maskCtx.globalCompositeOperation = "source-in";
1845
1843
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1846
1844
  maskCtx.fillRect(0, 0, width, height);
1847
1845
  maskCtx.restore();
@@ -1864,11 +1862,11 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1864
1862
  var image = images[i];
1865
1863
  var width = image.width,
1866
1864
  height = image.height;
1867
- var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
1865
+ var maskCanvas = this.cachedCanvases.getCanvas("maskCanvas", width, height);
1868
1866
  var maskCtx = maskCanvas.context;
1869
1867
  maskCtx.save();
1870
1868
  putBinaryImageMask(maskCtx, image);
1871
- maskCtx.globalCompositeOperation = 'source-in';
1869
+ maskCtx.globalCompositeOperation = "source-in";
1872
1870
  maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
1873
1871
  maskCtx.fillRect(0, 0, width, height);
1874
1872
  maskCtx.restore();
@@ -1880,20 +1878,20 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1880
1878
  }
1881
1879
  },
1882
1880
  paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
1883
- var imgData = this.objs.get(objId);
1881
+ const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
1884
1882
 
1885
1883
  if (!imgData) {
1886
- (0, _util.warn)('Dependent image isn\'t ready yet');
1884
+ (0, _util.warn)("Dependent image isn't ready yet");
1887
1885
  return;
1888
1886
  }
1889
1887
 
1890
1888
  this.paintInlineImageXObject(imgData);
1891
1889
  },
1892
1890
  paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
1893
- var imgData = this.objs.get(objId);
1891
+ const imgData = objId.startsWith("g_") ? this.commonObjs.get(objId) : this.objs.get(objId);
1894
1892
 
1895
1893
  if (!imgData) {
1896
- (0, _util.warn)('Dependent image isn\'t ready yet');
1894
+ (0, _util.warn)("Dependent image isn't ready yet");
1897
1895
  return;
1898
1896
  }
1899
1897
 
@@ -1928,10 +1926,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1928
1926
  var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
1929
1927
  var imgToPaint, tmpCanvas;
1930
1928
 
1931
- if (typeof HTMLElement === 'function' && imgData instanceof HTMLElement || !imgData.data) {
1929
+ if (typeof HTMLElement === "function" && imgData instanceof HTMLElement || !imgData.data) {
1932
1930
  imgToPaint = imgData;
1933
1931
  } else {
1934
- tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
1932
+ tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", width, height);
1935
1933
  var tmpCtx = tmpCanvas.context;
1936
1934
  putBinaryImageData(tmpCtx, imgData);
1937
1935
  imgToPaint = tmpCanvas.canvas;
@@ -1939,7 +1937,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1939
1937
 
1940
1938
  var paintWidth = width,
1941
1939
  paintHeight = height;
1942
- var tmpCanvasId = 'prescale1';
1940
+ var tmpCanvasId = "prescale1";
1943
1941
 
1944
1942
  while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
1945
1943
  var newWidth = paintWidth,
@@ -1962,7 +1960,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1962
1960
  imgToPaint = tmpCanvas.canvas;
1963
1961
  paintWidth = newWidth;
1964
1962
  paintHeight = newHeight;
1965
- tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
1963
+ tmpCanvasId = tmpCanvasId === "prescale1" ? "prescale2" : "prescale1";
1966
1964
  }
1967
1965
 
1968
1966
  ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
@@ -1970,7 +1968,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1970
1968
  if (this.imageLayer) {
1971
1969
  var position = this.getCanvasPosition(0, -height);
1972
1970
  this.imageLayer.appendImage({
1973
- imgData: imgData,
1971
+ imgData,
1974
1972
  left: position[0],
1975
1973
  top: position[1],
1976
1974
  width: width / currentTransform[0],
@@ -1984,7 +1982,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1984
1982
  var ctx = this.ctx;
1985
1983
  var w = imgData.width;
1986
1984
  var h = imgData.height;
1987
- var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
1985
+ var tmpCanvas = this.cachedCanvases.getCanvas("inlineImage", w, h);
1988
1986
  var tmpCtx = tmpCanvas.context;
1989
1987
  putBinaryImageData(tmpCtx, imgData);
1990
1988
 
@@ -1998,7 +1996,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
1998
1996
  if (this.imageLayer) {
1999
1997
  var position = this.getCanvasPosition(entry.x, entry.y);
2000
1998
  this.imageLayer.appendImage({
2001
- imgData: imgData,
1999
+ imgData,
2002
2000
  left: position[0],
2003
2001
  top: position[1],
2004
2002
  width: w,
@@ -2013,7 +2011,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
2013
2011
  this.ctx.fillRect(0, 0, 1, 1);
2014
2012
  },
2015
2013
  paintXObject: function CanvasGraphics_paintXObject() {
2016
- (0, _util.warn)('Unsupported \'paintXObject\' command.');
2014
+ (0, _util.warn)("Unsupported 'paintXObject' command.");
2017
2015
  },
2018
2016
  markPoint: function CanvasGraphics_markPoint(tag) {},
2019
2017
  markPointProps: function CanvasGraphics_markPointProps(tag, properties) {},
@@ -2027,7 +2025,7 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
2027
2025
 
2028
2026
  if (this.pendingClip) {
2029
2027
  if (this.pendingClip === EO_CLIP) {
2030
- ctx.clip('evenodd');
2028
+ ctx.clip("evenodd");
2031
2029
  } else {
2032
2030
  ctx.clip();
2033
2031
  }
@@ -2037,14 +2035,16 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
2037
2035
 
2038
2036
  ctx.beginPath();
2039
2037
  },
2040
- getSinglePixelWidth: function getSinglePixelWidth(scale) {
2038
+
2039
+ getSinglePixelWidth(scale) {
2041
2040
  if (this._cachedGetSinglePixelWidth === null) {
2042
- var inverse = this.ctx.mozCurrentTransformInverse;
2041
+ const inverse = this.ctx.mozCurrentTransformInverse;
2043
2042
  this._cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
2044
2043
  }
2045
2044
 
2046
2045
  return this._cachedGetSinglePixelWidth;
2047
2046
  },
2047
+
2048
2048
  getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
2049
2049
  var transform = this.ctx.mozCurrentTransform;
2050
2050
  return [transform[0] * x + transform[2] * y + transform[4], transform[1] * x + transform[3] * y + transform[5]];