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.

Files changed (185) hide show
  1. package/README.md +4 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +6499 -17971
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +22 -1
  6. package/build/pdf.worker.entry.js +5 -3
  7. package/build/pdf.worker.js +19303 -29896
  8. package/build/pdf.worker.js.map +1 -1
  9. package/build/pdf.worker.min.js +22 -1
  10. package/es5/build/pdf.js +25473 -0
  11. package/es5/build/pdf.js.map +1 -0
  12. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  13. package/es5/build/pdf.worker.js +57878 -0
  14. package/es5/build/pdf.worker.js.map +1 -0
  15. package/es5/web/images/annotation-check.svg +11 -0
  16. package/es5/web/images/annotation-comment.svg +16 -0
  17. package/es5/web/images/annotation-help.svg +26 -0
  18. package/es5/web/images/annotation-insert.svg +10 -0
  19. package/es5/web/images/annotation-key.svg +11 -0
  20. package/es5/web/images/annotation-newparagraph.svg +11 -0
  21. package/es5/web/images/annotation-noicon.svg +7 -0
  22. package/es5/web/images/annotation-note.svg +42 -0
  23. package/es5/web/images/annotation-paragraph.svg +16 -0
  24. package/es5/web/images/loading-icon.gif +0 -0
  25. package/es5/web/images/shadow.png +0 -0
  26. package/es5/web/images/texture.png +0 -0
  27. package/es5/web/pdf_viewer.css +407 -0
  28. package/es5/web/pdf_viewer.js +7757 -0
  29. package/es5/web/pdf_viewer.js.map +1 -0
  30. package/image_decoders/pdf.image_decoders.js +1333 -4839
  31. package/image_decoders/pdf.image_decoders.js.map +1 -1
  32. package/image_decoders/pdf.image_decoders.min.js +22 -1
  33. package/lib/README.md +7 -0
  34. package/lib/core/annotation.js +683 -1066
  35. package/lib/core/arithmetic_decoder.js +81 -97
  36. package/lib/core/bidi.js +54 -46
  37. package/lib/core/ccitt.js +88 -81
  38. package/lib/core/ccitt_stream.js +15 -14
  39. package/lib/core/cff_parser.js +196 -193
  40. package/lib/core/charsets.js +4 -4
  41. package/lib/core/chunked_stream.js +441 -569
  42. package/lib/core/cmap.js +220 -279
  43. package/lib/core/colorspace.js +699 -863
  44. package/lib/core/core_utils.js +59 -80
  45. package/lib/core/crypto.js +379 -437
  46. package/lib/core/document.js +564 -673
  47. package/lib/core/encodings.js +15 -15
  48. package/lib/core/evaluator.js +983 -889
  49. package/lib/core/font_renderer.js +128 -171
  50. package/lib/core/fonts.js +451 -400
  51. package/lib/core/function.js +289 -285
  52. package/lib/core/glyphlist.js +4527 -4527
  53. package/lib/core/image.js +138 -117
  54. package/lib/core/image_utils.js +46 -63
  55. package/lib/core/jbig2.js +324 -332
  56. package/lib/core/jbig2_stream.js +18 -17
  57. package/lib/core/jpeg_stream.js +133 -24
  58. package/lib/core/jpg.js +238 -210
  59. package/lib/core/jpx.js +158 -157
  60. package/lib/core/jpx_stream.js +28 -28
  61. package/lib/core/metrics.js +2928 -2928
  62. package/lib/core/murmurhash3.js +87 -102
  63. package/lib/core/obj.js +1111 -1302
  64. package/lib/core/operator_list.js +55 -42
  65. package/lib/core/parser.js +956 -987
  66. package/lib/core/pattern.js +69 -69
  67. package/lib/core/pdf_manager.js +149 -316
  68. package/lib/core/primitives.js +45 -77
  69. package/lib/core/ps_parser.js +175 -214
  70. package/lib/core/standard_fonts.js +237 -236
  71. package/lib/core/stream.js +83 -77
  72. package/lib/core/type1_parser.js +78 -68
  73. package/lib/core/unicode.js +1654 -1654
  74. package/lib/core/worker.js +148 -196
  75. package/lib/core/worker_stream.js +101 -210
  76. package/lib/display/annotation_layer.js +733 -1155
  77. package/lib/display/api.js +1539 -1928
  78. package/lib/display/api_compatibility.js +10 -8
  79. package/lib/display/canvas.js +159 -158
  80. package/lib/display/content_disposition.js +36 -55
  81. package/lib/display/display_utils.js +298 -551
  82. package/lib/display/fetch_stream.js +181 -305
  83. package/lib/display/font_loader.js +273 -416
  84. package/lib/display/metadata.js +86 -98
  85. package/lib/display/network.js +376 -511
  86. package/lib/display/network_utils.js +20 -19
  87. package/lib/display/node_stream.js +276 -460
  88. package/lib/display/pattern_helper.js +76 -44
  89. package/lib/display/svg.js +1137 -1405
  90. package/lib/display/text_layer.js +75 -82
  91. package/lib/display/transport_stream.js +236 -374
  92. package/lib/display/webgl.js +70 -83
  93. package/lib/display/worker_options.js +3 -3
  94. package/lib/display/xml_parser.js +303 -392
  95. package/lib/examples/node/domstubs.js +37 -37
  96. package/lib/pdf.js +22 -21
  97. package/lib/pdf.worker.js +5 -5
  98. package/lib/shared/compatibility.js +2 -251
  99. package/lib/shared/is_node.js +7 -6
  100. package/lib/shared/message_handler.js +222 -194
  101. package/lib/shared/util.js +269 -405
  102. package/lib/test/unit/annotation_spec.js +1089 -1014
  103. package/lib/test/unit/api_spec.js +617 -544
  104. package/lib/test/unit/bidi_spec.js +7 -7
  105. package/lib/test/unit/cff_parser_spec.js +63 -62
  106. package/lib/test/unit/clitests_helper.js +7 -9
  107. package/lib/test/unit/cmap_spec.js +84 -86
  108. package/lib/test/unit/colorspace_spec.js +154 -154
  109. package/lib/test/unit/core_utils_spec.js +125 -105
  110. package/lib/test/unit/crypto_spec.js +181 -181
  111. package/lib/test/unit/custom_spec.js +22 -24
  112. package/lib/test/unit/display_svg_spec.js +35 -36
  113. package/lib/test/unit/display_utils_spec.js +139 -149
  114. package/lib/test/unit/document_spec.js +16 -16
  115. package/lib/test/unit/encodings_spec.js +12 -34
  116. package/lib/test/unit/evaluator_spec.js +81 -95
  117. package/lib/test/unit/fetch_stream_spec.js +30 -30
  118. package/lib/test/unit/function_spec.js +206 -204
  119. package/lib/test/unit/jasmine-boot.js +48 -32
  120. package/lib/test/unit/message_handler_spec.js +172 -162
  121. package/lib/test/unit/metadata_spec.js +69 -69
  122. package/lib/test/unit/murmurhash3_spec.js +12 -12
  123. package/lib/test/unit/network_spec.js +12 -12
  124. package/lib/test/unit/network_utils_spec.js +152 -152
  125. package/lib/test/unit/node_stream_spec.js +74 -90
  126. package/lib/test/unit/parser_spec.js +107 -113
  127. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  128. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  129. package/lib/test/unit/pdf_history_spec.js +32 -32
  130. package/lib/test/unit/primitives_spec.js +117 -115
  131. package/lib/test/unit/stream_spec.js +16 -14
  132. package/lib/test/unit/test_utils.js +119 -285
  133. package/lib/test/unit/testreporter.js +19 -19
  134. package/lib/test/unit/type1_parser_spec.js +41 -41
  135. package/lib/test/unit/ui_utils_spec.js +318 -426
  136. package/lib/test/unit/unicode_spec.js +42 -42
  137. package/lib/test/unit/util_spec.js +122 -143
  138. package/lib/web/annotation_layer_builder.js +66 -103
  139. package/lib/web/app.js +1166 -1196
  140. package/lib/web/app_options.js +61 -77
  141. package/lib/web/base_viewer.js +804 -850
  142. package/lib/web/chromecom.js +164 -249
  143. package/lib/web/debugger.js +149 -205
  144. package/lib/web/download_manager.js +38 -57
  145. package/lib/web/firefox_print_service.js +35 -30
  146. package/lib/web/firefoxcom.js +175 -374
  147. package/lib/web/genericcom.js +26 -108
  148. package/lib/web/genericl10n.js +24 -153
  149. package/lib/web/grab_to_pan.js +30 -30
  150. package/lib/web/interfaces.js +80 -258
  151. package/lib/web/overlay_manager.js +70 -246
  152. package/lib/web/password_prompt.js +38 -64
  153. package/lib/web/pdf_attachment_viewer.js +105 -130
  154. package/lib/web/pdf_cursor_tools.js +75 -102
  155. package/lib/web/pdf_document_properties.js +227 -376
  156. package/lib/web/pdf_find_bar.js +137 -171
  157. package/lib/web/pdf_find_controller.js +492 -549
  158. package/lib/web/pdf_find_utils.js +13 -13
  159. package/lib/web/pdf_history.js +395 -406
  160. package/lib/web/pdf_link_service.js +302 -349
  161. package/lib/web/pdf_outline_viewer.js +148 -209
  162. package/lib/web/pdf_page_view.js +449 -507
  163. package/lib/web/pdf_presentation_mode.js +304 -357
  164. package/lib/web/pdf_print_service.js +90 -104
  165. package/lib/web/pdf_rendering_queue.js +87 -108
  166. package/lib/web/pdf_sidebar.js +264 -304
  167. package/lib/web/pdf_sidebar_resizer.js +92 -119
  168. package/lib/web/pdf_single_page_viewer.js +77 -126
  169. package/lib/web/pdf_thumbnail_view.js +276 -297
  170. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  171. package/lib/web/pdf_viewer.component.js +20 -21
  172. package/lib/web/pdf_viewer.js +55 -115
  173. package/lib/web/preferences.js +66 -273
  174. package/lib/web/secondary_toolbar.js +164 -196
  175. package/lib/web/text_layer_builder.js +284 -317
  176. package/lib/web/toolbar.js +216 -211
  177. package/lib/web/ui_utils.js +303 -404
  178. package/lib/web/view_history.js +49 -222
  179. package/lib/web/viewer_compatibility.js +7 -5
  180. package/package.json +2 -9
  181. package/web/pdf_viewer.css +25 -18
  182. package/web/pdf_viewer.js +3481 -4764
  183. package/web/pdf_viewer.js.map +1 -1
  184. package/webpack.js +14 -5
  185. package/lib/shared/streams_polyfill.js +0 -43
@@ -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 2019 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,151 +26,39 @@ Object.defineProperty(exports, "__esModule", {
26
26
  });
27
27
  exports.SVGGraphics = void 0;
28
28
 
29
- var _util = require("../shared/util");
29
+ var _util = require("../shared/util.js");
30
30
 
31
- var _display_utils = require("./display_utils");
31
+ var _display_utils = require("./display_utils.js");
32
32
 
33
- var _is_node = _interopRequireDefault(require("../shared/is_node"));
33
+ var _is_node = require("../shared/is_node.js");
34
34
 
35
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
36
-
37
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
38
-
39
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
40
-
41
- function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
42
-
43
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
44
-
45
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
46
-
47
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
48
-
49
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
50
-
51
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
52
-
53
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
54
-
55
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
56
-
57
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
58
-
59
- var SVGGraphics = function SVGGraphics() {
60
- throw new Error('Not implemented: SVGGraphics');
35
+ let SVGGraphics = function () {
36
+ throw new Error("Not implemented: SVGGraphics");
61
37
  };
62
38
 
63
39
  exports.SVGGraphics = SVGGraphics;
64
40
  {
65
- var opListToTree = function opListToTree(opList) {
66
- var opTree = [];
67
- var tmp = [];
68
- var _iteratorNormalCompletion = true;
69
- var _didIteratorError = false;
70
- var _iteratorError = undefined;
71
-
72
- try {
73
- for (var _iterator = opList[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
74
- var opListElement = _step.value;
75
-
76
- if (opListElement.fn === 'save') {
77
- opTree.push({
78
- 'fnId': 92,
79
- 'fn': 'group',
80
- 'items': []
81
- });
82
- tmp.push(opTree);
83
- opTree = opTree[opTree.length - 1].items;
84
- continue;
85
- }
86
-
87
- if (opListElement.fn === 'restore') {
88
- opTree = tmp.pop();
89
- } else {
90
- opTree.push(opListElement);
91
- }
92
- }
93
- } catch (err) {
94
- _didIteratorError = true;
95
- _iteratorError = err;
96
- } finally {
97
- try {
98
- if (!_iteratorNormalCompletion && _iterator["return"] != null) {
99
- _iterator["return"]();
100
- }
101
- } finally {
102
- if (_didIteratorError) {
103
- throw _iteratorError;
104
- }
105
- }
106
- }
107
-
108
- return opTree;
109
- };
110
-
111
- var pf = function pf(value) {
112
- if (Number.isInteger(value)) {
113
- return value.toString();
114
- }
115
-
116
- var s = value.toFixed(10);
117
- var i = s.length - 1;
118
-
119
- if (s[i] !== '0') {
120
- return s;
121
- }
122
-
123
- do {
124
- i--;
125
- } while (s[i] === '0');
126
-
127
- return s.substring(0, s[i] === '.' ? i : i + 1);
128
- };
129
-
130
- var pm = function pm(m) {
131
- if (m[4] === 0 && m[5] === 0) {
132
- if (m[1] === 0 && m[2] === 0) {
133
- if (m[0] === 1 && m[3] === 1) {
134
- return '';
135
- }
136
-
137
- return "scale(".concat(pf(m[0]), " ").concat(pf(m[3]), ")");
138
- }
139
-
140
- if (m[0] === m[3] && m[1] === -m[2]) {
141
- var a = Math.acos(m[0]) * 180 / Math.PI;
142
- return "rotate(".concat(pf(a), ")");
143
- }
144
- } else {
145
- if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
146
- return "translate(".concat(pf(m[4]), " ").concat(pf(m[5]), ")");
147
- }
148
- }
149
-
150
- return "matrix(".concat(pf(m[0]), " ").concat(pf(m[1]), " ").concat(pf(m[2]), " ").concat(pf(m[3]), " ").concat(pf(m[4]), " ") + "".concat(pf(m[5]), ")");
41
+ const SVG_DEFAULTS = {
42
+ fontStyle: "normal",
43
+ fontWeight: "normal",
44
+ fillColor: "#000000"
151
45
  };
46
+ const XML_NS = "http://www.w3.org/XML/1998/namespace";
47
+ const XLINK_NS = "http://www.w3.org/1999/xlink";
48
+ const LINE_CAP_STYLES = ["butt", "round", "square"];
49
+ const LINE_JOIN_STYLES = ["miter", "round", "bevel"];
152
50
 
153
- var SVG_DEFAULTS = {
154
- fontStyle: 'normal',
155
- fontWeight: 'normal',
156
- fillColor: '#000000'
157
- };
158
- var XML_NS = 'http://www.w3.org/XML/1998/namespace';
159
- var XLINK_NS = 'http://www.w3.org/1999/xlink';
160
- var LINE_CAP_STYLES = ['butt', 'round', 'square'];
161
- var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
162
-
163
- var convertImgDataToPng = function () {
164
- var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
165
- var CHUNK_WRAPPER_SIZE = 12;
166
- var crcTable = new Int32Array(256);
51
+ const convertImgDataToPng = function () {
52
+ const PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
53
+ const CHUNK_WRAPPER_SIZE = 12;
54
+ const crcTable = new Int32Array(256);
167
55
 
168
- for (var i = 0; i < 256; i++) {
169
- var c = i;
56
+ for (let i = 0; i < 256; i++) {
57
+ let c = i;
170
58
 
171
- for (var h = 0; h < 8; h++) {
59
+ for (let h = 0; h < 8; h++) {
172
60
  if (c & 1) {
173
- c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
61
+ c = 0xedb88320 ^ c >> 1 & 0x7fffffff;
174
62
  } else {
175
63
  c = c >> 1 & 0x7fffffff;
176
64
  }
@@ -180,11 +68,11 @@ exports.SVGGraphics = SVGGraphics;
180
68
  }
181
69
 
182
70
  function crc32(data, start, end) {
183
- var crc = -1;
71
+ let crc = -1;
184
72
 
185
- for (var _i = start; _i < end; _i++) {
186
- var a = (crc ^ data[_i]) & 0xff;
187
- var b = crcTable[a];
73
+ for (let i = start; i < end; i++) {
74
+ const a = (crc ^ data[i]) & 0xff;
75
+ const b = crcTable[a];
188
76
  crc = crc >>> 8 ^ b;
189
77
  }
190
78
 
@@ -192,8 +80,8 @@ exports.SVGGraphics = SVGGraphics;
192
80
  }
193
81
 
194
82
  function writePngChunk(type, body, data, offset) {
195
- var p = offset;
196
- var len = body.length;
83
+ let p = offset;
84
+ const len = body.length;
197
85
  data[p] = len >> 24 & 0xff;
198
86
  data[p + 1] = len >> 16 & 0xff;
199
87
  data[p + 2] = len >> 8 & 0xff;
@@ -206,7 +94,7 @@ exports.SVGGraphics = SVGGraphics;
206
94
  p += 4;
207
95
  data.set(body, p);
208
96
  p += body.length;
209
- var crc = crc32(data, offset + 4, p);
97
+ const crc = crc32(data, offset + 4, p);
210
98
  data[p] = crc >> 24 & 0xff;
211
99
  data[p + 1] = crc >> 16 & 0xff;
212
100
  data[p + 2] = crc >> 8 & 0xff;
@@ -214,11 +102,11 @@ exports.SVGGraphics = SVGGraphics;
214
102
  }
215
103
 
216
104
  function adler32(data, start, end) {
217
- var a = 1;
218
- var b = 0;
105
+ let a = 1;
106
+ let b = 0;
219
107
 
220
- for (var _i2 = start; _i2 < end; ++_i2) {
221
- a = (a + (data[_i2] & 0xff)) % 65521;
108
+ for (let i = start; i < end; ++i) {
109
+ a = (a + (data[i] & 0xff)) % 65521;
222
110
  b = (b + a) % 65521;
223
111
  }
224
112
 
@@ -226,40 +114,40 @@ exports.SVGGraphics = SVGGraphics;
226
114
  }
227
115
 
228
116
  function deflateSync(literals) {
229
- if (!(0, _is_node["default"])()) {
117
+ if (!_is_node.isNodeJS) {
230
118
  return deflateSyncUncompressed(literals);
231
119
  }
232
120
 
233
121
  try {
234
- var input;
122
+ let input;
235
123
 
236
124
  if (parseInt(process.versions.node) >= 8) {
237
125
  input = literals;
238
126
  } else {
239
- input = new Buffer(literals);
127
+ input = Buffer.from(literals);
240
128
  }
241
129
 
242
- var output = require('zlib').deflateSync(input, {
130
+ const output = require("zlib").deflateSync(input, {
243
131
  level: 9
244
132
  });
245
133
 
246
134
  return output instanceof Uint8Array ? output : new Uint8Array(output);
247
135
  } catch (e) {
248
- (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
136
+ (0, _util.warn)("Not compressing PNG because zlib.deflateSync is unavailable: " + e);
249
137
  }
250
138
 
251
139
  return deflateSyncUncompressed(literals);
252
140
  }
253
141
 
254
142
  function deflateSyncUncompressed(literals) {
255
- var len = literals.length;
256
- var maxBlockLength = 0xFFFF;
257
- var deflateBlocks = Math.ceil(len / maxBlockLength);
258
- var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
259
- var pi = 0;
143
+ let len = literals.length;
144
+ const maxBlockLength = 0xffff;
145
+ const deflateBlocks = Math.ceil(len / maxBlockLength);
146
+ const idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
147
+ let pi = 0;
260
148
  idat[pi++] = 0x78;
261
149
  idat[pi++] = 0x9c;
262
- var pos = 0;
150
+ let pos = 0;
263
151
 
264
152
  while (len > maxBlockLength) {
265
153
  idat[pi++] = 0x00;
@@ -280,7 +168,7 @@ exports.SVGGraphics = SVGGraphics;
280
168
  idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
281
169
  idat.set(literals.subarray(pos), pi);
282
170
  pi += literals.length - pos;
283
- var adler = adler32(literals, 0, literals.length);
171
+ const adler = adler32(literals, 0, literals.length);
284
172
  idat[pi++] = adler >> 24 & 0xff;
285
173
  idat[pi++] = adler >> 16 & 0xff;
286
174
  idat[pi++] = adler >> 8 & 0xff;
@@ -289,10 +177,10 @@ exports.SVGGraphics = SVGGraphics;
289
177
  }
290
178
 
291
179
  function encode(imgData, kind, forceDataSchema, isMask) {
292
- var width = imgData.width;
293
- var height = imgData.height;
294
- var bitDepth, colorType, lineSize;
295
- var bytes = imgData.data;
180
+ const width = imgData.width;
181
+ const height = imgData.height;
182
+ let bitDepth, colorType, lineSize;
183
+ const bytes = imgData.data;
296
184
 
297
185
  switch (kind) {
298
186
  case _util.ImageKind.GRAYSCALE_1BPP:
@@ -314,14 +202,14 @@ exports.SVGGraphics = SVGGraphics;
314
202
  break;
315
203
 
316
204
  default:
317
- throw new Error('invalid format');
205
+ throw new Error("invalid format");
318
206
  }
319
207
 
320
- var literals = new Uint8Array((1 + lineSize) * height);
321
- var offsetLiterals = 0,
208
+ const literals = new Uint8Array((1 + lineSize) * height);
209
+ let offsetLiterals = 0,
322
210
  offsetBytes = 0;
323
211
 
324
- for (var y = 0; y < height; ++y) {
212
+ for (let y = 0; y < height; ++y) {
325
213
  literals[offsetLiterals++] = 0;
326
214
  literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
327
215
  offsetBytes += lineSize;
@@ -331,42 +219,38 @@ exports.SVGGraphics = SVGGraphics;
331
219
  if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
332
220
  offsetLiterals = 0;
333
221
 
334
- for (var _y = 0; _y < height; _y++) {
222
+ for (let y = 0; y < height; y++) {
335
223
  offsetLiterals++;
336
224
 
337
- for (var _i3 = 0; _i3 < lineSize; _i3++) {
338
- literals[offsetLiterals++] ^= 0xFF;
225
+ for (let i = 0; i < lineSize; i++) {
226
+ literals[offsetLiterals++] ^= 0xff;
339
227
  }
340
228
  }
341
229
  }
342
230
 
343
- var ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
344
- var idat = deflateSync(literals);
345
- var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
346
- var data = new Uint8Array(pngLength);
347
- var offset = 0;
231
+ const ihdr = new Uint8Array([width >> 24 & 0xff, width >> 16 & 0xff, width >> 8 & 0xff, width & 0xff, height >> 24 & 0xff, height >> 16 & 0xff, height >> 8 & 0xff, height & 0xff, bitDepth, colorType, 0x00, 0x00, 0x00]);
232
+ const idat = deflateSync(literals);
233
+ const pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
234
+ const data = new Uint8Array(pngLength);
235
+ let offset = 0;
348
236
  data.set(PNG_HEADER, offset);
349
237
  offset += PNG_HEADER.length;
350
- writePngChunk('IHDR', ihdr, data, offset);
238
+ writePngChunk("IHDR", ihdr, data, offset);
351
239
  offset += CHUNK_WRAPPER_SIZE + ihdr.length;
352
- writePngChunk('IDATA', idat, data, offset);
240
+ writePngChunk("IDATA", idat, data, offset);
353
241
  offset += CHUNK_WRAPPER_SIZE + idat.length;
354
- writePngChunk('IEND', new Uint8Array(0), data, offset);
355
- return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
242
+ writePngChunk("IEND", new Uint8Array(0), data, offset);
243
+ return (0, _util.createObjectURL)(data, "image/png", forceDataSchema);
356
244
  }
357
245
 
358
246
  return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
359
- var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
247
+ const kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
360
248
  return encode(imgData, kind, forceDataSchema, isMask);
361
249
  };
362
250
  }();
363
251
 
364
- var SVGExtraState =
365
- /*#__PURE__*/
366
- function () {
367
- function SVGExtraState() {
368
- _classCallCheck(this, SVGExtraState);
369
-
252
+ class SVGExtraState {
253
+ constructor() {
370
254
  this.fontSizeScale = 1;
371
255
  this.fontWeight = SVG_DEFAULTS.fontWeight;
372
256
  this.fontSize = 0;
@@ -384,47 +268,105 @@ exports.SVGGraphics = SVGGraphics;
384
268
  this.textHScale = 1;
385
269
  this.textRise = 0;
386
270
  this.fillColor = SVG_DEFAULTS.fillColor;
387
- this.strokeColor = '#000000';
271
+ this.strokeColor = "#000000";
388
272
  this.fillAlpha = 1;
389
273
  this.strokeAlpha = 1;
390
274
  this.lineWidth = 1;
391
- this.lineJoin = '';
392
- this.lineCap = '';
275
+ this.lineJoin = "";
276
+ this.lineCap = "";
393
277
  this.miterLimit = 0;
394
278
  this.dashArray = [];
395
279
  this.dashPhase = 0;
396
280
  this.dependencies = [];
397
281
  this.activeClipUrl = null;
398
282
  this.clipGroup = null;
399
- this.maskId = '';
283
+ this.maskId = "";
400
284
  }
401
285
 
402
- _createClass(SVGExtraState, [{
403
- key: "clone",
404
- value: function clone() {
405
- return Object.create(this);
286
+ clone() {
287
+ return Object.create(this);
288
+ }
289
+
290
+ setCurrentPoint(x, y) {
291
+ this.x = x;
292
+ this.y = y;
293
+ }
294
+
295
+ }
296
+
297
+ function opListToTree(opList) {
298
+ let opTree = [];
299
+ const tmp = [];
300
+
301
+ for (const opListElement of opList) {
302
+ if (opListElement.fn === "save") {
303
+ opTree.push({
304
+ fnId: 92,
305
+ fn: "group",
306
+ items: []
307
+ });
308
+ tmp.push(opTree);
309
+ opTree = opTree[opTree.length - 1].items;
310
+ continue;
406
311
  }
407
- }, {
408
- key: "setCurrentPoint",
409
- value: function setCurrentPoint(x, y) {
410
- this.x = x;
411
- this.y = y;
312
+
313
+ if (opListElement.fn === "restore") {
314
+ opTree = tmp.pop();
315
+ } else {
316
+ opTree.push(opListElement);
412
317
  }
413
- }]);
318
+ }
414
319
 
415
- return SVGExtraState;
416
- }();
320
+ return opTree;
321
+ }
417
322
 
418
- var clipCount = 0;
419
- var maskCount = 0;
420
- var shadingCount = 0;
323
+ function pf(value) {
324
+ if (Number.isInteger(value)) {
325
+ return value.toString();
326
+ }
327
+
328
+ const s = value.toFixed(10);
329
+ let i = s.length - 1;
330
+
331
+ if (s[i] !== "0") {
332
+ return s;
333
+ }
334
+
335
+ do {
336
+ i--;
337
+ } while (s[i] === "0");
338
+
339
+ return s.substring(0, s[i] === "." ? i : i + 1);
340
+ }
341
+
342
+ function pm(m) {
343
+ if (m[4] === 0 && m[5] === 0) {
344
+ if (m[1] === 0 && m[2] === 0) {
345
+ if (m[0] === 1 && m[3] === 1) {
346
+ return "";
347
+ }
348
+
349
+ return `scale(${pf(m[0])} ${pf(m[3])})`;
350
+ }
351
+
352
+ if (m[0] === m[3] && m[1] === -m[2]) {
353
+ const a = Math.acos(m[0]) * 180 / Math.PI;
354
+ return `rotate(${pf(a)})`;
355
+ }
356
+ } else {
357
+ if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
358
+ return `translate(${pf(m[4])} ${pf(m[5])})`;
359
+ }
360
+ }
421
361
 
422
- exports.SVGGraphics = SVGGraphics =
423
- /*#__PURE__*/
424
- function () {
425
- function SVGGraphics(commonObjs, objs, forceDataSchema) {
426
- _classCallCheck(this, SVGGraphics);
362
+ return `matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` + `${pf(m[5])})`;
363
+ }
427
364
 
365
+ let clipCount = 0;
366
+ let maskCount = 0;
367
+ let shadingCount = 0;
368
+ exports.SVGGraphics = SVGGraphics = class SVGGraphics {
369
+ constructor(commonObjs, objs, forceDataSchema) {
428
370
  this.svgFactory = new _display_utils.DOMSVGFactory();
429
371
  this.current = new SVGExtraState();
430
372
  this.transformMatrix = _util.IDENTITY_MATRIX;
@@ -440,1340 +382,1130 @@ exports.SVGGraphics = SVGGraphics;
440
382
  this.forceDataSchema = !!forceDataSchema;
441
383
  this._operatorIdMapping = [];
442
384
 
443
- for (var op in _util.OPS) {
385
+ for (const op in _util.OPS) {
444
386
  this._operatorIdMapping[_util.OPS[op]] = op;
445
387
  }
446
388
  }
447
389
 
448
- _createClass(SVGGraphics, [{
449
- key: "save",
450
- value: function save() {
451
- this.transformStack.push(this.transformMatrix);
452
- var old = this.current;
453
- this.extraStack.push(old);
454
- this.current = old.clone();
455
- }
456
- }, {
457
- key: "restore",
458
- value: function restore() {
459
- this.transformMatrix = this.transformStack.pop();
460
- this.current = this.extraStack.pop();
461
- this.pendingClip = null;
462
- this.tgrp = null;
463
- }
464
- }, {
465
- key: "group",
466
- value: function group(items) {
467
- this.save();
468
- this.executeOpTree(items);
469
- this.restore();
470
- }
471
- }, {
472
- key: "loadDependencies",
473
- value: function loadDependencies(operatorList) {
474
- var _this = this;
390
+ save() {
391
+ this.transformStack.push(this.transformMatrix);
392
+ const old = this.current;
393
+ this.extraStack.push(old);
394
+ this.current = old.clone();
395
+ }
475
396
 
476
- var fnArray = operatorList.fnArray;
477
- var argsArray = operatorList.argsArray;
397
+ restore() {
398
+ this.transformMatrix = this.transformStack.pop();
399
+ this.current = this.extraStack.pop();
400
+ this.pendingClip = null;
401
+ this.tgrp = null;
402
+ }
478
403
 
479
- for (var i = 0, ii = fnArray.length; i < ii; i++) {
480
- if (fnArray[i] !== _util.OPS.dependency) {
481
- continue;
482
- }
404
+ group(items) {
405
+ this.save();
406
+ this.executeOpTree(items);
407
+ this.restore();
408
+ }
483
409
 
484
- var _iteratorNormalCompletion2 = true;
485
- var _didIteratorError2 = false;
486
- var _iteratorError2 = undefined;
487
-
488
- try {
489
- var _loop = function _loop() {
490
- var obj = _step2.value;
491
- var objsPool = obj.startsWith('g_') ? _this.commonObjs : _this.objs;
492
- var promise = new Promise(function (resolve) {
493
- objsPool.get(obj, resolve);
494
- });
495
-
496
- _this.current.dependencies.push(promise);
497
- };
498
-
499
- for (var _iterator2 = argsArray[i][Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
500
- _loop();
501
- }
502
- } catch (err) {
503
- _didIteratorError2 = true;
504
- _iteratorError2 = err;
505
- } finally {
506
- try {
507
- if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
508
- _iterator2["return"]();
509
- }
510
- } finally {
511
- if (_didIteratorError2) {
512
- throw _iteratorError2;
513
- }
514
- }
515
- }
410
+ loadDependencies(operatorList) {
411
+ const fnArray = operatorList.fnArray;
412
+ const argsArray = operatorList.argsArray;
413
+
414
+ for (let i = 0, ii = fnArray.length; i < ii; i++) {
415
+ if (fnArray[i] !== _util.OPS.dependency) {
416
+ continue;
516
417
  }
517
418
 
518
- return Promise.all(this.current.dependencies);
519
- }
520
- }, {
521
- key: "transform",
522
- value: function transform(a, b, c, d, e, f) {
523
- var transformMatrix = [a, b, c, d, e, f];
524
- this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
525
- this.tgrp = null;
419
+ for (const obj of argsArray[i]) {
420
+ const objsPool = obj.startsWith("g_") ? this.commonObjs : this.objs;
421
+ const promise = new Promise(resolve => {
422
+ objsPool.get(obj, resolve);
423
+ });
424
+ this.current.dependencies.push(promise);
425
+ }
526
426
  }
527
- }, {
528
- key: "getSVG",
529
- value: function getSVG(operatorList, viewport) {
530
- var _this2 = this;
531
427
 
532
- this.viewport = viewport;
428
+ return Promise.all(this.current.dependencies);
429
+ }
533
430
 
534
- var svgElement = this._initialize(viewport);
431
+ transform(a, b, c, d, e, f) {
432
+ const transformMatrix = [a, b, c, d, e, f];
433
+ this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
434
+ this.tgrp = null;
435
+ }
535
436
 
536
- return this.loadDependencies(operatorList).then(function () {
537
- _this2.transformMatrix = _util.IDENTITY_MATRIX;
437
+ getSVG(operatorList, viewport) {
438
+ this.viewport = viewport;
538
439
 
539
- _this2.executeOpTree(_this2.convertOpList(operatorList));
440
+ const svgElement = this._initialize(viewport);
540
441
 
541
- return svgElement;
442
+ return this.loadDependencies(operatorList).then(() => {
443
+ this.transformMatrix = _util.IDENTITY_MATRIX;
444
+ this.executeOpTree(this.convertOpList(operatorList));
445
+ return svgElement;
446
+ });
447
+ }
448
+
449
+ convertOpList(operatorList) {
450
+ const operatorIdMapping = this._operatorIdMapping;
451
+ const argsArray = operatorList.argsArray;
452
+ const fnArray = operatorList.fnArray;
453
+ const opList = [];
454
+
455
+ for (let i = 0, ii = fnArray.length; i < ii; i++) {
456
+ const fnId = fnArray[i];
457
+ opList.push({
458
+ fnId,
459
+ fn: operatorIdMapping[fnId],
460
+ args: argsArray[i]
542
461
  });
543
462
  }
544
- }, {
545
- key: "convertOpList",
546
- value: function convertOpList(operatorList) {
547
- var operatorIdMapping = this._operatorIdMapping;
548
- var argsArray = operatorList.argsArray;
549
- var fnArray = operatorList.fnArray;
550
- var opList = [];
551
-
552
- for (var i = 0, ii = fnArray.length; i < ii; i++) {
553
- var fnId = fnArray[i];
554
- opList.push({
555
- 'fnId': fnId,
556
- 'fn': operatorIdMapping[fnId],
557
- 'args': argsArray[i]
558
- });
559
- }
560
463
 
561
- return opListToTree(opList);
562
- }
563
- }, {
564
- key: "executeOpTree",
565
- value: function executeOpTree(opTree) {
566
- var _iteratorNormalCompletion3 = true;
567
- var _didIteratorError3 = false;
568
- var _iteratorError3 = undefined;
569
-
570
- try {
571
- for (var _iterator3 = opTree[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
572
- var opTreeElement = _step3.value;
573
- var fn = opTreeElement.fn;
574
- var fnId = opTreeElement.fnId;
575
- var args = opTreeElement.args;
576
-
577
- switch (fnId | 0) {
578
- case _util.OPS.beginText:
579
- this.beginText();
580
- break;
581
-
582
- case _util.OPS.dependency:
583
- break;
584
-
585
- case _util.OPS.setLeading:
586
- this.setLeading(args);
587
- break;
588
-
589
- case _util.OPS.setLeadingMoveText:
590
- this.setLeadingMoveText(args[0], args[1]);
591
- break;
592
-
593
- case _util.OPS.setFont:
594
- this.setFont(args);
595
- break;
596
-
597
- case _util.OPS.showText:
598
- this.showText(args[0]);
599
- break;
600
-
601
- case _util.OPS.showSpacedText:
602
- this.showText(args[0]);
603
- break;
604
-
605
- case _util.OPS.endText:
606
- this.endText();
607
- break;
608
-
609
- case _util.OPS.moveText:
610
- this.moveText(args[0], args[1]);
611
- break;
612
-
613
- case _util.OPS.setCharSpacing:
614
- this.setCharSpacing(args[0]);
615
- break;
616
-
617
- case _util.OPS.setWordSpacing:
618
- this.setWordSpacing(args[0]);
619
- break;
620
-
621
- case _util.OPS.setHScale:
622
- this.setHScale(args[0]);
623
- break;
624
-
625
- case _util.OPS.setTextMatrix:
626
- this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
627
- break;
628
-
629
- case _util.OPS.setTextRise:
630
- this.setTextRise(args[0]);
631
- break;
632
-
633
- case _util.OPS.setTextRenderingMode:
634
- this.setTextRenderingMode(args[0]);
635
- break;
636
-
637
- case _util.OPS.setLineWidth:
638
- this.setLineWidth(args[0]);
639
- break;
640
-
641
- case _util.OPS.setLineJoin:
642
- this.setLineJoin(args[0]);
643
- break;
644
-
645
- case _util.OPS.setLineCap:
646
- this.setLineCap(args[0]);
647
- break;
648
-
649
- case _util.OPS.setMiterLimit:
650
- this.setMiterLimit(args[0]);
651
- break;
652
-
653
- case _util.OPS.setFillRGBColor:
654
- this.setFillRGBColor(args[0], args[1], args[2]);
655
- break;
656
-
657
- case _util.OPS.setStrokeRGBColor:
658
- this.setStrokeRGBColor(args[0], args[1], args[2]);
659
- break;
660
-
661
- case _util.OPS.setStrokeColorN:
662
- this.setStrokeColorN(args);
663
- break;
664
-
665
- case _util.OPS.setFillColorN:
666
- this.setFillColorN(args);
667
- break;
464
+ return opListToTree(opList);
465
+ }
668
466
 
669
- case _util.OPS.shadingFill:
670
- this.shadingFill(args[0]);
671
- break;
467
+ executeOpTree(opTree) {
468
+ for (const opTreeElement of opTree) {
469
+ const fn = opTreeElement.fn;
470
+ const fnId = opTreeElement.fnId;
471
+ const args = opTreeElement.args;
672
472
 
673
- case _util.OPS.setDash:
674
- this.setDash(args[0], args[1]);
675
- break;
473
+ switch (fnId | 0) {
474
+ case _util.OPS.beginText:
475
+ this.beginText();
476
+ break;
676
477
 
677
- case _util.OPS.setRenderingIntent:
678
- this.setRenderingIntent(args[0]);
679
- break;
478
+ case _util.OPS.dependency:
479
+ break;
680
480
 
681
- case _util.OPS.setFlatness:
682
- this.setFlatness(args[0]);
683
- break;
481
+ case _util.OPS.setLeading:
482
+ this.setLeading(args);
483
+ break;
684
484
 
685
- case _util.OPS.setGState:
686
- this.setGState(args[0]);
687
- break;
485
+ case _util.OPS.setLeadingMoveText:
486
+ this.setLeadingMoveText(args[0], args[1]);
487
+ break;
688
488
 
689
- case _util.OPS.fill:
690
- this.fill();
691
- break;
489
+ case _util.OPS.setFont:
490
+ this.setFont(args);
491
+ break;
692
492
 
693
- case _util.OPS.eoFill:
694
- this.eoFill();
695
- break;
493
+ case _util.OPS.showText:
494
+ this.showText(args[0]);
495
+ break;
696
496
 
697
- case _util.OPS.stroke:
698
- this.stroke();
699
- break;
497
+ case _util.OPS.showSpacedText:
498
+ this.showText(args[0]);
499
+ break;
700
500
 
701
- case _util.OPS.fillStroke:
702
- this.fillStroke();
703
- break;
501
+ case _util.OPS.endText:
502
+ this.endText();
503
+ break;
704
504
 
705
- case _util.OPS.eoFillStroke:
706
- this.eoFillStroke();
707
- break;
505
+ case _util.OPS.moveText:
506
+ this.moveText(args[0], args[1]);
507
+ break;
708
508
 
709
- case _util.OPS.clip:
710
- this.clip('nonzero');
711
- break;
509
+ case _util.OPS.setCharSpacing:
510
+ this.setCharSpacing(args[0]);
511
+ break;
712
512
 
713
- case _util.OPS.eoClip:
714
- this.clip('evenodd');
715
- break;
513
+ case _util.OPS.setWordSpacing:
514
+ this.setWordSpacing(args[0]);
515
+ break;
716
516
 
717
- case _util.OPS.paintSolidColorImageMask:
718
- this.paintSolidColorImageMask();
719
- break;
517
+ case _util.OPS.setHScale:
518
+ this.setHScale(args[0]);
519
+ break;
720
520
 
721
- case _util.OPS.paintJpegXObject:
722
- this.paintJpegXObject(args[0], args[1], args[2]);
723
- break;
521
+ case _util.OPS.setTextMatrix:
522
+ this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
523
+ break;
724
524
 
725
- case _util.OPS.paintImageXObject:
726
- this.paintImageXObject(args[0]);
727
- break;
525
+ case _util.OPS.setTextRise:
526
+ this.setTextRise(args[0]);
527
+ break;
728
528
 
729
- case _util.OPS.paintInlineImageXObject:
730
- this.paintInlineImageXObject(args[0]);
731
- break;
529
+ case _util.OPS.setTextRenderingMode:
530
+ this.setTextRenderingMode(args[0]);
531
+ break;
732
532
 
733
- case _util.OPS.paintImageMaskXObject:
734
- this.paintImageMaskXObject(args[0]);
735
- break;
533
+ case _util.OPS.setLineWidth:
534
+ this.setLineWidth(args[0]);
535
+ break;
736
536
 
737
- case _util.OPS.paintFormXObjectBegin:
738
- this.paintFormXObjectBegin(args[0], args[1]);
739
- break;
537
+ case _util.OPS.setLineJoin:
538
+ this.setLineJoin(args[0]);
539
+ break;
740
540
 
741
- case _util.OPS.paintFormXObjectEnd:
742
- this.paintFormXObjectEnd();
743
- break;
541
+ case _util.OPS.setLineCap:
542
+ this.setLineCap(args[0]);
543
+ break;
744
544
 
745
- case _util.OPS.closePath:
746
- this.closePath();
747
- break;
545
+ case _util.OPS.setMiterLimit:
546
+ this.setMiterLimit(args[0]);
547
+ break;
748
548
 
749
- case _util.OPS.closeStroke:
750
- this.closeStroke();
751
- break;
549
+ case _util.OPS.setFillRGBColor:
550
+ this.setFillRGBColor(args[0], args[1], args[2]);
551
+ break;
752
552
 
753
- case _util.OPS.closeFillStroke:
754
- this.closeFillStroke();
755
- break;
553
+ case _util.OPS.setStrokeRGBColor:
554
+ this.setStrokeRGBColor(args[0], args[1], args[2]);
555
+ break;
756
556
 
757
- case _util.OPS.closeEOFillStroke:
758
- this.closeEOFillStroke();
759
- break;
557
+ case _util.OPS.setStrokeColorN:
558
+ this.setStrokeColorN(args);
559
+ break;
760
560
 
761
- case _util.OPS.nextLine:
762
- this.nextLine();
763
- break;
561
+ case _util.OPS.setFillColorN:
562
+ this.setFillColorN(args);
563
+ break;
764
564
 
765
- case _util.OPS.transform:
766
- this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
767
- break;
565
+ case _util.OPS.shadingFill:
566
+ this.shadingFill(args[0]);
567
+ break;
768
568
 
769
- case _util.OPS.constructPath:
770
- this.constructPath(args[0], args[1]);
771
- break;
569
+ case _util.OPS.setDash:
570
+ this.setDash(args[0], args[1]);
571
+ break;
772
572
 
773
- case _util.OPS.endPath:
774
- this.endPath();
775
- break;
573
+ case _util.OPS.setRenderingIntent:
574
+ this.setRenderingIntent(args[0]);
575
+ break;
776
576
 
777
- case 92:
778
- this.group(opTreeElement.items);
779
- break;
577
+ case _util.OPS.setFlatness:
578
+ this.setFlatness(args[0]);
579
+ break;
780
580
 
781
- default:
782
- (0, _util.warn)("Unimplemented operator ".concat(fn));
783
- break;
784
- }
785
- }
786
- } catch (err) {
787
- _didIteratorError3 = true;
788
- _iteratorError3 = err;
789
- } finally {
790
- try {
791
- if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
792
- _iterator3["return"]();
793
- }
794
- } finally {
795
- if (_didIteratorError3) {
796
- throw _iteratorError3;
797
- }
798
- }
581
+ case _util.OPS.setGState:
582
+ this.setGState(args[0]);
583
+ break;
584
+
585
+ case _util.OPS.fill:
586
+ this.fill();
587
+ break;
588
+
589
+ case _util.OPS.eoFill:
590
+ this.eoFill();
591
+ break;
592
+
593
+ case _util.OPS.stroke:
594
+ this.stroke();
595
+ break;
596
+
597
+ case _util.OPS.fillStroke:
598
+ this.fillStroke();
599
+ break;
600
+
601
+ case _util.OPS.eoFillStroke:
602
+ this.eoFillStroke();
603
+ break;
604
+
605
+ case _util.OPS.clip:
606
+ this.clip("nonzero");
607
+ break;
608
+
609
+ case _util.OPS.eoClip:
610
+ this.clip("evenodd");
611
+ break;
612
+
613
+ case _util.OPS.paintSolidColorImageMask:
614
+ this.paintSolidColorImageMask();
615
+ break;
616
+
617
+ case _util.OPS.paintJpegXObject:
618
+ this.paintJpegXObject(args[0], args[1], args[2]);
619
+ break;
620
+
621
+ case _util.OPS.paintImageXObject:
622
+ this.paintImageXObject(args[0]);
623
+ break;
624
+
625
+ case _util.OPS.paintInlineImageXObject:
626
+ this.paintInlineImageXObject(args[0]);
627
+ break;
628
+
629
+ case _util.OPS.paintImageMaskXObject:
630
+ this.paintImageMaskXObject(args[0]);
631
+ break;
632
+
633
+ case _util.OPS.paintFormXObjectBegin:
634
+ this.paintFormXObjectBegin(args[0], args[1]);
635
+ break;
636
+
637
+ case _util.OPS.paintFormXObjectEnd:
638
+ this.paintFormXObjectEnd();
639
+ break;
640
+
641
+ case _util.OPS.closePath:
642
+ this.closePath();
643
+ break;
644
+
645
+ case _util.OPS.closeStroke:
646
+ this.closeStroke();
647
+ break;
648
+
649
+ case _util.OPS.closeFillStroke:
650
+ this.closeFillStroke();
651
+ break;
652
+
653
+ case _util.OPS.closeEOFillStroke:
654
+ this.closeEOFillStroke();
655
+ break;
656
+
657
+ case _util.OPS.nextLine:
658
+ this.nextLine();
659
+ break;
660
+
661
+ case _util.OPS.transform:
662
+ this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
663
+ break;
664
+
665
+ case _util.OPS.constructPath:
666
+ this.constructPath(args[0], args[1]);
667
+ break;
668
+
669
+ case _util.OPS.endPath:
670
+ this.endPath();
671
+ break;
672
+
673
+ case 92:
674
+ this.group(opTreeElement.items);
675
+ break;
676
+
677
+ default:
678
+ (0, _util.warn)(`Unimplemented operator ${fn}`);
679
+ break;
799
680
  }
800
681
  }
801
- }, {
802
- key: "setWordSpacing",
803
- value: function setWordSpacing(wordSpacing) {
804
- this.current.wordSpacing = wordSpacing;
805
- }
806
- }, {
807
- key: "setCharSpacing",
808
- value: function setCharSpacing(charSpacing) {
809
- this.current.charSpacing = charSpacing;
810
- }
811
- }, {
812
- key: "nextLine",
813
- value: function nextLine() {
814
- this.moveText(0, this.current.leading);
815
- }
816
- }, {
817
- key: "setTextMatrix",
818
- value: function setTextMatrix(a, b, c, d, e, f) {
819
- var current = this.current;
820
- current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
821
- current.textMatrixScale = Math.sqrt(a * a + b * b);
822
- current.x = current.lineX = 0;
823
- current.y = current.lineY = 0;
824
- current.xcoords = [];
825
- current.tspan = this.svgFactory.createElement('svg:tspan');
826
- current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
827
- current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
828
- current.tspan.setAttributeNS(null, 'y', pf(-current.y));
829
- current.txtElement = this.svgFactory.createElement('svg:text');
830
- current.txtElement.appendChild(current.tspan);
831
- }
832
- }, {
833
- key: "beginText",
834
- value: function beginText() {
835
- var current = this.current;
836
- current.x = current.lineX = 0;
837
- current.y = current.lineY = 0;
838
- current.textMatrix = _util.IDENTITY_MATRIX;
839
- current.lineMatrix = _util.IDENTITY_MATRIX;
840
- current.textMatrixScale = 1;
841
- current.tspan = this.svgFactory.createElement('svg:tspan');
842
- current.txtElement = this.svgFactory.createElement('svg:text');
843
- current.txtgrp = this.svgFactory.createElement('svg:g');
844
- current.xcoords = [];
845
- }
846
- }, {
847
- key: "moveText",
848
- value: function moveText(x, y) {
849
- var current = this.current;
850
- current.x = current.lineX += x;
851
- current.y = current.lineY += y;
852
- current.xcoords = [];
853
- current.tspan = this.svgFactory.createElement('svg:tspan');
854
- current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
855
- current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
856
- current.tspan.setAttributeNS(null, 'y', pf(-current.y));
857
- }
858
- }, {
859
- key: "showText",
860
- value: function showText(glyphs) {
861
- var current = this.current;
862
- var font = current.font;
863
- var fontSize = current.fontSize;
864
-
865
- if (fontSize === 0) {
866
- return;
867
- }
682
+ }
868
683
 
869
- var charSpacing = current.charSpacing;
870
- var wordSpacing = current.wordSpacing;
871
- var fontDirection = current.fontDirection;
872
- var textHScale = current.textHScale * fontDirection;
873
- var vertical = font.vertical;
874
- var widthAdvanceScale = fontSize * current.fontMatrix[0];
875
- var x = 0;
876
- var _iteratorNormalCompletion4 = true;
877
- var _didIteratorError4 = false;
878
- var _iteratorError4 = undefined;
879
-
880
- try {
881
- for (var _iterator4 = glyphs[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
882
- var glyph = _step4.value;
883
-
884
- if (glyph === null) {
885
- x += fontDirection * wordSpacing;
886
- continue;
887
- } else if ((0, _util.isNum)(glyph)) {
888
- x += -glyph * fontSize * 0.001;
889
- continue;
890
- }
891
-
892
- var width = glyph.width;
893
- var character = glyph.fontChar;
894
- var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
895
- var charWidth = width * widthAdvanceScale + spacing * fontDirection;
896
-
897
- if (!glyph.isInFont && !font.missingFile) {
898
- x += charWidth;
899
- continue;
900
- }
901
-
902
- current.xcoords.push(current.x + x * textHScale);
903
- current.tspan.textContent += character;
904
- x += charWidth;
905
- }
906
- } catch (err) {
907
- _didIteratorError4 = true;
908
- _iteratorError4 = err;
909
- } finally {
910
- try {
911
- if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
912
- _iterator4["return"]();
913
- }
914
- } finally {
915
- if (_didIteratorError4) {
916
- throw _iteratorError4;
917
- }
918
- }
919
- }
684
+ setWordSpacing(wordSpacing) {
685
+ this.current.wordSpacing = wordSpacing;
686
+ }
920
687
 
921
- if (vertical) {
922
- current.y -= x * textHScale;
923
- } else {
924
- current.x += x * textHScale;
925
- }
688
+ setCharSpacing(charSpacing) {
689
+ this.current.charSpacing = charSpacing;
690
+ }
926
691
 
927
- current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
928
- current.tspan.setAttributeNS(null, 'y', pf(-current.y));
929
- current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
930
- current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
692
+ nextLine() {
693
+ this.moveText(0, this.current.leading);
694
+ }
931
695
 
932
- if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
933
- current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
934
- }
696
+ setTextMatrix(a, b, c, d, e, f) {
697
+ const current = this.current;
698
+ current.textMatrix = current.lineMatrix = [a, b, c, d, e, f];
699
+ current.textMatrixScale = Math.sqrt(a * a + b * b);
700
+ current.x = current.lineX = 0;
701
+ current.y = current.lineY = 0;
702
+ current.xcoords = [];
703
+ current.tspan = this.svgFactory.createElement("svg:tspan");
704
+ current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
705
+ current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
706
+ current.tspan.setAttributeNS(null, "y", pf(-current.y));
707
+ current.txtElement = this.svgFactory.createElement("svg:text");
708
+ current.txtElement.appendChild(current.tspan);
709
+ }
935
710
 
936
- if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
937
- current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
938
- }
711
+ beginText() {
712
+ const current = this.current;
713
+ current.x = current.lineX = 0;
714
+ current.y = current.lineY = 0;
715
+ current.textMatrix = _util.IDENTITY_MATRIX;
716
+ current.lineMatrix = _util.IDENTITY_MATRIX;
717
+ current.textMatrixScale = 1;
718
+ current.tspan = this.svgFactory.createElement("svg:tspan");
719
+ current.txtElement = this.svgFactory.createElement("svg:text");
720
+ current.txtgrp = this.svgFactory.createElement("svg:g");
721
+ current.xcoords = [];
722
+ }
939
723
 
940
- var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
724
+ moveText(x, y) {
725
+ const current = this.current;
726
+ current.x = current.lineX += x;
727
+ current.y = current.lineY += y;
728
+ current.xcoords = [];
729
+ current.tspan = this.svgFactory.createElement("svg:tspan");
730
+ current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
731
+ current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
732
+ current.tspan.setAttributeNS(null, "y", pf(-current.y));
733
+ }
941
734
 
942
- if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
943
- if (current.fillColor !== SVG_DEFAULTS.fillColor) {
944
- current.tspan.setAttributeNS(null, 'fill', current.fillColor);
945
- }
735
+ showText(glyphs) {
736
+ const current = this.current;
737
+ const font = current.font;
738
+ const fontSize = current.fontSize;
946
739
 
947
- if (current.fillAlpha < 1) {
948
- current.tspan.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
949
- }
950
- } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
951
- current.tspan.setAttributeNS(null, 'fill', 'transparent');
952
- } else {
953
- current.tspan.setAttributeNS(null, 'fill', 'none');
954
- }
740
+ if (fontSize === 0) {
741
+ return;
742
+ }
955
743
 
956
- if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
957
- var lineWidthScale = 1 / (current.textMatrixScale || 1);
744
+ const charSpacing = current.charSpacing;
745
+ const wordSpacing = current.wordSpacing;
746
+ const fontDirection = current.fontDirection;
747
+ const textHScale = current.textHScale * fontDirection;
748
+ const vertical = font.vertical;
749
+ const widthAdvanceScale = fontSize * current.fontMatrix[0];
750
+ let x = 0;
958
751
 
959
- this._setStrokeAttributes(current.tspan, lineWidthScale);
752
+ for (const glyph of glyphs) {
753
+ if (glyph === null) {
754
+ x += fontDirection * wordSpacing;
755
+ continue;
756
+ } else if ((0, _util.isNum)(glyph)) {
757
+ x += -glyph * fontSize * 0.001;
758
+ continue;
960
759
  }
961
760
 
962
- var textMatrix = current.textMatrix;
761
+ const width = glyph.width;
762
+ const character = glyph.fontChar;
763
+ const spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
764
+ const charWidth = width * widthAdvanceScale + spacing * fontDirection;
963
765
 
964
- if (current.textRise !== 0) {
965
- textMatrix = textMatrix.slice();
966
- textMatrix[5] += current.textRise;
766
+ if (!glyph.isInFont && !font.missingFile) {
767
+ x += charWidth;
768
+ continue;
967
769
  }
968
770
 
969
- current.txtElement.setAttributeNS(null, 'transform', "".concat(pm(textMatrix), " scale(1, -1)"));
970
- current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
971
- current.txtElement.appendChild(current.tspan);
972
- current.txtgrp.appendChild(current.txtElement);
771
+ current.xcoords.push(current.x + x);
772
+ current.tspan.textContent += character;
773
+ x += charWidth;
774
+ }
973
775
 
974
- this._ensureTransformGroup().appendChild(current.txtElement);
776
+ if (vertical) {
777
+ current.y -= x * textHScale;
778
+ } else {
779
+ current.x += x * textHScale;
975
780
  }
976
- }, {
977
- key: "setLeadingMoveText",
978
- value: function setLeadingMoveText(x, y) {
979
- this.setLeading(-y);
980
- this.moveText(x, y);
781
+
782
+ current.tspan.setAttributeNS(null, "x", current.xcoords.map(pf).join(" "));
783
+ current.tspan.setAttributeNS(null, "y", pf(-current.y));
784
+ current.tspan.setAttributeNS(null, "font-family", current.fontFamily);
785
+ current.tspan.setAttributeNS(null, "font-size", `${pf(current.fontSize)}px`);
786
+
787
+ if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
788
+ current.tspan.setAttributeNS(null, "font-style", current.fontStyle);
981
789
  }
982
- }, {
983
- key: "addFontStyle",
984
- value: function addFontStyle(fontObj) {
985
- if (!this.cssStyle) {
986
- this.cssStyle = this.svgFactory.createElement('svg:style');
987
- this.cssStyle.setAttributeNS(null, 'type', 'text/css');
988
- this.defs.appendChild(this.cssStyle);
989
- }
990
790
 
991
- var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
992
- this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
791
+ if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
792
+ current.tspan.setAttributeNS(null, "font-weight", current.fontWeight);
993
793
  }
994
- }, {
995
- key: "setFont",
996
- value: function setFont(details) {
997
- var current = this.current;
998
- var fontObj = this.commonObjs.get(details[0]);
999
- var size = details[1];
1000
- current.font = fontObj;
1001
-
1002
- if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
1003
- this.addFontStyle(fontObj);
1004
- this.embeddedFonts[fontObj.loadedName] = fontObj;
1005
- }
1006
794
 
1007
- current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
1008
- var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
1009
- var italic = fontObj.italic ? 'italic' : 'normal';
795
+ const fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
1010
796
 
1011
- if (size < 0) {
1012
- size = -size;
1013
- current.fontDirection = -1;
1014
- } else {
1015
- current.fontDirection = 1;
797
+ if (fillStrokeMode === _util.TextRenderingMode.FILL || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
798
+ if (current.fillColor !== SVG_DEFAULTS.fillColor) {
799
+ current.tspan.setAttributeNS(null, "fill", current.fillColor);
1016
800
  }
1017
801
 
1018
- current.fontSize = size;
1019
- current.fontFamily = fontObj.loadedName;
1020
- current.fontWeight = bold;
1021
- current.fontStyle = italic;
1022
- current.tspan = this.svgFactory.createElement('svg:tspan');
1023
- current.tspan.setAttributeNS(null, 'y', pf(-current.y));
1024
- current.xcoords = [];
1025
- }
1026
- }, {
1027
- key: "endText",
1028
- value: function endText() {
1029
- var current = this.current;
1030
-
1031
- if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
1032
- current.element = current.txtElement;
1033
- this.clip('nonzero');
1034
- this.endPath();
802
+ if (current.fillAlpha < 1) {
803
+ current.tspan.setAttributeNS(null, "fill-opacity", current.fillAlpha);
1035
804
  }
805
+ } else if (current.textRenderingMode === _util.TextRenderingMode.ADD_TO_PATH) {
806
+ current.tspan.setAttributeNS(null, "fill", "transparent");
807
+ } else {
808
+ current.tspan.setAttributeNS(null, "fill", "none");
1036
809
  }
1037
- }, {
1038
- key: "setLineWidth",
1039
- value: function setLineWidth(width) {
1040
- if (width > 0) {
1041
- this.current.lineWidth = width;
1042
- }
1043
- }
1044
- }, {
1045
- key: "setLineCap",
1046
- value: function setLineCap(style) {
1047
- this.current.lineCap = LINE_CAP_STYLES[style];
1048
- }
1049
- }, {
1050
- key: "setLineJoin",
1051
- value: function setLineJoin(style) {
1052
- this.current.lineJoin = LINE_JOIN_STYLES[style];
810
+
811
+ if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
812
+ const lineWidthScale = 1 / (current.textMatrixScale || 1);
813
+
814
+ this._setStrokeAttributes(current.tspan, lineWidthScale);
1053
815
  }
1054
- }, {
1055
- key: "setMiterLimit",
1056
- value: function setMiterLimit(limit) {
1057
- this.current.miterLimit = limit;
816
+
817
+ let textMatrix = current.textMatrix;
818
+
819
+ if (current.textRise !== 0) {
820
+ textMatrix = textMatrix.slice();
821
+ textMatrix[5] += current.textRise;
1058
822
  }
1059
- }, {
1060
- key: "setStrokeAlpha",
1061
- value: function setStrokeAlpha(strokeAlpha) {
1062
- this.current.strokeAlpha = strokeAlpha;
823
+
824
+ current.txtElement.setAttributeNS(null, "transform", `${pm(textMatrix)} scale(${pf(textHScale)}, -1)`);
825
+ current.txtElement.setAttributeNS(XML_NS, "xml:space", "preserve");
826
+ current.txtElement.appendChild(current.tspan);
827
+ current.txtgrp.appendChild(current.txtElement);
828
+
829
+ this._ensureTransformGroup().appendChild(current.txtElement);
830
+ }
831
+
832
+ setLeadingMoveText(x, y) {
833
+ this.setLeading(-y);
834
+ this.moveText(x, y);
835
+ }
836
+
837
+ addFontStyle(fontObj) {
838
+ if (!this.cssStyle) {
839
+ this.cssStyle = this.svgFactory.createElement("svg:style");
840
+ this.cssStyle.setAttributeNS(null, "type", "text/css");
841
+ this.defs.appendChild(this.cssStyle);
1063
842
  }
1064
- }, {
1065
- key: "setStrokeRGBColor",
1066
- value: function setStrokeRGBColor(r, g, b) {
1067
- this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
843
+
844
+ const url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
845
+ this.cssStyle.textContent += `@font-face { font-family: "${fontObj.loadedName}";` + ` src: url(${url}); }\n`;
846
+ }
847
+
848
+ setFont(details) {
849
+ const current = this.current;
850
+ const fontObj = this.commonObjs.get(details[0]);
851
+ let size = details[1];
852
+ current.font = fontObj;
853
+
854
+ if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
855
+ this.addFontStyle(fontObj);
856
+ this.embeddedFonts[fontObj.loadedName] = fontObj;
1068
857
  }
1069
- }, {
1070
- key: "setFillAlpha",
1071
- value: function setFillAlpha(fillAlpha) {
1072
- this.current.fillAlpha = fillAlpha;
858
+
859
+ current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
860
+ let bold = "normal";
861
+
862
+ if (fontObj.black) {
863
+ bold = "900";
864
+ } else if (fontObj.bold) {
865
+ bold = "bold";
1073
866
  }
1074
- }, {
1075
- key: "setFillRGBColor",
1076
- value: function setFillRGBColor(r, g, b) {
1077
- this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
1078
- this.current.tspan = this.svgFactory.createElement('svg:tspan');
1079
- this.current.xcoords = [];
867
+
868
+ const italic = fontObj.italic ? "italic" : "normal";
869
+
870
+ if (size < 0) {
871
+ size = -size;
872
+ current.fontDirection = -1;
873
+ } else {
874
+ current.fontDirection = 1;
1080
875
  }
1081
- }, {
1082
- key: "setStrokeColorN",
1083
- value: function setStrokeColorN(args) {
1084
- this.current.strokeColor = this._makeColorN_Pattern(args);
876
+
877
+ current.fontSize = size;
878
+ current.fontFamily = fontObj.loadedName;
879
+ current.fontWeight = bold;
880
+ current.fontStyle = italic;
881
+ current.tspan = this.svgFactory.createElement("svg:tspan");
882
+ current.tspan.setAttributeNS(null, "y", pf(-current.y));
883
+ current.xcoords = [];
884
+ }
885
+
886
+ endText() {
887
+ const current = this.current;
888
+
889
+ if (current.textRenderingMode & _util.TextRenderingMode.ADD_TO_PATH_FLAG && current.txtElement && current.txtElement.hasChildNodes()) {
890
+ current.element = current.txtElement;
891
+ this.clip("nonzero");
892
+ this.endPath();
1085
893
  }
1086
- }, {
1087
- key: "setFillColorN",
1088
- value: function setFillColorN(args) {
1089
- this.current.fillColor = this._makeColorN_Pattern(args);
894
+ }
895
+
896
+ setLineWidth(width) {
897
+ if (width > 0) {
898
+ this.current.lineWidth = width;
1090
899
  }
1091
- }, {
1092
- key: "shadingFill",
1093
- value: function shadingFill(args) {
1094
- var width = this.viewport.width;
1095
- var height = this.viewport.height;
900
+ }
1096
901
 
1097
- var inv = _util.Util.inverseTransform(this.transformMatrix);
902
+ setLineCap(style) {
903
+ this.current.lineCap = LINE_CAP_STYLES[style];
904
+ }
1098
905
 
1099
- var bl = _util.Util.applyTransform([0, 0], inv);
906
+ setLineJoin(style) {
907
+ this.current.lineJoin = LINE_JOIN_STYLES[style];
908
+ }
1100
909
 
1101
- var br = _util.Util.applyTransform([0, height], inv);
910
+ setMiterLimit(limit) {
911
+ this.current.miterLimit = limit;
912
+ }
1102
913
 
1103
- var ul = _util.Util.applyTransform([width, 0], inv);
914
+ setStrokeAlpha(strokeAlpha) {
915
+ this.current.strokeAlpha = strokeAlpha;
916
+ }
1104
917
 
1105
- var ur = _util.Util.applyTransform([width, height], inv);
918
+ setStrokeRGBColor(r, g, b) {
919
+ this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
920
+ }
1106
921
 
1107
- var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
1108
- var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
1109
- var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
1110
- var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
1111
- var rect = this.svgFactory.createElement('svg:rect');
1112
- rect.setAttributeNS(null, 'x', x0);
1113
- rect.setAttributeNS(null, 'y', y0);
1114
- rect.setAttributeNS(null, 'width', x1 - x0);
1115
- rect.setAttributeNS(null, 'height', y1 - y0);
1116
- rect.setAttributeNS(null, 'fill', this._makeShadingPattern(args));
922
+ setFillAlpha(fillAlpha) {
923
+ this.current.fillAlpha = fillAlpha;
924
+ }
1117
925
 
1118
- this._ensureTransformGroup().appendChild(rect);
1119
- }
1120
- }, {
1121
- key: "_makeColorN_Pattern",
1122
- value: function _makeColorN_Pattern(args) {
1123
- if (args[0] === 'TilingPattern') {
1124
- return this._makeTilingPattern(args);
1125
- }
926
+ setFillRGBColor(r, g, b) {
927
+ this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
928
+ this.current.tspan = this.svgFactory.createElement("svg:tspan");
929
+ this.current.xcoords = [];
930
+ }
1126
931
 
1127
- return this._makeShadingPattern(args);
1128
- }
1129
- }, {
1130
- key: "_makeTilingPattern",
1131
- value: function _makeTilingPattern(args) {
1132
- var color = args[1];
1133
- var operatorList = args[2];
1134
- var matrix = args[3] || _util.IDENTITY_MATRIX;
1135
-
1136
- var _args$ = _slicedToArray(args[4], 4),
1137
- x0 = _args$[0],
1138
- y0 = _args$[1],
1139
- x1 = _args$[2],
1140
- y1 = _args$[3];
1141
-
1142
- var xstep = args[5];
1143
- var ystep = args[6];
1144
- var paintType = args[7];
1145
- var tilingId = "shading".concat(shadingCount++);
1146
-
1147
- var _Util$applyTransform = _util.Util.applyTransform([x0, y0], matrix),
1148
- _Util$applyTransform2 = _slicedToArray(_Util$applyTransform, 2),
1149
- tx0 = _Util$applyTransform2[0],
1150
- ty0 = _Util$applyTransform2[1];
1151
-
1152
- var _Util$applyTransform3 = _util.Util.applyTransform([x1, y1], matrix),
1153
- _Util$applyTransform4 = _slicedToArray(_Util$applyTransform3, 2),
1154
- tx1 = _Util$applyTransform4[0],
1155
- ty1 = _Util$applyTransform4[1];
1156
-
1157
- var _Util$singularValueDe = _util.Util.singularValueDecompose2dScale(matrix),
1158
- _Util$singularValueDe2 = _slicedToArray(_Util$singularValueDe, 2),
1159
- xscale = _Util$singularValueDe2[0],
1160
- yscale = _Util$singularValueDe2[1];
1161
-
1162
- var txstep = xstep * xscale;
1163
- var tystep = ystep * yscale;
1164
- var tiling = this.svgFactory.createElement('svg:pattern');
1165
- tiling.setAttributeNS(null, 'id', tilingId);
1166
- tiling.setAttributeNS(null, 'patternUnits', 'userSpaceOnUse');
1167
- tiling.setAttributeNS(null, 'width', txstep);
1168
- tiling.setAttributeNS(null, 'height', tystep);
1169
- tiling.setAttributeNS(null, 'x', "".concat(tx0));
1170
- tiling.setAttributeNS(null, 'y', "".concat(ty0));
1171
- var svg = this.svg;
1172
- var transformMatrix = this.transformMatrix;
1173
- var fillColor = this.current.fillColor;
1174
- var strokeColor = this.current.strokeColor;
1175
- var bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
1176
- this.svg = bbox;
1177
- this.transformMatrix = matrix;
1178
-
1179
- if (paintType === 2) {
1180
- var cssColor = _util.Util.makeCssRgb.apply(_util.Util, _toConsumableArray(color));
1181
-
1182
- this.current.fillColor = cssColor;
1183
- this.current.strokeColor = cssColor;
1184
- }
932
+ setStrokeColorN(args) {
933
+ this.current.strokeColor = this._makeColorN_Pattern(args);
934
+ }
1185
935
 
1186
- this.executeOpTree(this.convertOpList(operatorList));
1187
- this.svg = svg;
1188
- this.transformMatrix = transformMatrix;
1189
- this.current.fillColor = fillColor;
1190
- this.current.strokeColor = strokeColor;
1191
- tiling.appendChild(bbox.childNodes[0]);
1192
- this.defs.appendChild(tiling);
1193
- return "url(#".concat(tilingId, ")");
1194
- }
1195
- }, {
1196
- key: "_makeShadingPattern",
1197
- value: function _makeShadingPattern(args) {
1198
- switch (args[0]) {
1199
- case 'RadialAxial':
1200
- var shadingId = "shading".concat(shadingCount++);
1201
- var colorStops = args[2];
1202
- var gradient;
1203
-
1204
- switch (args[1]) {
1205
- case 'axial':
1206
- var point0 = args[3];
1207
- var point1 = args[4];
1208
- gradient = this.svgFactory.createElement('svg:linearGradient');
1209
- gradient.setAttributeNS(null, 'id', shadingId);
1210
- gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
1211
- gradient.setAttributeNS(null, 'x1', point0[0]);
1212
- gradient.setAttributeNS(null, 'y1', point0[1]);
1213
- gradient.setAttributeNS(null, 'x2', point1[0]);
1214
- gradient.setAttributeNS(null, 'y2', point1[1]);
1215
- break;
1216
-
1217
- case 'radial':
1218
- var focalPoint = args[3];
1219
- var circlePoint = args[4];
1220
- var focalRadius = args[5];
1221
- var circleRadius = args[6];
1222
- gradient = this.svgFactory.createElement('svg:radialGradient');
1223
- gradient.setAttributeNS(null, 'id', shadingId);
1224
- gradient.setAttributeNS(null, 'gradientUnits', 'userSpaceOnUse');
1225
- gradient.setAttributeNS(null, 'cx', circlePoint[0]);
1226
- gradient.setAttributeNS(null, 'cy', circlePoint[1]);
1227
- gradient.setAttributeNS(null, 'r', circleRadius);
1228
- gradient.setAttributeNS(null, 'fx', focalPoint[0]);
1229
- gradient.setAttributeNS(null, 'fy', focalPoint[1]);
1230
- gradient.setAttributeNS(null, 'fr', focalRadius);
1231
- break;
1232
-
1233
- default:
1234
- throw new Error("Unknown RadialAxial type: ".concat(args[1]));
1235
- }
1236
-
1237
- var _iteratorNormalCompletion5 = true;
1238
- var _didIteratorError5 = false;
1239
- var _iteratorError5 = undefined;
1240
-
1241
- try {
1242
- for (var _iterator5 = colorStops[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
1243
- var colorStop = _step5.value;
1244
- var stop = this.svgFactory.createElement('svg:stop');
1245
- stop.setAttributeNS(null, 'offset', colorStop[0]);
1246
- stop.setAttributeNS(null, 'stop-color', colorStop[1]);
1247
- gradient.appendChild(stop);
1248
- }
1249
- } catch (err) {
1250
- _didIteratorError5 = true;
1251
- _iteratorError5 = err;
1252
- } finally {
1253
- try {
1254
- if (!_iteratorNormalCompletion5 && _iterator5["return"] != null) {
1255
- _iterator5["return"]();
1256
- }
1257
- } finally {
1258
- if (_didIteratorError5) {
1259
- throw _iteratorError5;
1260
- }
1261
- }
1262
- }
1263
-
1264
- this.defs.appendChild(gradient);
1265
- return "url(#".concat(shadingId, ")");
1266
-
1267
- case 'Mesh':
1268
- (0, _util.warn)('Unimplemented pattern Mesh');
1269
- return null;
1270
-
1271
- case 'Dummy':
1272
- return 'hotpink';
936
+ setFillColorN(args) {
937
+ this.current.fillColor = this._makeColorN_Pattern(args);
938
+ }
1273
939
 
1274
- default:
1275
- throw new Error("Unknown IR type: ".concat(args[0]));
1276
- }
1277
- }
1278
- }, {
1279
- key: "setDash",
1280
- value: function setDash(dashArray, dashPhase) {
1281
- this.current.dashArray = dashArray;
1282
- this.current.dashPhase = dashPhase;
1283
- }
1284
- }, {
1285
- key: "constructPath",
1286
- value: function constructPath(ops, args) {
1287
- var current = this.current;
1288
- var x = current.x,
1289
- y = current.y;
1290
- var d = [];
1291
- var j = 0;
1292
- var _iteratorNormalCompletion6 = true;
1293
- var _didIteratorError6 = false;
1294
- var _iteratorError6 = undefined;
1295
-
1296
- try {
1297
- for (var _iterator6 = ops[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
1298
- var op = _step6.value;
1299
-
1300
- switch (op | 0) {
1301
- case _util.OPS.rectangle:
1302
- x = args[j++];
1303
- y = args[j++];
1304
- var width = args[j++];
1305
- var height = args[j++];
1306
- var xw = x + width;
1307
- var yh = y + height;
1308
- d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
1309
- break;
1310
-
1311
- case _util.OPS.moveTo:
1312
- x = args[j++];
1313
- y = args[j++];
1314
- d.push('M', pf(x), pf(y));
1315
- break;
1316
-
1317
- case _util.OPS.lineTo:
1318
- x = args[j++];
1319
- y = args[j++];
1320
- d.push('L', pf(x), pf(y));
1321
- break;
1322
-
1323
- case _util.OPS.curveTo:
1324
- x = args[j + 4];
1325
- y = args[j + 5];
1326
- d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
1327
- j += 6;
1328
- break;
1329
-
1330
- case _util.OPS.curveTo2:
1331
- x = args[j + 2];
1332
- y = args[j + 3];
1333
- d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
1334
- j += 4;
1335
- break;
1336
-
1337
- case _util.OPS.curveTo3:
1338
- x = args[j + 2];
1339
- y = args[j + 3];
1340
- d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
1341
- j += 4;
1342
- break;
1343
-
1344
- case _util.OPS.closePath:
1345
- d.push('Z');
1346
- break;
1347
- }
1348
- }
1349
- } catch (err) {
1350
- _didIteratorError6 = true;
1351
- _iteratorError6 = err;
1352
- } finally {
1353
- try {
1354
- if (!_iteratorNormalCompletion6 && _iterator6["return"] != null) {
1355
- _iterator6["return"]();
1356
- }
1357
- } finally {
1358
- if (_didIteratorError6) {
1359
- throw _iteratorError6;
1360
- }
1361
- }
1362
- }
940
+ shadingFill(args) {
941
+ const width = this.viewport.width;
942
+ const height = this.viewport.height;
1363
943
 
1364
- d = d.join(' ');
944
+ const inv = _util.Util.inverseTransform(this.transformMatrix);
1365
945
 
1366
- if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
1367
- d = current.path.getAttributeNS(null, 'd') + d;
1368
- } else {
1369
- current.path = this.svgFactory.createElement('svg:path');
946
+ const bl = _util.Util.applyTransform([0, 0], inv);
1370
947
 
1371
- this._ensureTransformGroup().appendChild(current.path);
1372
- }
948
+ const br = _util.Util.applyTransform([0, height], inv);
949
+
950
+ const ul = _util.Util.applyTransform([width, 0], inv);
951
+
952
+ const ur = _util.Util.applyTransform([width, height], inv);
953
+
954
+ const x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
955
+ const y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
956
+ const x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
957
+ const y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
958
+ const rect = this.svgFactory.createElement("svg:rect");
959
+ rect.setAttributeNS(null, "x", x0);
960
+ rect.setAttributeNS(null, "y", y0);
961
+ rect.setAttributeNS(null, "width", x1 - x0);
962
+ rect.setAttributeNS(null, "height", y1 - y0);
963
+ rect.setAttributeNS(null, "fill", this._makeShadingPattern(args));
1373
964
 
1374
- current.path.setAttributeNS(null, 'd', d);
1375
- current.path.setAttributeNS(null, 'fill', 'none');
1376
- current.element = current.path;
1377
- current.setCurrentPoint(x, y);
965
+ this._ensureTransformGroup().appendChild(rect);
966
+ }
967
+
968
+ _makeColorN_Pattern(args) {
969
+ if (args[0] === "TilingPattern") {
970
+ return this._makeTilingPattern(args);
1378
971
  }
1379
- }, {
1380
- key: "endPath",
1381
- value: function endPath() {
1382
- var current = this.current;
1383
- current.path = null;
1384
-
1385
- if (!this.pendingClip) {
1386
- return;
1387
- }
1388
972
 
1389
- if (!current.element) {
1390
- this.pendingClip = null;
1391
- return;
1392
- }
973
+ return this._makeShadingPattern(args);
974
+ }
1393
975
 
1394
- var clipId = "clippath".concat(clipCount++);
1395
- var clipPath = this.svgFactory.createElement('svg:clipPath');
1396
- clipPath.setAttributeNS(null, 'id', clipId);
1397
- clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
1398
- var clipElement = current.element.cloneNode(true);
976
+ _makeTilingPattern(args) {
977
+ const color = args[1];
978
+ const operatorList = args[2];
979
+ const matrix = args[3] || _util.IDENTITY_MATRIX;
980
+ const [x0, y0, x1, y1] = args[4];
981
+ const xstep = args[5];
982
+ const ystep = args[6];
983
+ const paintType = args[7];
984
+ const tilingId = `shading${shadingCount++}`;
985
+
986
+ const [tx0, ty0] = _util.Util.applyTransform([x0, y0], matrix);
987
+
988
+ const [tx1, ty1] = _util.Util.applyTransform([x1, y1], matrix);
989
+
990
+ const [xscale, yscale] = _util.Util.singularValueDecompose2dScale(matrix);
991
+
992
+ const txstep = xstep * xscale;
993
+ const tystep = ystep * yscale;
994
+ const tiling = this.svgFactory.createElement("svg:pattern");
995
+ tiling.setAttributeNS(null, "id", tilingId);
996
+ tiling.setAttributeNS(null, "patternUnits", "userSpaceOnUse");
997
+ tiling.setAttributeNS(null, "width", txstep);
998
+ tiling.setAttributeNS(null, "height", tystep);
999
+ tiling.setAttributeNS(null, "x", `${tx0}`);
1000
+ tiling.setAttributeNS(null, "y", `${ty0}`);
1001
+ const svg = this.svg;
1002
+ const transformMatrix = this.transformMatrix;
1003
+ const fillColor = this.current.fillColor;
1004
+ const strokeColor = this.current.strokeColor;
1005
+ const bbox = this.svgFactory.create(tx1 - tx0, ty1 - ty0);
1006
+ this.svg = bbox;
1007
+ this.transformMatrix = matrix;
1008
+
1009
+ if (paintType === 2) {
1010
+ const cssColor = _util.Util.makeCssRgb(...color);
1011
+
1012
+ this.current.fillColor = cssColor;
1013
+ this.current.strokeColor = cssColor;
1014
+ }
1015
+
1016
+ this.executeOpTree(this.convertOpList(operatorList));
1017
+ this.svg = svg;
1018
+ this.transformMatrix = transformMatrix;
1019
+ this.current.fillColor = fillColor;
1020
+ this.current.strokeColor = strokeColor;
1021
+ tiling.appendChild(bbox.childNodes[0]);
1022
+ this.defs.appendChild(tiling);
1023
+ return `url(#${tilingId})`;
1024
+ }
1399
1025
 
1400
- if (this.pendingClip === 'evenodd') {
1401
- clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
1402
- } else {
1403
- clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
1404
- }
1026
+ _makeShadingPattern(args) {
1027
+ switch (args[0]) {
1028
+ case "RadialAxial":
1029
+ const shadingId = `shading${shadingCount++}`;
1030
+ const colorStops = args[3];
1031
+ let gradient;
1032
+
1033
+ switch (args[1]) {
1034
+ case "axial":
1035
+ const point0 = args[4];
1036
+ const point1 = args[5];
1037
+ gradient = this.svgFactory.createElement("svg:linearGradient");
1038
+ gradient.setAttributeNS(null, "id", shadingId);
1039
+ gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
1040
+ gradient.setAttributeNS(null, "x1", point0[0]);
1041
+ gradient.setAttributeNS(null, "y1", point0[1]);
1042
+ gradient.setAttributeNS(null, "x2", point1[0]);
1043
+ gradient.setAttributeNS(null, "y2", point1[1]);
1044
+ break;
1045
+
1046
+ case "radial":
1047
+ const focalPoint = args[4];
1048
+ const circlePoint = args[5];
1049
+ const focalRadius = args[6];
1050
+ const circleRadius = args[7];
1051
+ gradient = this.svgFactory.createElement("svg:radialGradient");
1052
+ gradient.setAttributeNS(null, "id", shadingId);
1053
+ gradient.setAttributeNS(null, "gradientUnits", "userSpaceOnUse");
1054
+ gradient.setAttributeNS(null, "cx", circlePoint[0]);
1055
+ gradient.setAttributeNS(null, "cy", circlePoint[1]);
1056
+ gradient.setAttributeNS(null, "r", circleRadius);
1057
+ gradient.setAttributeNS(null, "fx", focalPoint[0]);
1058
+ gradient.setAttributeNS(null, "fy", focalPoint[1]);
1059
+ gradient.setAttributeNS(null, "fr", focalRadius);
1060
+ break;
1061
+
1062
+ default:
1063
+ throw new Error(`Unknown RadialAxial type: ${args[1]}`);
1064
+ }
1405
1065
 
1406
- this.pendingClip = null;
1407
- clipPath.appendChild(clipElement);
1408
- this.defs.appendChild(clipPath);
1066
+ for (const colorStop of colorStops) {
1067
+ const stop = this.svgFactory.createElement("svg:stop");
1068
+ stop.setAttributeNS(null, "offset", colorStop[0]);
1069
+ stop.setAttributeNS(null, "stop-color", colorStop[1]);
1070
+ gradient.appendChild(stop);
1071
+ }
1409
1072
 
1410
- if (current.activeClipUrl) {
1411
- current.clipGroup = null;
1412
- this.extraStack.forEach(function (prev) {
1413
- prev.clipGroup = null;
1414
- });
1415
- clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
1416
- }
1073
+ this.defs.appendChild(gradient);
1074
+ return `url(#${shadingId})`;
1417
1075
 
1418
- current.activeClipUrl = "url(#".concat(clipId, ")");
1419
- this.tgrp = null;
1420
- }
1421
- }, {
1422
- key: "clip",
1423
- value: function clip(type) {
1424
- this.pendingClip = type;
1076
+ case "Mesh":
1077
+ (0, _util.warn)("Unimplemented pattern Mesh");
1078
+ return null;
1079
+
1080
+ case "Dummy":
1081
+ return "hotpink";
1082
+
1083
+ default:
1084
+ throw new Error(`Unknown IR type: ${args[0]}`);
1425
1085
  }
1426
- }, {
1427
- key: "closePath",
1428
- value: function closePath() {
1429
- var current = this.current;
1430
-
1431
- if (current.path) {
1432
- var d = "".concat(current.path.getAttributeNS(null, 'd'), "Z");
1433
- current.path.setAttributeNS(null, 'd', d);
1086
+ }
1087
+
1088
+ setDash(dashArray, dashPhase) {
1089
+ this.current.dashArray = dashArray;
1090
+ this.current.dashPhase = dashPhase;
1091
+ }
1092
+
1093
+ constructPath(ops, args) {
1094
+ const current = this.current;
1095
+ let x = current.x,
1096
+ y = current.y;
1097
+ let d = [];
1098
+ let j = 0;
1099
+
1100
+ for (const op of ops) {
1101
+ switch (op | 0) {
1102
+ case _util.OPS.rectangle:
1103
+ x = args[j++];
1104
+ y = args[j++];
1105
+ const width = args[j++];
1106
+ const height = args[j++];
1107
+ const xw = x + width;
1108
+ const yh = y + height;
1109
+ d.push("M", pf(x), pf(y), "L", pf(xw), pf(y), "L", pf(xw), pf(yh), "L", pf(x), pf(yh), "Z");
1110
+ break;
1111
+
1112
+ case _util.OPS.moveTo:
1113
+ x = args[j++];
1114
+ y = args[j++];
1115
+ d.push("M", pf(x), pf(y));
1116
+ break;
1117
+
1118
+ case _util.OPS.lineTo:
1119
+ x = args[j++];
1120
+ y = args[j++];
1121
+ d.push("L", pf(x), pf(y));
1122
+ break;
1123
+
1124
+ case _util.OPS.curveTo:
1125
+ x = args[j + 4];
1126
+ y = args[j + 5];
1127
+ d.push("C", pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
1128
+ j += 6;
1129
+ break;
1130
+
1131
+ case _util.OPS.curveTo2:
1132
+ d.push("C", pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
1133
+ x = args[j + 2];
1134
+ y = args[j + 3];
1135
+ j += 4;
1136
+ break;
1137
+
1138
+ case _util.OPS.curveTo3:
1139
+ x = args[j + 2];
1140
+ y = args[j + 3];
1141
+ d.push("C", pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
1142
+ j += 4;
1143
+ break;
1144
+
1145
+ case _util.OPS.closePath:
1146
+ d.push("Z");
1147
+ break;
1434
1148
  }
1435
1149
  }
1436
- }, {
1437
- key: "setLeading",
1438
- value: function setLeading(leading) {
1439
- this.current.leading = -leading;
1150
+
1151
+ d = d.join(" ");
1152
+
1153
+ if (current.path && ops.length > 0 && ops[0] !== _util.OPS.rectangle && ops[0] !== _util.OPS.moveTo) {
1154
+ d = current.path.getAttributeNS(null, "d") + d;
1155
+ } else {
1156
+ current.path = this.svgFactory.createElement("svg:path");
1157
+
1158
+ this._ensureTransformGroup().appendChild(current.path);
1440
1159
  }
1441
- }, {
1442
- key: "setTextRise",
1443
- value: function setTextRise(textRise) {
1444
- this.current.textRise = textRise;
1160
+
1161
+ current.path.setAttributeNS(null, "d", d);
1162
+ current.path.setAttributeNS(null, "fill", "none");
1163
+ current.element = current.path;
1164
+ current.setCurrentPoint(x, y);
1165
+ }
1166
+
1167
+ endPath() {
1168
+ const current = this.current;
1169
+ current.path = null;
1170
+
1171
+ if (!this.pendingClip) {
1172
+ return;
1445
1173
  }
1446
- }, {
1447
- key: "setTextRenderingMode",
1448
- value: function setTextRenderingMode(textRenderingMode) {
1449
- this.current.textRenderingMode = textRenderingMode;
1174
+
1175
+ if (!current.element) {
1176
+ this.pendingClip = null;
1177
+ return;
1450
1178
  }
1451
- }, {
1452
- key: "setHScale",
1453
- value: function setHScale(scale) {
1454
- this.current.textHScale = scale / 100;
1179
+
1180
+ const clipId = `clippath${clipCount++}`;
1181
+ const clipPath = this.svgFactory.createElement("svg:clipPath");
1182
+ clipPath.setAttributeNS(null, "id", clipId);
1183
+ clipPath.setAttributeNS(null, "transform", pm(this.transformMatrix));
1184
+ const clipElement = current.element.cloneNode(true);
1185
+
1186
+ if (this.pendingClip === "evenodd") {
1187
+ clipElement.setAttributeNS(null, "clip-rule", "evenodd");
1188
+ } else {
1189
+ clipElement.setAttributeNS(null, "clip-rule", "nonzero");
1455
1190
  }
1456
- }, {
1457
- key: "setRenderingIntent",
1458
- value: function setRenderingIntent(intent) {}
1459
- }, {
1460
- key: "setFlatness",
1461
- value: function setFlatness(flatness) {}
1462
- }, {
1463
- key: "setGState",
1464
- value: function setGState(states) {
1465
- var _iteratorNormalCompletion7 = true;
1466
- var _didIteratorError7 = false;
1467
- var _iteratorError7 = undefined;
1468
-
1469
- try {
1470
- for (var _iterator7 = states[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
1471
- var _step7$value = _slicedToArray(_step7.value, 2),
1472
- key = _step7$value[0],
1473
- value = _step7$value[1];
1474
-
1475
- switch (key) {
1476
- case 'LW':
1477
- this.setLineWidth(value);
1478
- break;
1479
-
1480
- case 'LC':
1481
- this.setLineCap(value);
1482
- break;
1483
-
1484
- case 'LJ':
1485
- this.setLineJoin(value);
1486
- break;
1487
-
1488
- case 'ML':
1489
- this.setMiterLimit(value);
1490
- break;
1491
-
1492
- case 'D':
1493
- this.setDash(value[0], value[1]);
1494
- break;
1495
-
1496
- case 'RI':
1497
- this.setRenderingIntent(value);
1498
- break;
1499
-
1500
- case 'FL':
1501
- this.setFlatness(value);
1502
- break;
1503
-
1504
- case 'Font':
1505
- this.setFont(value);
1506
- break;
1507
-
1508
- case 'CA':
1509
- this.setStrokeAlpha(value);
1510
- break;
1511
-
1512
- case 'ca':
1513
- this.setFillAlpha(value);
1514
- break;
1515
-
1516
- default:
1517
- (0, _util.warn)("Unimplemented graphic state operator ".concat(key));
1518
- break;
1519
- }
1520
- }
1521
- } catch (err) {
1522
- _didIteratorError7 = true;
1523
- _iteratorError7 = err;
1524
- } finally {
1525
- try {
1526
- if (!_iteratorNormalCompletion7 && _iterator7["return"] != null) {
1527
- _iterator7["return"]();
1528
- }
1529
- } finally {
1530
- if (_didIteratorError7) {
1531
- throw _iteratorError7;
1532
- }
1533
- }
1534
- }
1191
+
1192
+ this.pendingClip = null;
1193
+ clipPath.appendChild(clipElement);
1194
+ this.defs.appendChild(clipPath);
1195
+
1196
+ if (current.activeClipUrl) {
1197
+ current.clipGroup = null;
1198
+ this.extraStack.forEach(function (prev) {
1199
+ prev.clipGroup = null;
1200
+ });
1201
+ clipPath.setAttributeNS(null, "clip-path", current.activeClipUrl);
1535
1202
  }
1536
- }, {
1537
- key: "fill",
1538
- value: function fill() {
1539
- var current = this.current;
1540
-
1541
- if (current.element) {
1542
- current.element.setAttributeNS(null, 'fill', current.fillColor);
1543
- current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
1544
- this.endPath();
1545
- }
1203
+
1204
+ current.activeClipUrl = `url(#${clipId})`;
1205
+ this.tgrp = null;
1206
+ }
1207
+
1208
+ clip(type) {
1209
+ this.pendingClip = type;
1210
+ }
1211
+
1212
+ closePath() {
1213
+ const current = this.current;
1214
+
1215
+ if (current.path) {
1216
+ const d = `${current.path.getAttributeNS(null, "d")}Z`;
1217
+ current.path.setAttributeNS(null, "d", d);
1546
1218
  }
1547
- }, {
1548
- key: "stroke",
1549
- value: function stroke() {
1550
- var current = this.current;
1219
+ }
1220
+
1221
+ setLeading(leading) {
1222
+ this.current.leading = -leading;
1223
+ }
1224
+
1225
+ setTextRise(textRise) {
1226
+ this.current.textRise = textRise;
1227
+ }
1228
+
1229
+ setTextRenderingMode(textRenderingMode) {
1230
+ this.current.textRenderingMode = textRenderingMode;
1231
+ }
1232
+
1233
+ setHScale(scale) {
1234
+ this.current.textHScale = scale / 100;
1235
+ }
1236
+
1237
+ setRenderingIntent(intent) {}
1238
+
1239
+ setFlatness(flatness) {}
1240
+
1241
+ setGState(states) {
1242
+ for (const [key, value] of states) {
1243
+ switch (key) {
1244
+ case "LW":
1245
+ this.setLineWidth(value);
1246
+ break;
1247
+
1248
+ case "LC":
1249
+ this.setLineCap(value);
1250
+ break;
1251
+
1252
+ case "LJ":
1253
+ this.setLineJoin(value);
1254
+ break;
1255
+
1256
+ case "ML":
1257
+ this.setMiterLimit(value);
1258
+ break;
1259
+
1260
+ case "D":
1261
+ this.setDash(value[0], value[1]);
1262
+ break;
1263
+
1264
+ case "RI":
1265
+ this.setRenderingIntent(value);
1266
+ break;
1551
1267
 
1552
- if (current.element) {
1553
- this._setStrokeAttributes(current.element);
1268
+ case "FL":
1269
+ this.setFlatness(value);
1270
+ break;
1554
1271
 
1555
- current.element.setAttributeNS(null, 'fill', 'none');
1556
- this.endPath();
1272
+ case "Font":
1273
+ this.setFont(value);
1274
+ break;
1275
+
1276
+ case "CA":
1277
+ this.setStrokeAlpha(value);
1278
+ break;
1279
+
1280
+ case "ca":
1281
+ this.setFillAlpha(value);
1282
+ break;
1283
+
1284
+ default:
1285
+ (0, _util.warn)(`Unimplemented graphic state operator ${key}`);
1286
+ break;
1557
1287
  }
1558
1288
  }
1559
- }, {
1560
- key: "_setStrokeAttributes",
1561
- value: function _setStrokeAttributes(element) {
1562
- var lineWidthScale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
1563
- var current = this.current;
1564
- var dashArray = current.dashArray;
1565
-
1566
- if (lineWidthScale !== 1 && dashArray.length > 0) {
1567
- dashArray = dashArray.map(function (value) {
1568
- return lineWidthScale * value;
1569
- });
1570
- }
1289
+ }
1571
1290
 
1572
- element.setAttributeNS(null, 'stroke', current.strokeColor);
1573
- element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
1574
- element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
1575
- element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
1576
- element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
1577
- element.setAttributeNS(null, 'stroke-width', pf(lineWidthScale * current.lineWidth) + 'px');
1578
- element.setAttributeNS(null, 'stroke-dasharray', dashArray.map(pf).join(' '));
1579
- element.setAttributeNS(null, 'stroke-dashoffset', pf(lineWidthScale * current.dashPhase) + 'px');
1580
- }
1581
- }, {
1582
- key: "eoFill",
1583
- value: function eoFill() {
1584
- if (this.current.element) {
1585
- this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
1586
- }
1291
+ fill() {
1292
+ const current = this.current;
1587
1293
 
1588
- this.fill();
1294
+ if (current.element) {
1295
+ current.element.setAttributeNS(null, "fill", current.fillColor);
1296
+ current.element.setAttributeNS(null, "fill-opacity", current.fillAlpha);
1297
+ this.endPath();
1589
1298
  }
1590
- }, {
1591
- key: "fillStroke",
1592
- value: function fillStroke() {
1593
- this.stroke();
1594
- this.fill();
1595
- }
1596
- }, {
1597
- key: "eoFillStroke",
1598
- value: function eoFillStroke() {
1599
- if (this.current.element) {
1600
- this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
1601
- }
1299
+ }
1602
1300
 
1603
- this.fillStroke();
1301
+ stroke() {
1302
+ const current = this.current;
1303
+
1304
+ if (current.element) {
1305
+ this._setStrokeAttributes(current.element);
1306
+
1307
+ current.element.setAttributeNS(null, "fill", "none");
1308
+ this.endPath();
1604
1309
  }
1605
- }, {
1606
- key: "closeStroke",
1607
- value: function closeStroke() {
1608
- this.closePath();
1609
- this.stroke();
1310
+ }
1311
+
1312
+ _setStrokeAttributes(element, lineWidthScale = 1) {
1313
+ const current = this.current;
1314
+ let dashArray = current.dashArray;
1315
+
1316
+ if (lineWidthScale !== 1 && dashArray.length > 0) {
1317
+ dashArray = dashArray.map(function (value) {
1318
+ return lineWidthScale * value;
1319
+ });
1610
1320
  }
1611
- }, {
1612
- key: "closeFillStroke",
1613
- value: function closeFillStroke() {
1614
- this.closePath();
1615
- this.fillStroke();
1321
+
1322
+ element.setAttributeNS(null, "stroke", current.strokeColor);
1323
+ element.setAttributeNS(null, "stroke-opacity", current.strokeAlpha);
1324
+ element.setAttributeNS(null, "stroke-miterlimit", pf(current.miterLimit));
1325
+ element.setAttributeNS(null, "stroke-linecap", current.lineCap);
1326
+ element.setAttributeNS(null, "stroke-linejoin", current.lineJoin);
1327
+ element.setAttributeNS(null, "stroke-width", pf(lineWidthScale * current.lineWidth) + "px");
1328
+ element.setAttributeNS(null, "stroke-dasharray", dashArray.map(pf).join(" "));
1329
+ element.setAttributeNS(null, "stroke-dashoffset", pf(lineWidthScale * current.dashPhase) + "px");
1330
+ }
1331
+
1332
+ eoFill() {
1333
+ if (this.current.element) {
1334
+ this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
1616
1335
  }
1617
- }, {
1618
- key: "closeEOFillStroke",
1619
- value: function closeEOFillStroke() {
1620
- this.closePath();
1621
- this.eoFillStroke();
1336
+
1337
+ this.fill();
1338
+ }
1339
+
1340
+ fillStroke() {
1341
+ this.stroke();
1342
+ this.fill();
1343
+ }
1344
+
1345
+ eoFillStroke() {
1346
+ if (this.current.element) {
1347
+ this.current.element.setAttributeNS(null, "fill-rule", "evenodd");
1622
1348
  }
1623
- }, {
1624
- key: "paintSolidColorImageMask",
1625
- value: function paintSolidColorImageMask() {
1626
- var rect = this.svgFactory.createElement('svg:rect');
1627
- rect.setAttributeNS(null, 'x', '0');
1628
- rect.setAttributeNS(null, 'y', '0');
1629
- rect.setAttributeNS(null, 'width', '1px');
1630
- rect.setAttributeNS(null, 'height', '1px');
1631
- rect.setAttributeNS(null, 'fill', this.current.fillColor);
1632
-
1633
- this._ensureTransformGroup().appendChild(rect);
1349
+
1350
+ this.fillStroke();
1351
+ }
1352
+
1353
+ closeStroke() {
1354
+ this.closePath();
1355
+ this.stroke();
1356
+ }
1357
+
1358
+ closeFillStroke() {
1359
+ this.closePath();
1360
+ this.fillStroke();
1361
+ }
1362
+
1363
+ closeEOFillStroke() {
1364
+ this.closePath();
1365
+ this.eoFillStroke();
1366
+ }
1367
+
1368
+ paintSolidColorImageMask() {
1369
+ const rect = this.svgFactory.createElement("svg:rect");
1370
+ rect.setAttributeNS(null, "x", "0");
1371
+ rect.setAttributeNS(null, "y", "0");
1372
+ rect.setAttributeNS(null, "width", "1px");
1373
+ rect.setAttributeNS(null, "height", "1px");
1374
+ rect.setAttributeNS(null, "fill", this.current.fillColor);
1375
+
1376
+ this._ensureTransformGroup().appendChild(rect);
1377
+ }
1378
+
1379
+ paintJpegXObject(objId, w, h) {
1380
+ const imgObj = this.objs.get(objId);
1381
+ const imgEl = this.svgFactory.createElement("svg:image");
1382
+ imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgObj.src);
1383
+ imgEl.setAttributeNS(null, "width", pf(w));
1384
+ imgEl.setAttributeNS(null, "height", pf(h));
1385
+ imgEl.setAttributeNS(null, "x", "0");
1386
+ imgEl.setAttributeNS(null, "y", pf(-h));
1387
+ imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / w)} ${pf(-1 / h)})`);
1388
+
1389
+ this._ensureTransformGroup().appendChild(imgEl);
1390
+ }
1391
+
1392
+ paintImageXObject(objId) {
1393
+ const imgData = this.objs.get(objId);
1394
+
1395
+ if (!imgData) {
1396
+ (0, _util.warn)(`Dependent image with object ID ${objId} is not ready yet`);
1397
+ return;
1634
1398
  }
1635
- }, {
1636
- key: "paintJpegXObject",
1637
- value: function paintJpegXObject(objId, w, h) {
1638
- var imgObj = this.objs.get(objId);
1639
- var imgEl = this.svgFactory.createElement('svg:image');
1640
- imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
1641
- imgEl.setAttributeNS(null, 'width', pf(w));
1642
- imgEl.setAttributeNS(null, 'height', pf(h));
1643
- imgEl.setAttributeNS(null, 'x', '0');
1644
- imgEl.setAttributeNS(null, 'y', pf(-h));
1645
- imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / w), " ").concat(pf(-1 / h), ")"));
1646
1399
 
1400
+ this.paintInlineImageXObject(imgData);
1401
+ }
1402
+
1403
+ paintInlineImageXObject(imgData, mask) {
1404
+ const width = imgData.width;
1405
+ const height = imgData.height;
1406
+ const imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
1407
+ const cliprect = this.svgFactory.createElement("svg:rect");
1408
+ cliprect.setAttributeNS(null, "x", "0");
1409
+ cliprect.setAttributeNS(null, "y", "0");
1410
+ cliprect.setAttributeNS(null, "width", pf(width));
1411
+ cliprect.setAttributeNS(null, "height", pf(height));
1412
+ this.current.element = cliprect;
1413
+ this.clip("nonzero");
1414
+ const imgEl = this.svgFactory.createElement("svg:image");
1415
+ imgEl.setAttributeNS(XLINK_NS, "xlink:href", imgSrc);
1416
+ imgEl.setAttributeNS(null, "x", "0");
1417
+ imgEl.setAttributeNS(null, "y", pf(-height));
1418
+ imgEl.setAttributeNS(null, "width", pf(width) + "px");
1419
+ imgEl.setAttributeNS(null, "height", pf(height) + "px");
1420
+ imgEl.setAttributeNS(null, "transform", `scale(${pf(1 / width)} ${pf(-1 / height)})`);
1421
+
1422
+ if (mask) {
1423
+ mask.appendChild(imgEl);
1424
+ } else {
1647
1425
  this._ensureTransformGroup().appendChild(imgEl);
1648
1426
  }
1649
- }, {
1650
- key: "paintImageXObject",
1651
- value: function paintImageXObject(objId) {
1652
- var imgData = this.objs.get(objId);
1653
-
1654
- if (!imgData) {
1655
- (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
1656
- return;
1657
- }
1427
+ }
1428
+
1429
+ paintImageMaskXObject(imgData) {
1430
+ const current = this.current;
1431
+ const width = imgData.width;
1432
+ const height = imgData.height;
1433
+ const fillColor = current.fillColor;
1434
+ current.maskId = `mask${maskCount++}`;
1435
+ const mask = this.svgFactory.createElement("svg:mask");
1436
+ mask.setAttributeNS(null, "id", current.maskId);
1437
+ const rect = this.svgFactory.createElement("svg:rect");
1438
+ rect.setAttributeNS(null, "x", "0");
1439
+ rect.setAttributeNS(null, "y", "0");
1440
+ rect.setAttributeNS(null, "width", pf(width));
1441
+ rect.setAttributeNS(null, "height", pf(height));
1442
+ rect.setAttributeNS(null, "fill", fillColor);
1443
+ rect.setAttributeNS(null, "mask", `url(#${current.maskId})`);
1444
+ this.defs.appendChild(mask);
1445
+
1446
+ this._ensureTransformGroup().appendChild(rect);
1447
+
1448
+ this.paintInlineImageXObject(imgData, mask);
1449
+ }
1658
1450
 
1659
- this.paintInlineImageXObject(imgData);
1451
+ paintFormXObjectBegin(matrix, bbox) {
1452
+ if (Array.isArray(matrix) && matrix.length === 6) {
1453
+ this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
1660
1454
  }
1661
- }, {
1662
- key: "paintInlineImageXObject",
1663
- value: function paintInlineImageXObject(imgData, mask) {
1664
- var width = imgData.width;
1665
- var height = imgData.height;
1666
- var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
1667
- var cliprect = this.svgFactory.createElement('svg:rect');
1668
- cliprect.setAttributeNS(null, 'x', '0');
1669
- cliprect.setAttributeNS(null, 'y', '0');
1670
- cliprect.setAttributeNS(null, 'width', pf(width));
1671
- cliprect.setAttributeNS(null, 'height', pf(height));
1455
+
1456
+ if (bbox) {
1457
+ const width = bbox[2] - bbox[0];
1458
+ const height = bbox[3] - bbox[1];
1459
+ const cliprect = this.svgFactory.createElement("svg:rect");
1460
+ cliprect.setAttributeNS(null, "x", bbox[0]);
1461
+ cliprect.setAttributeNS(null, "y", bbox[1]);
1462
+ cliprect.setAttributeNS(null, "width", pf(width));
1463
+ cliprect.setAttributeNS(null, "height", pf(height));
1672
1464
  this.current.element = cliprect;
1673
- this.clip('nonzero');
1674
- var imgEl = this.svgFactory.createElement('svg:image');
1675
- imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
1676
- imgEl.setAttributeNS(null, 'x', '0');
1677
- imgEl.setAttributeNS(null, 'y', pf(-height));
1678
- imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
1679
- imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
1680
- imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
1681
-
1682
- if (mask) {
1683
- mask.appendChild(imgEl);
1684
- } else {
1685
- this._ensureTransformGroup().appendChild(imgEl);
1686
- }
1687
- }
1688
- }, {
1689
- key: "paintImageMaskXObject",
1690
- value: function paintImageMaskXObject(imgData) {
1691
- var current = this.current;
1692
- var width = imgData.width;
1693
- var height = imgData.height;
1694
- var fillColor = current.fillColor;
1695
- current.maskId = "mask".concat(maskCount++);
1696
- var mask = this.svgFactory.createElement('svg:mask');
1697
- mask.setAttributeNS(null, 'id', current.maskId);
1698
- var rect = this.svgFactory.createElement('svg:rect');
1699
- rect.setAttributeNS(null, 'x', '0');
1700
- rect.setAttributeNS(null, 'y', '0');
1701
- rect.setAttributeNS(null, 'width', pf(width));
1702
- rect.setAttributeNS(null, 'height', pf(height));
1703
- rect.setAttributeNS(null, 'fill', fillColor);
1704
- rect.setAttributeNS(null, 'mask', "url(#".concat(current.maskId, ")"));
1705
- this.defs.appendChild(mask);
1706
-
1707
- this._ensureTransformGroup().appendChild(rect);
1708
-
1709
- this.paintInlineImageXObject(imgData, mask);
1465
+ this.clip("nonzero");
1466
+ this.endPath();
1710
1467
  }
1711
- }, {
1712
- key: "paintFormXObjectBegin",
1713
- value: function paintFormXObjectBegin(matrix, bbox) {
1714
- if (Array.isArray(matrix) && matrix.length === 6) {
1715
- this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
1716
- }
1468
+ }
1717
1469
 
1718
- if (bbox) {
1719
- var width = bbox[2] - bbox[0];
1720
- var height = bbox[3] - bbox[1];
1721
- var cliprect = this.svgFactory.createElement('svg:rect');
1722
- cliprect.setAttributeNS(null, 'x', bbox[0]);
1723
- cliprect.setAttributeNS(null, 'y', bbox[1]);
1724
- cliprect.setAttributeNS(null, 'width', pf(width));
1725
- cliprect.setAttributeNS(null, 'height', pf(height));
1726
- this.current.element = cliprect;
1727
- this.clip('nonzero');
1728
- this.endPath();
1729
- }
1730
- }
1731
- }, {
1732
- key: "paintFormXObjectEnd",
1733
- value: function paintFormXObjectEnd() {}
1734
- }, {
1735
- key: "_initialize",
1736
- value: function _initialize(viewport) {
1737
- var svg = this.svgFactory.create(viewport.width, viewport.height);
1738
- var definitions = this.svgFactory.createElement('svg:defs');
1739
- svg.appendChild(definitions);
1740
- this.defs = definitions;
1741
- var rootGroup = this.svgFactory.createElement('svg:g');
1742
- rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
1743
- svg.appendChild(rootGroup);
1744
- this.svg = rootGroup;
1745
- return svg;
1746
- }
1747
- }, {
1748
- key: "_ensureClipGroup",
1749
- value: function _ensureClipGroup() {
1750
- if (!this.current.clipGroup) {
1751
- var clipGroup = this.svgFactory.createElement('svg:g');
1752
- clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
1753
- this.svg.appendChild(clipGroup);
1754
- this.current.clipGroup = clipGroup;
1755
- }
1470
+ paintFormXObjectEnd() {}
1471
+
1472
+ _initialize(viewport) {
1473
+ const svg = this.svgFactory.create(viewport.width, viewport.height);
1474
+ const definitions = this.svgFactory.createElement("svg:defs");
1475
+ svg.appendChild(definitions);
1476
+ this.defs = definitions;
1477
+ const rootGroup = this.svgFactory.createElement("svg:g");
1478
+ rootGroup.setAttributeNS(null, "transform", pm(viewport.transform));
1479
+ svg.appendChild(rootGroup);
1480
+ this.svg = rootGroup;
1481
+ return svg;
1482
+ }
1756
1483
 
1757
- return this.current.clipGroup;
1484
+ _ensureClipGroup() {
1485
+ if (!this.current.clipGroup) {
1486
+ const clipGroup = this.svgFactory.createElement("svg:g");
1487
+ clipGroup.setAttributeNS(null, "clip-path", this.current.activeClipUrl);
1488
+ this.svg.appendChild(clipGroup);
1489
+ this.current.clipGroup = clipGroup;
1758
1490
  }
1759
- }, {
1760
- key: "_ensureTransformGroup",
1761
- value: function _ensureTransformGroup() {
1762
- if (!this.tgrp) {
1763
- this.tgrp = this.svgFactory.createElement('svg:g');
1764
- this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
1765
-
1766
- if (this.current.activeClipUrl) {
1767
- this._ensureClipGroup().appendChild(this.tgrp);
1768
- } else {
1769
- this.svg.appendChild(this.tgrp);
1770
- }
1771
- }
1772
1491
 
1773
- return this.tgrp;
1492
+ return this.current.clipGroup;
1493
+ }
1494
+
1495
+ _ensureTransformGroup() {
1496
+ if (!this.tgrp) {
1497
+ this.tgrp = this.svgFactory.createElement("svg:g");
1498
+ this.tgrp.setAttributeNS(null, "transform", pm(this.transformMatrix));
1499
+
1500
+ if (this.current.activeClipUrl) {
1501
+ this._ensureClipGroup().appendChild(this.tgrp);
1502
+ } else {
1503
+ this.svg.appendChild(this.tgrp);
1504
+ }
1774
1505
  }
1775
- }]);
1776
1506
 
1777
- return SVGGraphics;
1778
- }();
1507
+ return this.tgrp;
1508
+ }
1509
+
1510
+ };
1779
1511
  }