pdfjs-dist 2.0.489 → 2.2.228

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 (169) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/bower.json +1 -1
  3. package/build/pdf.js +18515 -11402
  4. package/build/pdf.js.map +1 -1
  5. package/build/pdf.min.js +1 -1
  6. package/build/pdf.worker.js +48266 -37137
  7. package/build/pdf.worker.js.map +1 -1
  8. package/build/pdf.worker.min.js +1 -1
  9. package/external/url/url-lib.js +627 -0
  10. package/image_decoders/pdf.image_decoders.js +11350 -0
  11. package/image_decoders/pdf.image_decoders.js.map +1 -0
  12. package/image_decoders/pdf.image_decoders.min.js +1 -0
  13. package/lib/core/annotation.js +587 -242
  14. package/lib/core/arithmetic_decoder.js +275 -245
  15. package/lib/core/bidi.js +65 -6
  16. package/lib/core/ccitt.js +173 -18
  17. package/lib/core/ccitt_stream.js +15 -6
  18. package/lib/core/cff_parser.js +433 -61
  19. package/lib/core/charsets.js +5 -4
  20. package/lib/core/chunked_stream.js +400 -152
  21. package/lib/core/cmap.js +326 -87
  22. package/lib/core/colorspace.js +874 -594
  23. package/lib/core/core_utils.js +147 -0
  24. package/lib/core/crypto.js +290 -45
  25. package/lib/core/document.js +560 -268
  26. package/lib/core/encodings.js +19 -10
  27. package/lib/core/evaluator.js +1005 -360
  28. package/lib/core/font_renderer.js +331 -97
  29. package/lib/core/fonts.js +812 -195
  30. package/lib/core/function.js +284 -71
  31. package/lib/core/glyphlist.js +4 -3
  32. package/lib/core/image.js +169 -62
  33. package/lib/core/image_utils.js +111 -0
  34. package/lib/core/jbig2.js +479 -66
  35. package/lib/core/jbig2_stream.js +19 -8
  36. package/lib/core/jpeg_stream.js +38 -13
  37. package/lib/core/jpg.js +253 -29
  38. package/lib/core/jpx.js +396 -6
  39. package/lib/core/jpx_stream.js +18 -6
  40. package/lib/core/metrics.js +15 -15
  41. package/lib/core/murmurhash3.js +56 -34
  42. package/lib/core/obj.js +1354 -488
  43. package/lib/core/operator_list.js +144 -31
  44. package/lib/core/parser.js +539 -191
  45. package/lib/core/pattern.js +148 -14
  46. package/lib/core/pdf_manager.js +323 -133
  47. package/lib/core/primitives.js +111 -24
  48. package/lib/core/ps_parser.js +134 -45
  49. package/lib/core/standard_fonts.js +17 -17
  50. package/lib/core/stream.js +313 -34
  51. package/lib/core/type1_parser.js +143 -13
  52. package/lib/core/unicode.js +32 -5
  53. package/lib/core/worker.js +217 -190
  54. package/lib/core/worker_stream.js +277 -0
  55. package/lib/display/annotation_layer.js +450 -133
  56. package/lib/display/api.js +1597 -784
  57. package/lib/display/api_compatibility.js +11 -13
  58. package/lib/display/canvas.js +360 -44
  59. package/lib/display/content_disposition.js +83 -32
  60. package/lib/display/display_utils.js +747 -0
  61. package/lib/display/fetch_stream.js +221 -90
  62. package/lib/display/font_loader.js +468 -236
  63. package/lib/display/metadata.js +38 -16
  64. package/lib/display/network.js +635 -428
  65. package/lib/display/network_utils.js +32 -19
  66. package/lib/display/node_stream.js +367 -175
  67. package/lib/display/pattern_helper.js +81 -31
  68. package/lib/display/svg.js +1235 -519
  69. package/lib/display/text_layer.js +153 -29
  70. package/lib/display/transport_stream.js +345 -94
  71. package/lib/display/webgl.js +64 -18
  72. package/lib/display/worker_options.js +5 -4
  73. package/lib/display/xml_parser.js +166 -53
  74. package/lib/examples/node/domstubs.js +60 -4
  75. package/lib/pdf.js +36 -14
  76. package/lib/pdf.worker.js +5 -3
  77. package/lib/shared/compatibility.js +158 -564
  78. package/lib/shared/global_scope.js +2 -2
  79. package/lib/shared/is_node.js +4 -4
  80. package/lib/shared/message_handler.js +521 -0
  81. package/lib/shared/streams_polyfill.js +21 -17
  82. package/lib/shared/url_polyfill.js +56 -0
  83. package/lib/shared/util.js +243 -710
  84. package/lib/test/unit/annotation_spec.js +870 -401
  85. package/lib/test/unit/api_spec.js +657 -345
  86. package/lib/test/unit/bidi_spec.js +7 -7
  87. package/lib/test/unit/cff_parser_spec.js +54 -11
  88. package/lib/test/unit/clitests_helper.js +10 -8
  89. package/lib/test/unit/cmap_spec.js +95 -41
  90. package/lib/test/unit/colorspace_spec.js +115 -63
  91. package/lib/test/unit/core_utils_spec.js +191 -0
  92. package/lib/test/unit/crypto_spec.js +17 -5
  93. package/lib/test/unit/custom_spec.js +43 -55
  94. package/lib/test/unit/display_svg_spec.js +34 -18
  95. package/lib/test/unit/display_utils_spec.js +273 -0
  96. package/lib/test/unit/document_spec.js +8 -13
  97. package/lib/test/unit/encodings_spec.js +25 -45
  98. package/lib/test/unit/evaluator_spec.js +38 -15
  99. package/lib/test/unit/fetch_stream_spec.js +109 -0
  100. package/lib/test/unit/function_spec.js +17 -5
  101. package/lib/test/unit/jasmine-boot.js +33 -20
  102. package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
  103. package/lib/test/unit/metadata_spec.js +71 -11
  104. package/lib/test/unit/murmurhash3_spec.js +3 -3
  105. package/lib/test/unit/network_spec.js +19 -54
  106. package/lib/test/unit/network_utils_spec.js +91 -14
  107. package/lib/test/unit/node_stream_spec.js +56 -32
  108. package/lib/test/unit/parser_spec.js +162 -71
  109. package/lib/test/unit/pdf_find_controller_spec.js +230 -0
  110. package/lib/test/unit/pdf_find_utils_spec.js +63 -0
  111. package/lib/test/unit/pdf_history_spec.js +21 -9
  112. package/lib/test/unit/primitives_spec.js +53 -20
  113. package/lib/test/unit/stream_spec.js +12 -4
  114. package/lib/test/unit/test_utils.js +273 -56
  115. package/lib/test/unit/testreporter.js +21 -3
  116. package/lib/test/unit/type1_parser_spec.js +8 -6
  117. package/lib/test/unit/ui_utils_spec.js +454 -16
  118. package/lib/test/unit/unicode_spec.js +18 -15
  119. package/lib/test/unit/util_spec.js +87 -128
  120. package/lib/web/annotation_layer_builder.js +39 -22
  121. package/lib/web/app.js +1290 -588
  122. package/lib/web/app_options.js +100 -62
  123. package/lib/web/base_viewer.js +511 -182
  124. package/lib/web/chromecom.js +261 -117
  125. package/lib/web/debugger.js +166 -22
  126. package/lib/web/download_manager.js +32 -13
  127. package/lib/web/firefox_print_service.js +20 -10
  128. package/lib/web/firefoxcom.js +315 -80
  129. package/lib/web/genericcom.js +89 -30
  130. package/lib/web/genericl10n.js +142 -30
  131. package/lib/web/grab_to_pan.js +28 -4
  132. package/lib/web/interfaces.js +170 -47
  133. package/lib/web/overlay_manager.js +235 -85
  134. package/lib/web/password_prompt.js +22 -14
  135. package/lib/web/pdf_attachment_viewer.js +38 -18
  136. package/lib/web/pdf_cursor_tools.js +39 -16
  137. package/lib/web/pdf_document_properties.js +255 -136
  138. package/lib/web/pdf_find_bar.js +84 -40
  139. package/lib/web/pdf_find_controller.js +495 -184
  140. package/lib/web/pdf_find_utils.js +111 -0
  141. package/lib/web/pdf_history.js +190 -53
  142. package/lib/web/pdf_link_service.js +138 -77
  143. package/lib/web/pdf_outline_viewer.js +122 -46
  144. package/lib/web/pdf_page_view.js +191 -67
  145. package/lib/web/pdf_presentation_mode.js +99 -34
  146. package/lib/web/pdf_print_service.js +61 -13
  147. package/lib/web/pdf_rendering_queue.js +28 -9
  148. package/lib/web/pdf_sidebar.js +141 -81
  149. package/lib/web/pdf_sidebar_resizer.js +42 -16
  150. package/lib/web/pdf_single_page_viewer.js +74 -66
  151. package/lib/web/pdf_thumbnail_view.js +104 -33
  152. package/lib/web/pdf_thumbnail_viewer.js +66 -26
  153. package/lib/web/pdf_viewer.component.js +112 -32
  154. package/lib/web/pdf_viewer.js +91 -52
  155. package/lib/web/preferences.js +284 -89
  156. package/lib/web/secondary_toolbar.js +165 -40
  157. package/lib/web/text_layer_builder.js +134 -59
  158. package/lib/web/toolbar.js +78 -43
  159. package/lib/web/ui_utils.js +462 -136
  160. package/lib/web/view_history.js +215 -67
  161. package/lib/web/viewer_compatibility.js +4 -13
  162. package/package.json +5 -4
  163. package/web/pdf_viewer.css +79 -11
  164. package/web/pdf_viewer.js +6107 -3748
  165. package/web/pdf_viewer.js.map +1 -1
  166. package/lib/display/dom_utils.js +0 -309
  167. package/lib/test/unit/dom_utils_spec.js +0 -89
  168. package/lib/test/unit/fonts_spec.js +0 -81
  169. package/lib/web/dom_events.js +0 -137
@@ -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 2017 Mozilla Foundation
5
+ * Copyright 2019 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.
@@ -19,38 +19,155 @@
19
19
  * @licend The above is the entire license notice for the
20
20
  * Javascript code in this page
21
21
  */
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  Object.defineProperty(exports, "__esModule", {
25
25
  value: true
26
26
  });
27
- exports.SVGGraphics = undefined;
27
+ exports.SVGGraphics = void 0;
28
28
 
29
- var _util = require('../shared/util');
29
+ var _util = require("../shared/util");
30
30
 
31
- var _dom_utils = require('./dom_utils');
31
+ var _display_utils = require("./display_utils");
32
32
 
33
- var _is_node = require('../shared/is_node');
33
+ var _is_node = _interopRequireDefault(require("../shared/is_node"));
34
34
 
35
- var _is_node2 = _interopRequireDefault(_is_node);
35
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
36
36
 
37
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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) { 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; }
38
58
 
39
59
  var SVGGraphics = function SVGGraphics() {
40
60
  throw new Error('Not implemented: SVGGraphics');
41
61
  };
62
+
63
+ exports.SVGGraphics = SVGGraphics;
42
64
  {
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]), ")");
151
+ };
152
+
43
153
  var SVG_DEFAULTS = {
44
154
  fontStyle: 'normal',
45
155
  fontWeight: 'normal',
46
156
  fillColor: '#000000'
47
157
  };
48
- var convertImgDataToPng = function convertImgDataToPngClosure() {
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 () {
49
164
  var PNG_HEADER = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
50
165
  var CHUNK_WRAPPER_SIZE = 12;
51
166
  var crcTable = new Int32Array(256);
167
+
52
168
  for (var i = 0; i < 256; i++) {
53
169
  var c = i;
170
+
54
171
  for (var h = 0; h < 8; h++) {
55
172
  if (c & 1) {
56
173
  c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
@@ -58,17 +175,22 @@ var SVGGraphics = function SVGGraphics() {
58
175
  c = c >> 1 & 0x7fffffff;
59
176
  }
60
177
  }
178
+
61
179
  crcTable[i] = c;
62
180
  }
181
+
63
182
  function crc32(data, start, end) {
64
183
  var crc = -1;
65
- for (var i = start; i < end; i++) {
66
- var a = (crc ^ data[i]) & 0xff;
184
+
185
+ for (var _i = start; _i < end; _i++) {
186
+ var a = (crc ^ data[_i]) & 0xff;
67
187
  var b = crcTable[a];
68
188
  crc = crc >>> 8 ^ b;
69
189
  }
190
+
70
191
  return crc ^ -1;
71
192
  }
193
+
72
194
  function writePngChunk(type, body, data, offset) {
73
195
  var p = offset;
74
196
  var len = body.length;
@@ -90,33 +212,45 @@ var SVGGraphics = function SVGGraphics() {
90
212
  data[p + 2] = crc >> 8 & 0xff;
91
213
  data[p + 3] = crc & 0xff;
92
214
  }
215
+
93
216
  function adler32(data, start, end) {
94
217
  var a = 1;
95
218
  var b = 0;
96
- for (var i = start; i < end; ++i) {
97
- a = (a + (data[i] & 0xff)) % 65521;
219
+
220
+ for (var _i2 = start; _i2 < end; ++_i2) {
221
+ a = (a + (data[_i2] & 0xff)) % 65521;
98
222
  b = (b + a) % 65521;
99
223
  }
224
+
100
225
  return b << 16 | a;
101
226
  }
227
+
102
228
  function deflateSync(literals) {
103
- if (!(0, _is_node2.default)()) {
229
+ if (!(0, _is_node["default"])()) {
104
230
  return deflateSyncUncompressed(literals);
105
231
  }
232
+
106
233
  try {
107
234
  var input;
235
+
108
236
  if (parseInt(process.versions.node) >= 8) {
109
237
  input = literals;
110
238
  } else {
111
239
  input = new Buffer(literals);
112
240
  }
113
- var output = require('zlib').deflateSync(input, { level: 9 });
241
+
242
+ var output = require('zlib').deflateSync(input, {
243
+ level: 9
244
+ });
245
+
114
246
  return output instanceof Uint8Array ? output : new Uint8Array(output);
115
247
  } catch (e) {
116
248
  (0, _util.warn)('Not compressing PNG because zlib.deflateSync is unavailable: ' + e);
117
249
  }
250
+
118
251
  return deflateSyncUncompressed(literals);
119
252
  }
253
+
120
254
  function deflateSyncUncompressed(literals) {
121
255
  var len = literals.length;
122
256
  var maxBlockLength = 0xFFFF;
@@ -126,6 +260,7 @@ var SVGGraphics = function SVGGraphics() {
126
260
  idat[pi++] = 0x78;
127
261
  idat[pi++] = 0x9c;
128
262
  var pos = 0;
263
+
129
264
  while (len > maxBlockLength) {
130
265
  idat[pi++] = 0x00;
131
266
  idat[pi++] = 0xff;
@@ -137,6 +272,7 @@ var SVGGraphics = function SVGGraphics() {
137
272
  pos += maxBlockLength;
138
273
  len -= maxBlockLength;
139
274
  }
275
+
140
276
  idat[pi++] = 0x01;
141
277
  idat[pi++] = len & 0xff;
142
278
  idat[pi++] = len >> 8 & 0xff;
@@ -151,49 +287,59 @@ var SVGGraphics = function SVGGraphics() {
151
287
  idat[pi++] = adler & 0xff;
152
288
  return idat;
153
289
  }
290
+
154
291
  function encode(imgData, kind, forceDataSchema, isMask) {
155
292
  var width = imgData.width;
156
293
  var height = imgData.height;
157
294
  var bitDepth, colorType, lineSize;
158
295
  var bytes = imgData.data;
296
+
159
297
  switch (kind) {
160
298
  case _util.ImageKind.GRAYSCALE_1BPP:
161
299
  colorType = 0;
162
300
  bitDepth = 1;
163
301
  lineSize = width + 7 >> 3;
164
302
  break;
303
+
165
304
  case _util.ImageKind.RGB_24BPP:
166
305
  colorType = 2;
167
306
  bitDepth = 8;
168
307
  lineSize = width * 3;
169
308
  break;
309
+
170
310
  case _util.ImageKind.RGBA_32BPP:
171
311
  colorType = 6;
172
312
  bitDepth = 8;
173
313
  lineSize = width * 4;
174
314
  break;
315
+
175
316
  default:
176
317
  throw new Error('invalid format');
177
318
  }
319
+
178
320
  var literals = new Uint8Array((1 + lineSize) * height);
179
321
  var offsetLiterals = 0,
180
322
  offsetBytes = 0;
181
- var y, i;
182
- for (y = 0; y < height; ++y) {
323
+
324
+ for (var y = 0; y < height; ++y) {
183
325
  literals[offsetLiterals++] = 0;
184
326
  literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
185
327
  offsetBytes += lineSize;
186
328
  offsetLiterals += lineSize;
187
329
  }
330
+
188
331
  if (kind === _util.ImageKind.GRAYSCALE_1BPP && isMask) {
189
332
  offsetLiterals = 0;
190
- for (y = 0; y < height; y++) {
333
+
334
+ for (var _y = 0; _y < height; _y++) {
191
335
  offsetLiterals++;
192
- for (i = 0; i < lineSize; i++) {
336
+
337
+ for (var _i3 = 0; _i3 < lineSize; _i3++) {
193
338
  literals[offsetLiterals++] ^= 0xFF;
194
339
  }
195
340
  }
196
341
  }
342
+
197
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]);
198
344
  var idat = deflateSync(literals);
199
345
  var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
@@ -208,19 +354,27 @@ var SVGGraphics = function SVGGraphics() {
208
354
  writePngChunk('IEND', new Uint8Array(0), data, offset);
209
355
  return (0, _util.createObjectURL)(data, 'image/png', forceDataSchema);
210
356
  }
357
+
211
358
  return function convertImgDataToPng(imgData, forceDataSchema, isMask) {
212
359
  var kind = imgData.kind === undefined ? _util.ImageKind.GRAYSCALE_1BPP : imgData.kind;
213
360
  return encode(imgData, kind, forceDataSchema, isMask);
214
361
  };
215
362
  }();
216
- var SVGExtraState = function SVGExtraStateClosure() {
363
+
364
+ var SVGExtraState =
365
+ /*#__PURE__*/
366
+ function () {
217
367
  function SVGExtraState() {
368
+ _classCallCheck(this, SVGExtraState);
369
+
218
370
  this.fontSizeScale = 1;
219
371
  this.fontWeight = SVG_DEFAULTS.fontWeight;
220
372
  this.fontSize = 0;
221
373
  this.textMatrix = _util.IDENTITY_MATRIX;
222
374
  this.fontMatrix = _util.FONT_IDENTITY_MATRIX;
223
375
  this.leading = 0;
376
+ this.textRenderingMode = _util.TextRenderingMode.FILL;
377
+ this.textMatrixScale = 1;
224
378
  this.x = 0;
225
379
  this.y = 0;
226
380
  this.lineX = 0;
@@ -244,76 +398,34 @@ var SVGGraphics = function SVGGraphics() {
244
398
  this.clipGroup = null;
245
399
  this.maskId = '';
246
400
  }
247
- SVGExtraState.prototype = {
248
- clone: function SVGExtraState_clone() {
401
+
402
+ _createClass(SVGExtraState, [{
403
+ key: "clone",
404
+ value: function clone() {
249
405
  return Object.create(this);
250
- },
251
- setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
406
+ }
407
+ }, {
408
+ key: "setCurrentPoint",
409
+ value: function setCurrentPoint(x, y) {
252
410
  this.x = x;
253
411
  this.y = y;
254
412
  }
255
- };
413
+ }]);
414
+
256
415
  return SVGExtraState;
257
416
  }();
258
- exports.SVGGraphics = SVGGraphics = function SVGGraphicsClosure() {
259
- function opListToTree(opList) {
260
- var opTree = [];
261
- var tmp = [];
262
- var opListLen = opList.length;
263
- for (var x = 0; x < opListLen; x++) {
264
- if (opList[x].fn === 'save') {
265
- opTree.push({
266
- 'fnId': 92,
267
- 'fn': 'group',
268
- 'items': []
269
- });
270
- tmp.push(opTree);
271
- opTree = opTree[opTree.length - 1].items;
272
- continue;
273
- }
274
- if (opList[x].fn === 'restore') {
275
- opTree = tmp.pop();
276
- } else {
277
- opTree.push(opList[x]);
278
- }
279
- }
280
- return opTree;
281
- }
282
- function pf(value) {
283
- if (Number.isInteger(value)) {
284
- return value.toString();
285
- }
286
- var s = value.toFixed(10);
287
- var i = s.length - 1;
288
- if (s[i] !== '0') {
289
- return s;
290
- }
291
- do {
292
- i--;
293
- } while (s[i] === '0');
294
- return s.substr(0, s[i] === '.' ? i : i + 1);
295
- }
296
- function pm(m) {
297
- if (m[4] === 0 && m[5] === 0) {
298
- if (m[1] === 0 && m[2] === 0) {
299
- if (m[0] === 1 && m[3] === 1) {
300
- return '';
301
- }
302
- return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
303
- }
304
- if (m[0] === m[3] && m[1] === -m[2]) {
305
- var a = Math.acos(m[0]) * 180 / Math.PI;
306
- return 'rotate(' + pf(a) + ')';
307
- }
308
- } else {
309
- if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
310
- return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
311
- }
312
- }
313
- return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
314
- }
417
+
418
+ var clipCount = 0;
419
+ var maskCount = 0;
420
+ var shadingCount = 0;
421
+
422
+ exports.SVGGraphics = SVGGraphics =
423
+ /*#__PURE__*/
424
+ function () {
315
425
  function SVGGraphics(commonObjs, objs, forceDataSchema) {
316
- this.svgFactory = new _dom_utils.DOMSVGFactory();
426
+ _classCallCheck(this, SVGGraphics);
427
+
428
+ this.svgFactory = new _display_utils.DOMSVGFactory();
317
429
  this.current = new SVGExtraState();
318
430
  this.transformMatrix = _util.IDENTITY_MATRIX;
319
431
  this.transformStack = [];
@@ -326,381 +438,583 @@ var SVGGraphics = function SVGGraphics() {
326
438
  this.embeddedFonts = Object.create(null);
327
439
  this.cssStyle = null;
328
440
  this.forceDataSchema = !!forceDataSchema;
441
+ this._operatorIdMapping = [];
442
+
443
+ for (var op in _util.OPS) {
444
+ this._operatorIdMapping[_util.OPS[op]] = op;
445
+ }
329
446
  }
330
- var XML_NS = 'http://www.w3.org/XML/1998/namespace';
331
- var XLINK_NS = 'http://www.w3.org/1999/xlink';
332
- var LINE_CAP_STYLES = ['butt', 'round', 'square'];
333
- var LINE_JOIN_STYLES = ['miter', 'round', 'bevel'];
334
- var clipCount = 0;
335
- var maskCount = 0;
336
- SVGGraphics.prototype = {
337
- save: function SVGGraphics_save() {
447
+
448
+ _createClass(SVGGraphics, [{
449
+ key: "save",
450
+ value: function save() {
338
451
  this.transformStack.push(this.transformMatrix);
339
452
  var old = this.current;
340
453
  this.extraStack.push(old);
341
454
  this.current = old.clone();
342
- },
343
- restore: function SVGGraphics_restore() {
455
+ }
456
+ }, {
457
+ key: "restore",
458
+ value: function restore() {
344
459
  this.transformMatrix = this.transformStack.pop();
345
460
  this.current = this.extraStack.pop();
346
461
  this.pendingClip = null;
347
462
  this.tgrp = null;
348
- },
349
- group: function SVGGraphics_group(items) {
463
+ }
464
+ }, {
465
+ key: "group",
466
+ value: function group(items) {
350
467
  this.save();
351
468
  this.executeOpTree(items);
352
469
  this.restore();
353
- },
354
- loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
470
+ }
471
+ }, {
472
+ key: "loadDependencies",
473
+ value: function loadDependencies(operatorList) {
355
474
  var _this = this;
356
475
 
357
476
  var fnArray = operatorList.fnArray;
358
- var fnArrayLen = fnArray.length;
359
477
  var argsArray = operatorList.argsArray;
360
- for (var i = 0; i < fnArrayLen; i++) {
361
- if (_util.OPS.dependency === fnArray[i]) {
362
- var deps = argsArray[i];
363
- for (var n = 0, nn = deps.length; n < nn; n++) {
364
- var obj = deps[n];
365
- var common = obj.substring(0, 2) === 'g_';
366
- var promise;
367
- if (common) {
368
- promise = new Promise(function (resolve) {
369
- _this.commonObjs.get(obj, resolve);
370
- });
371
- } else {
372
- promise = new Promise(function (resolve) {
373
- _this.objs.get(obj, resolve);
374
- });
478
+
479
+ for (var i = 0, ii = fnArray.length; i < ii; i++) {
480
+ if (fnArray[i] !== _util.OPS.dependency) {
481
+ continue;
482
+ }
483
+
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;
375
513
  }
376
- this.current.dependencies.push(promise);
377
514
  }
378
515
  }
379
516
  }
517
+
380
518
  return Promise.all(this.current.dependencies);
381
- },
382
- transform: function SVGGraphics_transform(a, b, c, d, e, f) {
519
+ }
520
+ }, {
521
+ key: "transform",
522
+ value: function transform(a, b, c, d, e, f) {
383
523
  var transformMatrix = [a, b, c, d, e, f];
384
524
  this.transformMatrix = _util.Util.transform(this.transformMatrix, transformMatrix);
385
525
  this.tgrp = null;
386
- },
387
- getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
526
+ }
527
+ }, {
528
+ key: "getSVG",
529
+ value: function getSVG(operatorList, viewport) {
388
530
  var _this2 = this;
389
531
 
390
532
  this.viewport = viewport;
533
+
391
534
  var svgElement = this._initialize(viewport);
535
+
392
536
  return this.loadDependencies(operatorList).then(function () {
393
537
  _this2.transformMatrix = _util.IDENTITY_MATRIX;
394
- var opTree = _this2.convertOpList(operatorList);
395
- _this2.executeOpTree(opTree);
538
+
539
+ _this2.executeOpTree(_this2.convertOpList(operatorList));
540
+
396
541
  return svgElement;
397
542
  });
398
- },
399
- convertOpList: function SVGGraphics_convertOpList(operatorList) {
543
+ }
544
+ }, {
545
+ key: "convertOpList",
546
+ value: function convertOpList(operatorList) {
547
+ var operatorIdMapping = this._operatorIdMapping;
400
548
  var argsArray = operatorList.argsArray;
401
549
  var fnArray = operatorList.fnArray;
402
- var fnArrayLen = fnArray.length;
403
- var REVOPS = [];
404
550
  var opList = [];
405
- for (var op in _util.OPS) {
406
- REVOPS[_util.OPS[op]] = op;
407
- }
408
- for (var x = 0; x < fnArrayLen; x++) {
409
- var fnId = fnArray[x];
551
+
552
+ for (var i = 0, ii = fnArray.length; i < ii; i++) {
553
+ var fnId = fnArray[i];
410
554
  opList.push({
411
555
  'fnId': fnId,
412
- 'fn': REVOPS[fnId],
413
- 'args': argsArray[x]
556
+ 'fn': operatorIdMapping[fnId],
557
+ 'args': argsArray[i]
414
558
  });
415
559
  }
560
+
416
561
  return opListToTree(opList);
417
- },
418
- executeOpTree: function SVGGraphics_executeOpTree(opTree) {
419
- var opTreeLen = opTree.length;
420
- for (var x = 0; x < opTreeLen; x++) {
421
- var fn = opTree[x].fn;
422
- var fnId = opTree[x].fnId;
423
- var args = opTree[x].args;
424
- switch (fnId | 0) {
425
- case _util.OPS.beginText:
426
- this.beginText();
427
- break;
428
- case _util.OPS.dependency:
429
- break;
430
- case _util.OPS.setLeading:
431
- this.setLeading(args);
432
- break;
433
- case _util.OPS.setLeadingMoveText:
434
- this.setLeadingMoveText(args[0], args[1]);
435
- break;
436
- case _util.OPS.setFont:
437
- this.setFont(args);
438
- break;
439
- case _util.OPS.showText:
440
- this.showText(args[0]);
441
- break;
442
- case _util.OPS.showSpacedText:
443
- this.showText(args[0]);
444
- break;
445
- case _util.OPS.endText:
446
- this.endText();
447
- break;
448
- case _util.OPS.moveText:
449
- this.moveText(args[0], args[1]);
450
- break;
451
- case _util.OPS.setCharSpacing:
452
- this.setCharSpacing(args[0]);
453
- break;
454
- case _util.OPS.setWordSpacing:
455
- this.setWordSpacing(args[0]);
456
- break;
457
- case _util.OPS.setHScale:
458
- this.setHScale(args[0]);
459
- break;
460
- case _util.OPS.setTextMatrix:
461
- this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
462
- break;
463
- case _util.OPS.setTextRise:
464
- this.setTextRise(args[0]);
465
- break;
466
- case _util.OPS.setLineWidth:
467
- this.setLineWidth(args[0]);
468
- break;
469
- case _util.OPS.setLineJoin:
470
- this.setLineJoin(args[0]);
471
- break;
472
- case _util.OPS.setLineCap:
473
- this.setLineCap(args[0]);
474
- break;
475
- case _util.OPS.setMiterLimit:
476
- this.setMiterLimit(args[0]);
477
- break;
478
- case _util.OPS.setFillRGBColor:
479
- this.setFillRGBColor(args[0], args[1], args[2]);
480
- break;
481
- case _util.OPS.setStrokeRGBColor:
482
- this.setStrokeRGBColor(args[0], args[1], args[2]);
483
- break;
484
- case _util.OPS.setDash:
485
- this.setDash(args[0], args[1]);
486
- break;
487
- case _util.OPS.setGState:
488
- this.setGState(args[0]);
489
- break;
490
- case _util.OPS.fill:
491
- this.fill();
492
- break;
493
- case _util.OPS.eoFill:
494
- this.eoFill();
495
- break;
496
- case _util.OPS.stroke:
497
- this.stroke();
498
- break;
499
- case _util.OPS.fillStroke:
500
- this.fillStroke();
501
- break;
502
- case _util.OPS.eoFillStroke:
503
- this.eoFillStroke();
504
- break;
505
- case _util.OPS.clip:
506
- this.clip('nonzero');
507
- break;
508
- case _util.OPS.eoClip:
509
- this.clip('evenodd');
510
- break;
511
- case _util.OPS.paintSolidColorImageMask:
512
- this.paintSolidColorImageMask();
513
- break;
514
- case _util.OPS.paintJpegXObject:
515
- this.paintJpegXObject(args[0], args[1], args[2]);
516
- break;
517
- case _util.OPS.paintImageXObject:
518
- this.paintImageXObject(args[0]);
519
- break;
520
- case _util.OPS.paintInlineImageXObject:
521
- this.paintInlineImageXObject(args[0]);
522
- break;
523
- case _util.OPS.paintImageMaskXObject:
524
- this.paintImageMaskXObject(args[0]);
525
- break;
526
- case _util.OPS.paintFormXObjectBegin:
527
- this.paintFormXObjectBegin(args[0], args[1]);
528
- break;
529
- case _util.OPS.paintFormXObjectEnd:
530
- this.paintFormXObjectEnd();
531
- break;
532
- case _util.OPS.closePath:
533
- this.closePath();
534
- break;
535
- case _util.OPS.closeStroke:
536
- this.closeStroke();
537
- break;
538
- case _util.OPS.closeFillStroke:
539
- this.closeFillStroke();
540
- break;
541
- case _util.OPS.closeEOFillStroke:
542
- this.closeEOFillStroke();
543
- break;
544
- case _util.OPS.nextLine:
545
- this.nextLine();
546
- break;
547
- case _util.OPS.transform:
548
- this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
549
- break;
550
- case _util.OPS.constructPath:
551
- this.constructPath(args[0], args[1]);
552
- break;
553
- case _util.OPS.endPath:
554
- this.endPath();
555
- break;
556
- case 92:
557
- this.group(opTree[x].items);
558
- break;
559
- default:
560
- (0, _util.warn)('Unimplemented operator ' + fn);
561
- break;
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;
668
+
669
+ case _util.OPS.shadingFill:
670
+ this.shadingFill(args[0]);
671
+ break;
672
+
673
+ case _util.OPS.setDash:
674
+ this.setDash(args[0], args[1]);
675
+ break;
676
+
677
+ case _util.OPS.setRenderingIntent:
678
+ this.setRenderingIntent(args[0]);
679
+ break;
680
+
681
+ case _util.OPS.setFlatness:
682
+ this.setFlatness(args[0]);
683
+ break;
684
+
685
+ case _util.OPS.setGState:
686
+ this.setGState(args[0]);
687
+ break;
688
+
689
+ case _util.OPS.fill:
690
+ this.fill();
691
+ break;
692
+
693
+ case _util.OPS.eoFill:
694
+ this.eoFill();
695
+ break;
696
+
697
+ case _util.OPS.stroke:
698
+ this.stroke();
699
+ break;
700
+
701
+ case _util.OPS.fillStroke:
702
+ this.fillStroke();
703
+ break;
704
+
705
+ case _util.OPS.eoFillStroke:
706
+ this.eoFillStroke();
707
+ break;
708
+
709
+ case _util.OPS.clip:
710
+ this.clip('nonzero');
711
+ break;
712
+
713
+ case _util.OPS.eoClip:
714
+ this.clip('evenodd');
715
+ break;
716
+
717
+ case _util.OPS.paintSolidColorImageMask:
718
+ this.paintSolidColorImageMask();
719
+ break;
720
+
721
+ case _util.OPS.paintJpegXObject:
722
+ this.paintJpegXObject(args[0], args[1], args[2]);
723
+ break;
724
+
725
+ case _util.OPS.paintImageXObject:
726
+ this.paintImageXObject(args[0]);
727
+ break;
728
+
729
+ case _util.OPS.paintInlineImageXObject:
730
+ this.paintInlineImageXObject(args[0]);
731
+ break;
732
+
733
+ case _util.OPS.paintImageMaskXObject:
734
+ this.paintImageMaskXObject(args[0]);
735
+ break;
736
+
737
+ case _util.OPS.paintFormXObjectBegin:
738
+ this.paintFormXObjectBegin(args[0], args[1]);
739
+ break;
740
+
741
+ case _util.OPS.paintFormXObjectEnd:
742
+ this.paintFormXObjectEnd();
743
+ break;
744
+
745
+ case _util.OPS.closePath:
746
+ this.closePath();
747
+ break;
748
+
749
+ case _util.OPS.closeStroke:
750
+ this.closeStroke();
751
+ break;
752
+
753
+ case _util.OPS.closeFillStroke:
754
+ this.closeFillStroke();
755
+ break;
756
+
757
+ case _util.OPS.closeEOFillStroke:
758
+ this.closeEOFillStroke();
759
+ break;
760
+
761
+ case _util.OPS.nextLine:
762
+ this.nextLine();
763
+ break;
764
+
765
+ case _util.OPS.transform:
766
+ this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
767
+ break;
768
+
769
+ case _util.OPS.constructPath:
770
+ this.constructPath(args[0], args[1]);
771
+ break;
772
+
773
+ case _util.OPS.endPath:
774
+ this.endPath();
775
+ break;
776
+
777
+ case 92:
778
+ this.group(opTreeElement.items);
779
+ break;
780
+
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
+ }
562
798
  }
563
799
  }
564
- },
565
- setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
800
+ }
801
+ }, {
802
+ key: "setWordSpacing",
803
+ value: function setWordSpacing(wordSpacing) {
566
804
  this.current.wordSpacing = wordSpacing;
567
- },
568
- setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
805
+ }
806
+ }, {
807
+ key: "setCharSpacing",
808
+ value: function setCharSpacing(charSpacing) {
569
809
  this.current.charSpacing = charSpacing;
570
- },
571
- nextLine: function SVGGraphics_nextLine() {
810
+ }
811
+ }, {
812
+ key: "nextLine",
813
+ value: function nextLine() {
572
814
  this.moveText(0, this.current.leading);
573
- },
574
- setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
815
+ }
816
+ }, {
817
+ key: "setTextMatrix",
818
+ value: function setTextMatrix(a, b, c, d, e, f) {
575
819
  var current = this.current;
576
- this.current.textMatrix = this.current.lineMatrix = [a, b, c, d, e, f];
577
- this.current.x = this.current.lineX = 0;
578
- this.current.y = this.current.lineY = 0;
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;
579
824
  current.xcoords = [];
580
825
  current.tspan = this.svgFactory.createElement('svg:tspan');
581
826
  current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
582
- current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
827
+ current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
583
828
  current.tspan.setAttributeNS(null, 'y', pf(-current.y));
584
829
  current.txtElement = this.svgFactory.createElement('svg:text');
585
830
  current.txtElement.appendChild(current.tspan);
586
- },
587
- beginText: function SVGGraphics_beginText() {
588
- this.current.x = this.current.lineX = 0;
589
- this.current.y = this.current.lineY = 0;
590
- this.current.textMatrix = _util.IDENTITY_MATRIX;
591
- this.current.lineMatrix = _util.IDENTITY_MATRIX;
592
- this.current.tspan = this.svgFactory.createElement('svg:tspan');
593
- this.current.txtElement = this.svgFactory.createElement('svg:text');
594
- this.current.txtgrp = this.svgFactory.createElement('svg:g');
595
- this.current.xcoords = [];
596
- },
597
- moveText: function SVGGraphics_moveText(x, y) {
831
+ }
832
+ }, {
833
+ key: "beginText",
834
+ value: function beginText() {
598
835
  var current = this.current;
599
- this.current.x = this.current.lineX += x;
600
- this.current.y = this.current.lineY += y;
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;
601
852
  current.xcoords = [];
602
853
  current.tspan = this.svgFactory.createElement('svg:tspan');
603
854
  current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
604
- current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
855
+ current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
605
856
  current.tspan.setAttributeNS(null, 'y', pf(-current.y));
606
- },
607
- showText: function SVGGraphics_showText(glyphs) {
857
+ }
858
+ }, {
859
+ key: "showText",
860
+ value: function showText(glyphs) {
608
861
  var current = this.current;
609
862
  var font = current.font;
610
863
  var fontSize = current.fontSize;
864
+
611
865
  if (fontSize === 0) {
612
866
  return;
613
867
  }
868
+
614
869
  var charSpacing = current.charSpacing;
615
870
  var wordSpacing = current.wordSpacing;
616
871
  var fontDirection = current.fontDirection;
617
872
  var textHScale = current.textHScale * fontDirection;
618
- var glyphsLength = glyphs.length;
619
873
  var vertical = font.vertical;
620
874
  var widthAdvanceScale = fontSize * current.fontMatrix[0];
621
- var x = 0,
622
- i;
623
- for (i = 0; i < glyphsLength; ++i) {
624
- var glyph = glyphs[i];
625
- if (glyph === null) {
626
- x += fontDirection * wordSpacing;
627
- continue;
628
- } else if ((0, _util.isNum)(glyph)) {
629
- x += -glyph * fontSize * 0.001;
630
- continue;
631
- }
632
- var width = glyph.width;
633
- var character = glyph.fontChar;
634
- var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
635
- var charWidth = width * widthAdvanceScale + spacing * fontDirection;
636
- if (!glyph.isInFont && !font.missingFile) {
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;
637
904
  x += charWidth;
638
- continue;
639
905
  }
640
- current.xcoords.push(current.x + x * textHScale);
641
- current.tspan.textContent += character;
642
- x += charWidth;
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
+ }
643
919
  }
920
+
644
921
  if (vertical) {
645
922
  current.y -= x * textHScale;
646
923
  } else {
647
924
  current.x += x * textHScale;
648
925
  }
926
+
649
927
  current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
650
928
  current.tspan.setAttributeNS(null, 'y', pf(-current.y));
651
929
  current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
652
- current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
930
+ current.tspan.setAttributeNS(null, 'font-size', "".concat(pf(current.fontSize), "px"));
931
+
653
932
  if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
654
933
  current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
655
934
  }
935
+
656
936
  if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
657
937
  current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
658
938
  }
659
- if (current.fillColor !== SVG_DEFAULTS.fillColor) {
660
- current.tspan.setAttributeNS(null, 'fill', current.fillColor);
939
+
940
+ var fillStrokeMode = current.textRenderingMode & _util.TextRenderingMode.FILL_STROKE_MASK;
941
+
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
+ }
946
+
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');
661
954
  }
955
+
956
+ if (fillStrokeMode === _util.TextRenderingMode.STROKE || fillStrokeMode === _util.TextRenderingMode.FILL_STROKE) {
957
+ var lineWidthScale = 1 / (current.textMatrixScale || 1);
958
+
959
+ this._setStrokeAttributes(current.tspan, lineWidthScale);
960
+ }
961
+
662
962
  var textMatrix = current.textMatrix;
963
+
663
964
  if (current.textRise !== 0) {
664
965
  textMatrix = textMatrix.slice();
665
966
  textMatrix[5] += current.textRise;
666
967
  }
667
- current.txtElement.setAttributeNS(null, 'transform', pm(textMatrix) + ' scale(1, -1)');
968
+
969
+ current.txtElement.setAttributeNS(null, 'transform', "".concat(pm(textMatrix), " scale(1, -1)"));
668
970
  current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
669
971
  current.txtElement.appendChild(current.tspan);
670
972
  current.txtgrp.appendChild(current.txtElement);
973
+
671
974
  this._ensureTransformGroup().appendChild(current.txtElement);
672
- },
673
- setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
975
+ }
976
+ }, {
977
+ key: "setLeadingMoveText",
978
+ value: function setLeadingMoveText(x, y) {
674
979
  this.setLeading(-y);
675
980
  this.moveText(x, y);
676
- },
677
- addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
981
+ }
982
+ }, {
983
+ key: "addFontStyle",
984
+ value: function addFontStyle(fontObj) {
678
985
  if (!this.cssStyle) {
679
986
  this.cssStyle = this.svgFactory.createElement('svg:style');
680
987
  this.cssStyle.setAttributeNS(null, 'type', 'text/css');
681
988
  this.defs.appendChild(this.cssStyle);
682
989
  }
990
+
683
991
  var url = (0, _util.createObjectURL)(fontObj.data, fontObj.mimetype, this.forceDataSchema);
684
- this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
685
- },
686
- setFont: function SVGGraphics_setFont(details) {
992
+ this.cssStyle.textContent += "@font-face { font-family: \"".concat(fontObj.loadedName, "\";") + " src: url(".concat(url, "); }\n");
993
+ }
994
+ }, {
995
+ key: "setFont",
996
+ value: function setFont(details) {
687
997
  var current = this.current;
688
998
  var fontObj = this.commonObjs.get(details[0]);
689
999
  var size = details[1];
690
- this.current.font = fontObj;
1000
+ current.font = fontObj;
1001
+
691
1002
  if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
692
1003
  this.addFontStyle(fontObj);
693
1004
  this.embeddedFonts[fontObj.loadedName] = fontObj;
694
1005
  }
1006
+
695
1007
  current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : _util.FONT_IDENTITY_MATRIX;
696
1008
  var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
697
1009
  var italic = fontObj.italic ? 'italic' : 'normal';
1010
+
698
1011
  if (size < 0) {
699
1012
  size = -size;
700
1013
  current.fontDirection = -1;
701
1014
  } else {
702
1015
  current.fontDirection = 1;
703
1016
  }
1017
+
704
1018
  current.fontSize = size;
705
1019
  current.fontFamily = fontObj.loadedName;
706
1020
  current.fontWeight = bold;
@@ -708,242 +1022,619 @@ var SVGGraphics = function SVGGraphics() {
708
1022
  current.tspan = this.svgFactory.createElement('svg:tspan');
709
1023
  current.tspan.setAttributeNS(null, 'y', pf(-current.y));
710
1024
  current.xcoords = [];
711
- },
712
- endText: function SVGGraphics_endText() {},
713
- setLineWidth: function SVGGraphics_setLineWidth(width) {
714
- this.current.lineWidth = width;
715
- },
716
- setLineCap: function SVGGraphics_setLineCap(style) {
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();
1035
+ }
1036
+ }
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) {
717
1047
  this.current.lineCap = LINE_CAP_STYLES[style];
718
- },
719
- setLineJoin: function SVGGraphics_setLineJoin(style) {
1048
+ }
1049
+ }, {
1050
+ key: "setLineJoin",
1051
+ value: function setLineJoin(style) {
720
1052
  this.current.lineJoin = LINE_JOIN_STYLES[style];
721
- },
722
- setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
1053
+ }
1054
+ }, {
1055
+ key: "setMiterLimit",
1056
+ value: function setMiterLimit(limit) {
723
1057
  this.current.miterLimit = limit;
724
- },
725
- setStrokeAlpha: function SVGGraphics_setStrokeAlpha(strokeAlpha) {
1058
+ }
1059
+ }, {
1060
+ key: "setStrokeAlpha",
1061
+ value: function setStrokeAlpha(strokeAlpha) {
726
1062
  this.current.strokeAlpha = strokeAlpha;
727
- },
728
- setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
729
- var color = _util.Util.makeCssRgb(r, g, b);
730
- this.current.strokeColor = color;
731
- },
732
- setFillAlpha: function SVGGraphics_setFillAlpha(fillAlpha) {
1063
+ }
1064
+ }, {
1065
+ key: "setStrokeRGBColor",
1066
+ value: function setStrokeRGBColor(r, g, b) {
1067
+ this.current.strokeColor = _util.Util.makeCssRgb(r, g, b);
1068
+ }
1069
+ }, {
1070
+ key: "setFillAlpha",
1071
+ value: function setFillAlpha(fillAlpha) {
733
1072
  this.current.fillAlpha = fillAlpha;
734
- },
735
- setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
736
- var color = _util.Util.makeCssRgb(r, g, b);
737
- this.current.fillColor = color;
1073
+ }
1074
+ }, {
1075
+ key: "setFillRGBColor",
1076
+ value: function setFillRGBColor(r, g, b) {
1077
+ this.current.fillColor = _util.Util.makeCssRgb(r, g, b);
738
1078
  this.current.tspan = this.svgFactory.createElement('svg:tspan');
739
1079
  this.current.xcoords = [];
740
- },
741
- setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
1080
+ }
1081
+ }, {
1082
+ key: "setStrokeColorN",
1083
+ value: function setStrokeColorN(args) {
1084
+ this.current.strokeColor = this._makeColorN_Pattern(args);
1085
+ }
1086
+ }, {
1087
+ key: "setFillColorN",
1088
+ value: function setFillColorN(args) {
1089
+ this.current.fillColor = this._makeColorN_Pattern(args);
1090
+ }
1091
+ }, {
1092
+ key: "shadingFill",
1093
+ value: function shadingFill(args) {
1094
+ var width = this.viewport.width;
1095
+ var height = this.viewport.height;
1096
+
1097
+ var inv = _util.Util.inverseTransform(this.transformMatrix);
1098
+
1099
+ var bl = _util.Util.applyTransform([0, 0], inv);
1100
+
1101
+ var br = _util.Util.applyTransform([0, height], inv);
1102
+
1103
+ var ul = _util.Util.applyTransform([width, 0], inv);
1104
+
1105
+ var ur = _util.Util.applyTransform([width, height], inv);
1106
+
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));
1117
+
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
+ }
1126
+
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
+ }
1185
+
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';
1273
+
1274
+ default:
1275
+ throw new Error("Unknown IR type: ".concat(args[0]));
1276
+ }
1277
+ }
1278
+ }, {
1279
+ key: "setDash",
1280
+ value: function setDash(dashArray, dashPhase) {
742
1281
  this.current.dashArray = dashArray;
743
1282
  this.current.dashPhase = dashPhase;
744
- },
745
- constructPath: function SVGGraphics_constructPath(ops, args) {
1283
+ }
1284
+ }, {
1285
+ key: "constructPath",
1286
+ value: function constructPath(ops, args) {
746
1287
  var current = this.current;
747
1288
  var x = current.x,
748
1289
  y = current.y;
749
- current.path = this.svgFactory.createElement('svg:path');
750
1290
  var d = [];
751
- var opLength = ops.length;
752
- for (var i = 0, j = 0; i < opLength; i++) {
753
- switch (ops[i] | 0) {
754
- case _util.OPS.rectangle:
755
- x = args[j++];
756
- y = args[j++];
757
- var width = args[j++];
758
- var height = args[j++];
759
- var xw = x + width;
760
- var yh = y + height;
761
- d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
762
- break;
763
- case _util.OPS.moveTo:
764
- x = args[j++];
765
- y = args[j++];
766
- d.push('M', pf(x), pf(y));
767
- break;
768
- case _util.OPS.lineTo:
769
- x = args[j++];
770
- y = args[j++];
771
- d.push('L', pf(x), pf(y));
772
- break;
773
- case _util.OPS.curveTo:
774
- x = args[j + 4];
775
- y = args[j + 5];
776
- d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
777
- j += 6;
778
- break;
779
- case _util.OPS.curveTo2:
780
- x = args[j + 2];
781
- y = args[j + 3];
782
- d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
783
- j += 4;
784
- break;
785
- case _util.OPS.curveTo3:
786
- x = args[j + 2];
787
- y = args[j + 3];
788
- d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
789
- j += 4;
790
- break;
791
- case _util.OPS.closePath:
792
- d.push('Z');
793
- break;
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
+ }
794
1361
  }
795
1362
  }
796
- current.path.setAttributeNS(null, 'd', d.join(' '));
1363
+
1364
+ d = d.join(' ');
1365
+
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');
1370
+
1371
+ this._ensureTransformGroup().appendChild(current.path);
1372
+ }
1373
+
1374
+ current.path.setAttributeNS(null, 'd', d);
797
1375
  current.path.setAttributeNS(null, 'fill', 'none');
798
- this._ensureTransformGroup().appendChild(current.path);
799
1376
  current.element = current.path;
800
1377
  current.setCurrentPoint(x, y);
801
- },
802
- endPath: function SVGGraphics_endPath() {
1378
+ }
1379
+ }, {
1380
+ key: "endPath",
1381
+ value: function endPath() {
1382
+ var current = this.current;
1383
+ current.path = null;
1384
+
803
1385
  if (!this.pendingClip) {
804
1386
  return;
805
1387
  }
806
- var current = this.current;
807
- var clipId = 'clippath' + clipCount;
808
- clipCount++;
1388
+
1389
+ if (!current.element) {
1390
+ this.pendingClip = null;
1391
+ return;
1392
+ }
1393
+
1394
+ var clipId = "clippath".concat(clipCount++);
809
1395
  var clipPath = this.svgFactory.createElement('svg:clipPath');
810
1396
  clipPath.setAttributeNS(null, 'id', clipId);
811
1397
  clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
812
- var clipElement = current.element.cloneNode();
1398
+ var clipElement = current.element.cloneNode(true);
1399
+
813
1400
  if (this.pendingClip === 'evenodd') {
814
1401
  clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
815
1402
  } else {
816
1403
  clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
817
1404
  }
1405
+
818
1406
  this.pendingClip = null;
819
1407
  clipPath.appendChild(clipElement);
820
1408
  this.defs.appendChild(clipPath);
1409
+
821
1410
  if (current.activeClipUrl) {
822
1411
  current.clipGroup = null;
823
1412
  this.extraStack.forEach(function (prev) {
824
1413
  prev.clipGroup = null;
825
1414
  });
1415
+ clipPath.setAttributeNS(null, 'clip-path', current.activeClipUrl);
826
1416
  }
827
- current.activeClipUrl = 'url(#' + clipId + ')';
1417
+
1418
+ current.activeClipUrl = "url(#".concat(clipId, ")");
828
1419
  this.tgrp = null;
829
- },
830
- clip: function SVGGraphics_clip(type) {
1420
+ }
1421
+ }, {
1422
+ key: "clip",
1423
+ value: function clip(type) {
831
1424
  this.pendingClip = type;
832
- },
833
- closePath: function SVGGraphics_closePath() {
1425
+ }
1426
+ }, {
1427
+ key: "closePath",
1428
+ value: function closePath() {
834
1429
  var current = this.current;
1430
+
835
1431
  if (current.path) {
836
- var d = current.path.getAttributeNS(null, 'd');
837
- d += 'Z';
1432
+ var d = "".concat(current.path.getAttributeNS(null, 'd'), "Z");
838
1433
  current.path.setAttributeNS(null, 'd', d);
839
1434
  }
840
- },
841
- setLeading: function SVGGraphics_setLeading(leading) {
1435
+ }
1436
+ }, {
1437
+ key: "setLeading",
1438
+ value: function setLeading(leading) {
842
1439
  this.current.leading = -leading;
843
- },
844
- setTextRise: function SVGGraphics_setTextRise(textRise) {
1440
+ }
1441
+ }, {
1442
+ key: "setTextRise",
1443
+ value: function setTextRise(textRise) {
845
1444
  this.current.textRise = textRise;
846
- },
847
- setHScale: function SVGGraphics_setHScale(scale) {
1445
+ }
1446
+ }, {
1447
+ key: "setTextRenderingMode",
1448
+ value: function setTextRenderingMode(textRenderingMode) {
1449
+ this.current.textRenderingMode = textRenderingMode;
1450
+ }
1451
+ }, {
1452
+ key: "setHScale",
1453
+ value: function setHScale(scale) {
848
1454
  this.current.textHScale = scale / 100;
849
- },
850
- setGState: function SVGGraphics_setGState(states) {
851
- for (var i = 0, ii = states.length; i < ii; i++) {
852
- var state = states[i];
853
- var key = state[0];
854
- var value = state[1];
855
- switch (key) {
856
- case 'LW':
857
- this.setLineWidth(value);
858
- break;
859
- case 'LC':
860
- this.setLineCap(value);
861
- break;
862
- case 'LJ':
863
- this.setLineJoin(value);
864
- break;
865
- case 'ML':
866
- this.setMiterLimit(value);
867
- break;
868
- case 'D':
869
- this.setDash(value[0], value[1]);
870
- break;
871
- case 'Font':
872
- this.setFont(value);
873
- break;
874
- case 'CA':
875
- this.setStrokeAlpha(value);
876
- break;
877
- case 'ca':
878
- this.setFillAlpha(value);
879
- break;
880
- default:
881
- (0, _util.warn)('Unimplemented graphic state ' + key);
882
- break;
1455
+ }
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
+ }
883
1533
  }
884
1534
  }
885
- },
886
- fill: function SVGGraphics_fill() {
1535
+ }
1536
+ }, {
1537
+ key: "fill",
1538
+ value: function fill() {
887
1539
  var current = this.current;
1540
+
888
1541
  if (current.element) {
889
1542
  current.element.setAttributeNS(null, 'fill', current.fillColor);
890
1543
  current.element.setAttributeNS(null, 'fill-opacity', current.fillAlpha);
1544
+ this.endPath();
891
1545
  }
892
- },
893
- stroke: function SVGGraphics_stroke() {
1546
+ }
1547
+ }, {
1548
+ key: "stroke",
1549
+ value: function stroke() {
894
1550
  var current = this.current;
1551
+
895
1552
  if (current.element) {
896
- current.element.setAttributeNS(null, 'stroke', current.strokeColor);
897
- current.element.setAttributeNS(null, 'stroke-opacity', current.strokeAlpha);
898
- current.element.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
899
- current.element.setAttributeNS(null, 'stroke-linecap', current.lineCap);
900
- current.element.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
901
- current.element.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
902
- current.element.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
903
- current.element.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
1553
+ this._setStrokeAttributes(current.element);
1554
+
904
1555
  current.element.setAttributeNS(null, 'fill', 'none');
1556
+ this.endPath();
1557
+ }
1558
+ }
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
+ });
905
1570
  }
906
- },
907
- eoFill: function SVGGraphics_eoFill() {
1571
+
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() {
908
1584
  if (this.current.element) {
909
1585
  this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
910
1586
  }
1587
+
911
1588
  this.fill();
912
- },
913
- fillStroke: function SVGGraphics_fillStroke() {
1589
+ }
1590
+ }, {
1591
+ key: "fillStroke",
1592
+ value: function fillStroke() {
914
1593
  this.stroke();
915
1594
  this.fill();
916
- },
917
- eoFillStroke: function SVGGraphics_eoFillStroke() {
1595
+ }
1596
+ }, {
1597
+ key: "eoFillStroke",
1598
+ value: function eoFillStroke() {
918
1599
  if (this.current.element) {
919
1600
  this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
920
1601
  }
1602
+
921
1603
  this.fillStroke();
922
- },
923
- closeStroke: function SVGGraphics_closeStroke() {
1604
+ }
1605
+ }, {
1606
+ key: "closeStroke",
1607
+ value: function closeStroke() {
924
1608
  this.closePath();
925
1609
  this.stroke();
926
- },
927
- closeFillStroke: function SVGGraphics_closeFillStroke() {
1610
+ }
1611
+ }, {
1612
+ key: "closeFillStroke",
1613
+ value: function closeFillStroke() {
928
1614
  this.closePath();
929
1615
  this.fillStroke();
930
- },
931
- closeEOFillStroke: function closeEOFillStroke() {
1616
+ }
1617
+ }, {
1618
+ key: "closeEOFillStroke",
1619
+ value: function closeEOFillStroke() {
932
1620
  this.closePath();
933
1621
  this.eoFillStroke();
934
- },
935
-
936
- paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
937
- var current = this.current;
1622
+ }
1623
+ }, {
1624
+ key: "paintSolidColorImageMask",
1625
+ value: function paintSolidColorImageMask() {
938
1626
  var rect = this.svgFactory.createElement('svg:rect');
939
1627
  rect.setAttributeNS(null, 'x', '0');
940
1628
  rect.setAttributeNS(null, 'y', '0');
941
1629
  rect.setAttributeNS(null, 'width', '1px');
942
1630
  rect.setAttributeNS(null, 'height', '1px');
943
- rect.setAttributeNS(null, 'fill', current.fillColor);
1631
+ rect.setAttributeNS(null, 'fill', this.current.fillColor);
1632
+
944
1633
  this._ensureTransformGroup().appendChild(rect);
945
- },
946
- paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
1634
+ }
1635
+ }, {
1636
+ key: "paintJpegXObject",
1637
+ value: function paintJpegXObject(objId, w, h) {
947
1638
  var imgObj = this.objs.get(objId);
948
1639
  var imgEl = this.svgFactory.createElement('svg:image');
949
1640
  imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
@@ -951,18 +1642,25 @@ var SVGGraphics = function SVGGraphics() {
951
1642
  imgEl.setAttributeNS(null, 'height', pf(h));
952
1643
  imgEl.setAttributeNS(null, 'x', '0');
953
1644
  imgEl.setAttributeNS(null, 'y', pf(-h));
954
- imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
1645
+ imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / w), " ").concat(pf(-1 / h), ")"));
1646
+
955
1647
  this._ensureTransformGroup().appendChild(imgEl);
956
- },
957
- paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
1648
+ }
1649
+ }, {
1650
+ key: "paintImageXObject",
1651
+ value: function paintImageXObject(objId) {
958
1652
  var imgData = this.objs.get(objId);
1653
+
959
1654
  if (!imgData) {
960
- (0, _util.warn)('Dependent image isn\'t ready yet');
1655
+ (0, _util.warn)("Dependent image with object ID ".concat(objId, " is not ready yet"));
961
1656
  return;
962
1657
  }
1658
+
963
1659
  this.paintInlineImageXObject(imgData);
964
- },
965
- paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
1660
+ }
1661
+ }, {
1662
+ key: "paintInlineImageXObject",
1663
+ value: function paintInlineImageXObject(imgData, mask) {
966
1664
  var width = imgData.width;
967
1665
  var height = imgData.height;
968
1666
  var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema, !!mask);
@@ -979,19 +1677,22 @@ var SVGGraphics = function SVGGraphics() {
979
1677
  imgEl.setAttributeNS(null, 'y', pf(-height));
980
1678
  imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
981
1679
  imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
982
- imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
1680
+ imgEl.setAttributeNS(null, 'transform', "scale(".concat(pf(1 / width), " ").concat(pf(-1 / height), ")"));
1681
+
983
1682
  if (mask) {
984
1683
  mask.appendChild(imgEl);
985
1684
  } else {
986
1685
  this._ensureTransformGroup().appendChild(imgEl);
987
1686
  }
988
- },
989
- paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
1687
+ }
1688
+ }, {
1689
+ key: "paintImageMaskXObject",
1690
+ value: function paintImageMaskXObject(imgData) {
990
1691
  var current = this.current;
991
1692
  var width = imgData.width;
992
1693
  var height = imgData.height;
993
1694
  var fillColor = current.fillColor;
994
- current.maskId = 'mask' + maskCount++;
1695
+ current.maskId = "mask".concat(maskCount++);
995
1696
  var mask = this.svgFactory.createElement('svg:mask');
996
1697
  mask.setAttributeNS(null, 'id', current.maskId);
997
1698
  var rect = this.svgFactory.createElement('svg:rect');
@@ -1000,16 +1701,21 @@ var SVGGraphics = function SVGGraphics() {
1000
1701
  rect.setAttributeNS(null, 'width', pf(width));
1001
1702
  rect.setAttributeNS(null, 'height', pf(height));
1002
1703
  rect.setAttributeNS(null, 'fill', fillColor);
1003
- rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
1704
+ rect.setAttributeNS(null, 'mask', "url(#".concat(current.maskId, ")"));
1004
1705
  this.defs.appendChild(mask);
1706
+
1005
1707
  this._ensureTransformGroup().appendChild(rect);
1708
+
1006
1709
  this.paintInlineImageXObject(imgData, mask);
1007
- },
1008
- paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
1710
+ }
1711
+ }, {
1712
+ key: "paintFormXObjectBegin",
1713
+ value: function paintFormXObjectBegin(matrix, bbox) {
1009
1714
  if (Array.isArray(matrix) && matrix.length === 6) {
1010
1715
  this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
1011
1716
  }
1012
- if (Array.isArray(bbox) && bbox.length === 4) {
1717
+
1718
+ if (bbox) {
1013
1719
  var width = bbox[2] - bbox[0];
1014
1720
  var height = bbox[3] - bbox[1];
1015
1721
  var cliprect = this.svgFactory.createElement('svg:rect');
@@ -1021,9 +1727,13 @@ var SVGGraphics = function SVGGraphics() {
1021
1727
  this.clip('nonzero');
1022
1728
  this.endPath();
1023
1729
  }
1024
- },
1025
- paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {},
1026
- _initialize: function _initialize(viewport) {
1730
+ }
1731
+ }, {
1732
+ key: "paintFormXObjectEnd",
1733
+ value: function paintFormXObjectEnd() {}
1734
+ }, {
1735
+ key: "_initialize",
1736
+ value: function _initialize(viewport) {
1027
1737
  var svg = this.svgFactory.create(viewport.width, viewport.height);
1028
1738
  var definitions = this.svgFactory.createElement('svg:defs');
1029
1739
  svg.appendChild(definitions);
@@ -1033,31 +1743,37 @@ var SVGGraphics = function SVGGraphics() {
1033
1743
  svg.appendChild(rootGroup);
1034
1744
  this.svg = rootGroup;
1035
1745
  return svg;
1036
- },
1037
-
1038
- _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
1746
+ }
1747
+ }, {
1748
+ key: "_ensureClipGroup",
1749
+ value: function _ensureClipGroup() {
1039
1750
  if (!this.current.clipGroup) {
1040
1751
  var clipGroup = this.svgFactory.createElement('svg:g');
1041
1752
  clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
1042
1753
  this.svg.appendChild(clipGroup);
1043
1754
  this.current.clipGroup = clipGroup;
1044
1755
  }
1756
+
1045
1757
  return this.current.clipGroup;
1046
- },
1047
- _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
1758
+ }
1759
+ }, {
1760
+ key: "_ensureTransformGroup",
1761
+ value: function _ensureTransformGroup() {
1048
1762
  if (!this.tgrp) {
1049
1763
  this.tgrp = this.svgFactory.createElement('svg:g');
1050
1764
  this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
1765
+
1051
1766
  if (this.current.activeClipUrl) {
1052
1767
  this._ensureClipGroup().appendChild(this.tgrp);
1053
1768
  } else {
1054
1769
  this.svg.appendChild(this.tgrp);
1055
1770
  }
1056
1771
  }
1772
+
1057
1773
  return this.tgrp;
1058
1774
  }
1059
- };
1775
+ }]);
1776
+
1060
1777
  return SVGGraphics;
1061
1778
  }();
1062
- }
1063
- exports.SVGGraphics = SVGGraphics;
1779
+ }