pdfjs-dist 2.1.266 → 2.5.207

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of pdfjs-dist might be problematic. Click here for more details.

Files changed (191) hide show
  1. package/CODE_OF_CONDUCT.md +15 -0
  2. package/README.md +4 -0
  3. package/bower.json +1 -1
  4. package/build/pdf.js +8382 -18492
  5. package/build/pdf.js.map +1 -1
  6. package/build/pdf.min.js +22 -1
  7. package/build/pdf.worker.entry.js +5 -3
  8. package/build/pdf.worker.js +20417 -29816
  9. package/build/pdf.worker.js.map +1 -1
  10. package/build/pdf.worker.min.js +22 -1
  11. package/es5/build/pdf.js +25688 -0
  12. package/es5/build/pdf.js.map +1 -0
  13. package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
  14. package/es5/build/pdf.worker.js +58239 -0
  15. package/es5/build/pdf.worker.js.map +1 -0
  16. package/es5/web/images/annotation-check.svg +11 -0
  17. package/es5/web/images/annotation-comment.svg +16 -0
  18. package/es5/web/images/annotation-help.svg +26 -0
  19. package/es5/web/images/annotation-insert.svg +10 -0
  20. package/es5/web/images/annotation-key.svg +11 -0
  21. package/es5/web/images/annotation-newparagraph.svg +11 -0
  22. package/es5/web/images/annotation-noicon.svg +7 -0
  23. package/es5/web/images/annotation-note.svg +42 -0
  24. package/es5/web/images/annotation-paragraph.svg +16 -0
  25. package/es5/web/images/loading-icon.gif +0 -0
  26. package/es5/web/images/shadow.png +0 -0
  27. package/es5/web/images/texture.png +0 -0
  28. package/es5/web/pdf_viewer.css +403 -0
  29. package/es5/web/pdf_viewer.js +7742 -0
  30. package/es5/web/pdf_viewer.js.map +1 -0
  31. package/image_decoders/pdf.image_decoders.js +1475 -4897
  32. package/image_decoders/pdf.image_decoders.js.map +1 -1
  33. package/image_decoders/pdf.image_decoders.min.js +22 -1
  34. package/lib/README.md +7 -0
  35. package/lib/core/annotation.js +750 -899
  36. package/lib/core/arithmetic_decoder.js +81 -97
  37. package/lib/core/bidi.js +54 -46
  38. package/lib/core/ccitt.js +88 -81
  39. package/lib/core/ccitt_stream.js +15 -14
  40. package/lib/core/cff_parser.js +235 -183
  41. package/lib/core/charsets.js +4 -4
  42. package/lib/core/chunked_stream.js +447 -542
  43. package/lib/core/cmap.js +222 -264
  44. package/lib/core/colorspace.js +699 -863
  45. package/lib/core/core_utils.js +152 -0
  46. package/lib/core/crypto.js +379 -437
  47. package/lib/core/document.js +573 -660
  48. package/lib/core/encodings.js +15 -15
  49. package/lib/core/evaluator.js +1103 -868
  50. package/lib/core/font_renderer.js +135 -178
  51. package/lib/core/fonts.js +570 -491
  52. package/lib/core/function.js +291 -288
  53. package/lib/core/glyphlist.js +4527 -4526
  54. package/lib/core/image.js +145 -149
  55. package/lib/core/image_utils.js +170 -0
  56. package/lib/core/jbig2.js +325 -316
  57. package/lib/core/jbig2_stream.js +18 -17
  58. package/lib/core/jpeg_stream.js +21 -26
  59. package/lib/core/jpg.js +284 -232
  60. package/lib/core/jpx.js +161 -143
  61. package/lib/core/jpx_stream.js +28 -28
  62. package/lib/core/metrics.js +2929 -2929
  63. package/lib/core/murmurhash3.js +90 -101
  64. package/lib/core/obj.js +1183 -1157
  65. package/lib/core/operator_list.js +99 -67
  66. package/lib/core/parser.js +972 -911
  67. package/lib/core/pattern.js +87 -70
  68. package/lib/core/pdf_manager.js +150 -315
  69. package/lib/core/primitives.js +83 -56
  70. package/lib/core/ps_parser.js +175 -214
  71. package/lib/core/standard_fonts.js +237 -236
  72. package/lib/core/stream.js +94 -74
  73. package/lib/core/type1_parser.js +87 -69
  74. package/lib/core/unicode.js +1654 -1654
  75. package/lib/core/worker.js +193 -390
  76. package/lib/core/worker_stream.js +168 -0
  77. package/lib/display/annotation_layer.js +741 -972
  78. package/lib/display/api.js +1500 -1791
  79. package/lib/display/api_compatibility.js +12 -17
  80. package/lib/display/canvas.js +165 -165
  81. package/lib/display/content_disposition.js +40 -59
  82. package/lib/display/display_utils.js +515 -0
  83. package/lib/display/fetch_stream.js +183 -298
  84. package/lib/display/font_loader.js +273 -413
  85. package/lib/display/metadata.js +86 -98
  86. package/lib/display/network.js +266 -359
  87. package/lib/display/network_utils.js +25 -18
  88. package/lib/display/node_stream.js +285 -458
  89. package/lib/display/pattern_helper.js +113 -65
  90. package/lib/display/svg.js +1166 -901
  91. package/lib/display/text_layer.js +156 -132
  92. package/lib/display/transport_stream.js +262 -278
  93. package/lib/display/webgl.js +70 -83
  94. package/lib/display/worker_options.js +3 -3
  95. package/lib/display/xml_parser.js +303 -392
  96. package/lib/examples/node/domstubs.js +40 -37
  97. package/lib/pdf.js +226 -59
  98. package/lib/pdf.worker.js +14 -6
  99. package/lib/shared/compatibility.js +3 -246
  100. package/lib/shared/is_node.js +7 -6
  101. package/lib/shared/message_handler.js +327 -332
  102. package/lib/shared/util.js +266 -416
  103. package/lib/test/unit/annotation_spec.js +1555 -701
  104. package/lib/test/unit/api_spec.js +802 -604
  105. package/lib/test/unit/bidi_spec.js +7 -7
  106. package/lib/test/unit/cff_parser_spec.js +84 -69
  107. package/lib/test/unit/clitests_helper.js +7 -9
  108. package/lib/test/unit/cmap_spec.js +74 -76
  109. package/lib/test/unit/colorspace_spec.js +166 -161
  110. package/lib/test/unit/core_utils_spec.js +211 -0
  111. package/lib/test/unit/crypto_spec.js +181 -181
  112. package/lib/test/unit/custom_spec.js +20 -22
  113. package/lib/test/unit/display_svg_spec.js +34 -39
  114. package/lib/test/unit/display_utils_spec.js +263 -0
  115. package/lib/test/unit/document_spec.js +16 -21
  116. package/lib/test/unit/encodings_spec.js +12 -34
  117. package/lib/test/unit/evaluator_spec.js +83 -83
  118. package/lib/test/unit/fetch_stream_spec.js +111 -0
  119. package/lib/test/unit/function_spec.js +206 -204
  120. package/lib/test/unit/jasmine-boot.js +46 -30
  121. package/lib/test/unit/message_handler_spec.js +173 -159
  122. package/lib/test/unit/metadata_spec.js +69 -69
  123. package/lib/test/unit/murmurhash3_spec.js +12 -12
  124. package/lib/test/unit/network_spec.js +13 -61
  125. package/lib/test/unit/network_utils_spec.js +183 -119
  126. package/lib/test/unit/node_stream_spec.js +78 -92
  127. package/lib/test/unit/parser_spec.js +172 -114
  128. package/lib/test/unit/pdf_find_controller_spec.js +55 -86
  129. package/lib/test/unit/pdf_find_utils_spec.js +32 -32
  130. package/lib/test/unit/pdf_history_spec.js +32 -32
  131. package/lib/test/unit/primitives_spec.js +140 -125
  132. package/lib/test/unit/stream_spec.js +16 -14
  133. package/lib/test/unit/test_utils.js +131 -143
  134. package/lib/test/unit/testreporter.js +19 -19
  135. package/lib/test/unit/type1_parser_spec.js +42 -42
  136. package/lib/test/unit/ui_utils_spec.js +297 -459
  137. package/lib/test/unit/unicode_spec.js +38 -38
  138. package/lib/test/unit/util_spec.js +121 -305
  139. package/lib/web/annotation_layer_builder.js +66 -103
  140. package/lib/web/app.js +1328 -1214
  141. package/lib/web/app_options.js +105 -107
  142. package/lib/web/base_viewer.js +824 -838
  143. package/lib/web/chromecom.js +165 -252
  144. package/lib/web/debugger.js +149 -205
  145. package/lib/web/download_manager.js +39 -55
  146. package/lib/web/firefox_print_service.js +37 -27
  147. package/lib/web/firefoxcom.js +212 -363
  148. package/lib/web/genericcom.js +26 -108
  149. package/lib/web/genericl10n.js +24 -153
  150. package/lib/web/grab_to_pan.js +32 -30
  151. package/lib/web/interfaces.js +80 -254
  152. package/lib/web/overlay_manager.js +70 -246
  153. package/lib/web/password_prompt.js +38 -64
  154. package/lib/web/pdf_attachment_viewer.js +113 -131
  155. package/lib/web/pdf_cursor_tools.js +75 -102
  156. package/lib/web/pdf_document_properties.js +221 -306
  157. package/lib/web/pdf_find_bar.js +136 -170
  158. package/lib/web/pdf_find_controller.js +491 -548
  159. package/lib/web/pdf_find_utils.js +13 -13
  160. package/lib/web/pdf_history.js +397 -406
  161. package/lib/web/pdf_link_service.js +304 -348
  162. package/lib/web/pdf_outline_viewer.js +140 -175
  163. package/lib/web/pdf_page_view.js +452 -523
  164. package/lib/web/pdf_presentation_mode.js +308 -357
  165. package/lib/web/pdf_print_service.js +90 -104
  166. package/lib/web/pdf_rendering_queue.js +84 -108
  167. package/lib/web/pdf_sidebar.js +276 -306
  168. package/lib/web/pdf_sidebar_resizer.js +92 -119
  169. package/lib/web/pdf_single_page_viewer.js +77 -126
  170. package/lib/web/pdf_thumbnail_view.js +276 -297
  171. package/lib/web/pdf_thumbnail_viewer.js +186 -206
  172. package/lib/web/pdf_viewer.component.js +20 -21
  173. package/lib/web/pdf_viewer.js +55 -115
  174. package/lib/web/preferences.js +82 -286
  175. package/lib/web/secondary_toolbar.js +164 -196
  176. package/lib/web/text_layer_builder.js +282 -339
  177. package/lib/web/toolbar.js +217 -210
  178. package/lib/web/ui_utils.js +267 -420
  179. package/lib/web/view_history.js +52 -226
  180. package/lib/web/viewer_compatibility.js +21 -6
  181. package/package.json +2 -9
  182. package/web/pdf_viewer.css +35 -25
  183. package/web/pdf_viewer.js +3489 -4855
  184. package/web/pdf_viewer.js.map +1 -1
  185. package/webpack.js +14 -5
  186. package/external/streams/streams-lib.js +0 -3962
  187. package/external/url/url-lib.js +0 -627
  188. package/lib/display/dom_utils.js +0 -494
  189. package/lib/shared/streams_polyfill.js +0 -43
  190. package/lib/shared/url_polyfill.js +0 -56
  191. package/lib/test/unit/dom_utils_spec.js +0 -89
@@ -2,7 +2,7 @@
2
2
  * @licstart The following is the entire license notice for the
3
3
  * Javascript code in this page
4
4
  *
5
- * Copyright 2018 Mozilla Foundation
5
+ * Copyright 2020 Mozilla Foundation
6
6
  *
7
7
  * Licensed under the Apache License, Version 2.0 (the "License");
8
8
  * you may not use this file except in compliance with the License.
@@ -27,11 +27,13 @@ Object.defineProperty(exports, "__esModule", {
27
27
  exports.getTilingPatternIR = getTilingPatternIR;
28
28
  exports.Pattern = void 0;
29
29
 
30
- var _util = require("../shared/util");
30
+ var _util = require("../shared/util.js");
31
31
 
32
- var _colorspace = require("./colorspace");
32
+ var _colorspace = require("./colorspace.js");
33
33
 
34
- var _primitives = require("./primitives");
34
+ var _primitives = require("./primitives.js");
35
+
36
+ var _core_utils = require("./core_utils.js");
35
37
 
36
38
  var ShadingType = {
37
39
  FUNCTION_BASED: 1,
@@ -45,18 +47,18 @@ var ShadingType = {
45
47
 
46
48
  var Pattern = function PatternClosure() {
47
49
  function Pattern() {
48
- (0, _util.unreachable)('should not call Pattern constructor');
50
+ (0, _util.unreachable)("should not call Pattern constructor");
49
51
  }
50
52
 
51
53
  Pattern.prototype = {
52
54
  getPattern: function Pattern_getPattern(ctx) {
53
- (0, _util.unreachable)("Should not call Pattern.getStyle: ".concat(ctx));
55
+ (0, _util.unreachable)(`Should not call Pattern.getStyle: ${ctx}`);
54
56
  }
55
57
  };
56
58
 
57
59
  Pattern.parseShading = function (shading, matrix, xref, res, handler, pdfFunctionFactory) {
58
60
  var dict = (0, _primitives.isStream)(shading) ? shading.dict : shading;
59
- var type = dict.get('ShadingType');
61
+ var type = dict.get("ShadingType");
60
62
 
61
63
  try {
62
64
  switch (type) {
@@ -71,14 +73,14 @@ var Pattern = function PatternClosure() {
71
73
  return new Shadings.Mesh(shading, matrix, xref, res, pdfFunctionFactory);
72
74
 
73
75
  default:
74
- throw new _util.FormatError('Unsupported ShadingType: ' + type);
76
+ throw new _util.FormatError("Unsupported ShadingType: " + type);
75
77
  }
76
78
  } catch (ex) {
77
- if (ex instanceof _util.MissingDataException) {
79
+ if (ex instanceof _core_utils.MissingDataException) {
78
80
  throw ex;
79
81
  }
80
82
 
81
- handler.send('UnsupportedFeature', {
83
+ handler.send("UnsupportedFeature", {
82
84
  featureId: _util.UNSUPPORTED_FEATURES.shadingPattern
83
85
  });
84
86
  (0, _util.warn)(ex);
@@ -96,17 +98,25 @@ Shadings.SMALL_NUMBER = 1e-6;
96
98
  Shadings.RadialAxial = function RadialAxialClosure() {
97
99
  function RadialAxial(dict, matrix, xref, res, pdfFunctionFactory) {
98
100
  this.matrix = matrix;
99
- this.coordsArr = dict.getArray('Coords');
100
- this.shadingType = dict.get('ShadingType');
101
- this.type = 'Pattern';
102
- var cs = dict.get('ColorSpace', 'CS');
101
+ this.coordsArr = dict.getArray("Coords");
102
+ this.shadingType = dict.get("ShadingType");
103
+ this.type = "Pattern";
104
+ var cs = dict.get("ColorSpace", "CS");
103
105
  cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
104
106
  this.cs = cs;
107
+ const bbox = dict.getArray("BBox");
108
+
109
+ if (Array.isArray(bbox) && bbox.length === 4) {
110
+ this.bbox = _util.Util.normalizeRect(bbox);
111
+ } else {
112
+ this.bbox = null;
113
+ }
114
+
105
115
  var t0 = 0.0,
106
116
  t1 = 1.0;
107
117
 
108
- if (dict.has('Domain')) {
109
- var domainArr = dict.getArray('Domain');
118
+ if (dict.has("Domain")) {
119
+ var domainArr = dict.getArray("Domain");
110
120
  t0 = domainArr[0];
111
121
  t1 = domainArr[1];
112
122
  }
@@ -114,8 +124,8 @@ Shadings.RadialAxial = function RadialAxialClosure() {
114
124
  var extendStart = false,
115
125
  extendEnd = false;
116
126
 
117
- if (dict.has('Extend')) {
118
- var extendArr = dict.getArray('Extend');
127
+ if (dict.has("Extend")) {
128
+ var extendArr = dict.getArray("Extend");
119
129
  extendStart = extendArr[0];
120
130
  extendEnd = extendArr[1];
121
131
  }
@@ -130,20 +140,20 @@ Shadings.RadialAxial = function RadialAxialClosure() {
130
140
  var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
131
141
 
132
142
  if (r1 <= r2 + distance && r2 <= r1 + distance) {
133
- (0, _util.warn)('Unsupported radial gradient.');
143
+ (0, _util.warn)("Unsupported radial gradient.");
134
144
  }
135
145
  }
136
146
 
137
147
  this.extendStart = extendStart;
138
148
  this.extendEnd = extendEnd;
139
- var fnObj = dict.get('Function');
149
+ var fnObj = dict.get("Function");
140
150
  var fn = pdfFunctionFactory.createFromArray(fnObj);
141
- var diff = t1 - t0;
142
- var step = diff / 10;
151
+ const NUMBER_OF_SAMPLES = 10;
152
+ const step = (t1 - t0) / NUMBER_OF_SAMPLES;
143
153
  var colorStops = this.colorStops = [];
144
154
 
145
155
  if (t0 >= t1 || step <= 0) {
146
- (0, _util.info)('Bad shading domain.');
156
+ (0, _util.info)("Bad shading domain.");
147
157
  return;
148
158
  }
149
159
 
@@ -151,20 +161,20 @@ Shadings.RadialAxial = function RadialAxialClosure() {
151
161
  ratio = new Float32Array(1);
152
162
  var rgbColor;
153
163
 
154
- for (var i = t0; i <= t1; i += step) {
155
- ratio[0] = i;
164
+ for (let i = 0; i <= NUMBER_OF_SAMPLES; i++) {
165
+ ratio[0] = t0 + i * step;
156
166
  fn(ratio, 0, color, 0);
157
167
  rgbColor = cs.getRgb(color, 0);
158
168
 
159
169
  var cssColor = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
160
170
 
161
- colorStops.push([(i - t0) / diff, cssColor]);
171
+ colorStops.push([i / NUMBER_OF_SAMPLES, cssColor]);
162
172
  }
163
173
 
164
- var background = 'transparent';
174
+ var background = "transparent";
165
175
 
166
- if (dict.has('Background')) {
167
- rgbColor = cs.getRgb(dict.get('Background'), 0);
176
+ if (dict.has("Background")) {
177
+ rgbColor = cs.getRgb(dict.get("Background"), 0);
168
178
  background = _util.Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
169
179
  }
170
180
 
@@ -192,15 +202,15 @@ Shadings.RadialAxial = function RadialAxialClosure() {
192
202
  p1 = [coordsArr[2], coordsArr[3]];
193
203
  r0 = null;
194
204
  r1 = null;
195
- type = 'axial';
205
+ type = "axial";
196
206
  } else if (shadingType === ShadingType.RADIAL) {
197
207
  p0 = [coordsArr[0], coordsArr[1]];
198
208
  p1 = [coordsArr[3], coordsArr[4]];
199
209
  r0 = coordsArr[2];
200
210
  r1 = coordsArr[5];
201
- type = 'radial';
211
+ type = "radial";
202
212
  } else {
203
- (0, _util.unreachable)("getPattern type unknown: ".concat(shadingType));
213
+ (0, _util.unreachable)(`getPattern type unknown: ${shadingType}`);
204
214
  }
205
215
 
206
216
  var matrix = this.matrix;
@@ -217,7 +227,7 @@ Shadings.RadialAxial = function RadialAxialClosure() {
217
227
  }
218
228
  }
219
229
 
220
- return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
230
+ return ["RadialAxial", type, this.bbox, this.colorStops, p0, p1, r0, r1];
221
231
  }
222
232
  };
223
233
  return RadialAxial;
@@ -268,7 +278,7 @@ Shadings.Mesh = function MeshClosure() {
268
278
  buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
269
279
  var nextByte = this.stream.getByte();
270
280
  this.buffer = nextByte & (1 << bufferLength) - 1;
271
- return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
281
+ return (buffer << 8 - bufferLength | (nextByte & 0xff) >> bufferLength) >>> 0;
272
282
  }
273
283
 
274
284
  if (n === 8 && bufferLength === 0) {
@@ -336,7 +346,7 @@ Shadings.Mesh = function MeshClosure() {
336
346
 
337
347
  if (verticesLeft === 0) {
338
348
  if (!(0 <= f && f <= 2)) {
339
- throw new _util.FormatError('Unknown type4 flag');
349
+ throw new _util.FormatError("Unknown type4 flag");
340
350
  }
341
351
 
342
352
  switch (f) {
@@ -366,7 +376,7 @@ Shadings.Mesh = function MeshClosure() {
366
376
  }
367
377
 
368
378
  mesh.figures.push({
369
- type: 'triangles',
379
+ type: "triangles",
370
380
  coords: new Int32Array(ps),
371
381
  colors: new Int32Array(ps)
372
382
  });
@@ -386,10 +396,10 @@ Shadings.Mesh = function MeshClosure() {
386
396
  }
387
397
 
388
398
  mesh.figures.push({
389
- type: 'lattice',
399
+ type: "lattice",
390
400
  coords: new Int32Array(ps),
391
401
  colors: new Int32Array(ps),
392
- verticesPerRow: verticesPerRow
402
+ verticesPerRow
393
403
  });
394
404
  }
395
405
 
@@ -422,7 +432,7 @@ Shadings.Mesh = function MeshClosure() {
422
432
 
423
433
  function buildFigureFromPatch(mesh, index) {
424
434
  var figure = mesh.figures[index];
425
- (0, _util.assert)(figure.type === 'patch', 'Unexpected patch mesh figure');
435
+ (0, _util.assert)(figure.type === "patch", "Unexpected patch mesh figure");
426
436
  var coords = mesh.coords,
427
437
  colors = mesh.colors;
428
438
  var pi = figure.coords;
@@ -493,10 +503,10 @@ Shadings.Mesh = function MeshClosure() {
493
503
  figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
494
504
  figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
495
505
  mesh.figures[index] = {
496
- type: 'lattice',
506
+ type: "lattice",
497
507
  coords: figureCoords,
498
508
  colors: figureColors,
499
- verticesPerRow: verticesPerRow
509
+ verticesPerRow
500
510
  };
501
511
  }
502
512
 
@@ -510,7 +520,7 @@ Shadings.Mesh = function MeshClosure() {
510
520
  var f = reader.readFlag();
511
521
 
512
522
  if (!(0 <= f && f <= 3)) {
513
- throw new _util.FormatError('Unknown type6 flag');
523
+ throw new _util.FormatError("Unknown type6 flag");
514
524
  }
515
525
 
516
526
  var i, ii;
@@ -624,7 +634,7 @@ Shadings.Mesh = function MeshClosure() {
624
634
  ps[10] = coords.length;
625
635
  coords.push([(-4 * coords[ps[15]][0] - coords[ps[0]][0] + 6 * (coords[ps[11]][0] + coords[ps[14]][0]) - 2 * (coords[ps[12]][0] + coords[ps[3]][0]) + 3 * (coords[ps[2]][0] + coords[ps[8]][0])) / 9, (-4 * coords[ps[15]][1] - coords[ps[0]][1] + 6 * (coords[ps[11]][1] + coords[ps[14]][1]) - 2 * (coords[ps[12]][1] + coords[ps[3]][1]) + 3 * (coords[ps[2]][1] + coords[ps[8]][1])) / 9]);
626
636
  mesh.figures.push({
627
- type: 'patch',
637
+ type: "patch",
628
638
  coords: new Int32Array(ps),
629
639
  colors: new Int32Array(cs)
630
640
  });
@@ -641,7 +651,7 @@ Shadings.Mesh = function MeshClosure() {
641
651
  var f = reader.readFlag();
642
652
 
643
653
  if (!(0 <= f && f <= 3)) {
644
- throw new _util.FormatError('Unknown type7 flag');
654
+ throw new _util.FormatError("Unknown type7 flag");
645
655
  }
646
656
 
647
657
  var i, ii;
@@ -763,7 +773,7 @@ Shadings.Mesh = function MeshClosure() {
763
773
  }
764
774
 
765
775
  mesh.figures.push({
766
- type: 'patch',
776
+ type: "patch",
767
777
  coords: new Int32Array(ps),
768
778
  colors: new Int32Array(cs)
769
779
  });
@@ -827,28 +837,35 @@ Shadings.Mesh = function MeshClosure() {
827
837
 
828
838
  function Mesh(stream, matrix, xref, res, pdfFunctionFactory) {
829
839
  if (!(0, _primitives.isStream)(stream)) {
830
- throw new _util.FormatError('Mesh data is not a stream');
840
+ throw new _util.FormatError("Mesh data is not a stream");
831
841
  }
832
842
 
833
843
  var dict = stream.dict;
834
844
  this.matrix = matrix;
835
- this.shadingType = dict.get('ShadingType');
836
- this.type = 'Pattern';
837
- this.bbox = dict.getArray('BBox');
838
- var cs = dict.get('ColorSpace', 'CS');
845
+ this.shadingType = dict.get("ShadingType");
846
+ this.type = "Pattern";
847
+ const bbox = dict.getArray("BBox");
848
+
849
+ if (Array.isArray(bbox) && bbox.length === 4) {
850
+ this.bbox = _util.Util.normalizeRect(bbox);
851
+ } else {
852
+ this.bbox = null;
853
+ }
854
+
855
+ var cs = dict.get("ColorSpace", "CS");
839
856
  cs = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
840
857
  this.cs = cs;
841
- this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
842
- var fnObj = dict.get('Function');
858
+ this.background = dict.has("Background") ? cs.getRgb(dict.get("Background"), 0) : null;
859
+ var fnObj = dict.get("Function");
843
860
  var fn = fnObj ? pdfFunctionFactory.createFromArray(fnObj) : null;
844
861
  this.coords = [];
845
862
  this.colors = [];
846
863
  this.figures = [];
847
864
  var decodeContext = {
848
- bitsPerCoordinate: dict.get('BitsPerCoordinate'),
849
- bitsPerComponent: dict.get('BitsPerComponent'),
850
- bitsPerFlag: dict.get('BitsPerFlag'),
851
- decode: dict.getArray('Decode'),
865
+ bitsPerCoordinate: dict.get("BitsPerCoordinate"),
866
+ bitsPerComponent: dict.get("BitsPerComponent"),
867
+ bitsPerFlag: dict.get("BitsPerFlag"),
868
+ decode: dict.getArray("Decode"),
852
869
  colorFn: fn,
853
870
  colorSpace: cs,
854
871
  numComps: fn ? 1 : cs.numComps
@@ -862,10 +879,10 @@ Shadings.Mesh = function MeshClosure() {
862
879
  break;
863
880
 
864
881
  case ShadingType.LATTICE_FORM_MESH:
865
- var verticesPerRow = dict.get('VerticesPerRow') | 0;
882
+ var verticesPerRow = dict.get("VerticesPerRow") | 0;
866
883
 
867
884
  if (verticesPerRow < 2) {
868
- throw new _util.FormatError('Invalid VerticesPerRow');
885
+ throw new _util.FormatError("Invalid VerticesPerRow");
869
886
  }
870
887
 
871
888
  decodeType5Shading(this, reader, verticesPerRow);
@@ -882,7 +899,7 @@ Shadings.Mesh = function MeshClosure() {
882
899
  break;
883
900
 
884
901
  default:
885
- (0, _util.unreachable)('Unsupported mesh type.');
902
+ (0, _util.unreachable)("Unsupported mesh type.");
886
903
  break;
887
904
  }
888
905
 
@@ -900,7 +917,7 @@ Shadings.Mesh = function MeshClosure() {
900
917
 
901
918
  Mesh.prototype = {
902
919
  getIR: function Mesh_getIR() {
903
- return ['Mesh', this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background];
920
+ return ["Mesh", this.shadingType, this.coords, this.colors, this.figures, this.bounds, this.matrix, this.bbox, this.background];
904
921
  }
905
922
  };
906
923
  return Mesh;
@@ -908,30 +925,30 @@ Shadings.Mesh = function MeshClosure() {
908
925
 
909
926
  Shadings.Dummy = function DummyClosure() {
910
927
  function Dummy() {
911
- this.type = 'Pattern';
928
+ this.type = "Pattern";
912
929
  }
913
930
 
914
931
  Dummy.prototype = {
915
932
  getIR: function Dummy_getIR() {
916
- return ['Dummy'];
933
+ return ["Dummy"];
917
934
  }
918
935
  };
919
936
  return Dummy;
920
937
  }();
921
938
 
922
939
  function getTilingPatternIR(operatorList, dict, args) {
923
- var matrix = dict.getArray('Matrix');
940
+ const matrix = dict.getArray("Matrix");
924
941
 
925
- var bbox = _util.Util.normalizeRect(dict.getArray('BBox'));
942
+ const bbox = _util.Util.normalizeRect(dict.getArray("BBox"));
926
943
 
927
- var xstep = dict.get('XStep');
928
- var ystep = dict.get('YStep');
929
- var paintType = dict.get('PaintType');
930
- var tilingType = dict.get('TilingType');
944
+ const xstep = dict.get("XStep");
945
+ const ystep = dict.get("YStep");
946
+ const paintType = dict.get("PaintType");
947
+ const tilingType = dict.get("TilingType");
931
948
 
932
949
  if (bbox[2] - bbox[0] === 0 || bbox[3] - bbox[1] === 0) {
933
- throw new _util.FormatError("Invalid getTilingPatternIR /BBox array: [".concat(bbox, "]."));
950
+ throw new _util.FormatError(`Invalid getTilingPatternIR /BBox array: [${bbox}].`);
934
951
  }
935
952
 
936
- return ['TilingPattern', args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
953
+ return ["TilingPattern", args, operatorList, matrix, bbox, xstep, ystep, paintType, tilingType];
937
954
  }