pdfjs-dist 2.0.943 → 2.1.266

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 (159) hide show
  1. package/bower.json +1 -1
  2. package/build/pdf.js +15329 -11095
  3. package/build/pdf.js.map +1 -1
  4. package/build/pdf.min.js +1 -1
  5. package/build/pdf.worker.js +12497 -4184
  6. package/build/pdf.worker.js.map +1 -1
  7. package/build/pdf.worker.min.js +1 -1
  8. package/image_decoders/pdf.image_decoders.js +3438 -1209
  9. package/image_decoders/pdf.image_decoders.js.map +1 -1
  10. package/image_decoders/pdf.image_decoders.min.js +1 -1
  11. package/lib/core/annotation.js +335 -109
  12. package/lib/core/arithmetic_decoder.js +274 -244
  13. package/lib/core/bidi.js +64 -5
  14. package/lib/core/ccitt.js +172 -17
  15. package/lib/core/ccitt_stream.js +14 -5
  16. package/lib/core/cff_parser.js +304 -28
  17. package/lib/core/charsets.js +4 -3
  18. package/lib/core/chunked_stream.js +379 -149
  19. package/lib/core/cmap.js +210 -40
  20. package/lib/core/colorspace.js +332 -187
  21. package/lib/core/crypto.js +289 -44
  22. package/lib/core/document.js +508 -249
  23. package/lib/core/encodings.js +18 -9
  24. package/lib/core/evaluator.js +657 -119
  25. package/lib/core/font_renderer.js +217 -34
  26. package/lib/core/fonts.js +632 -41
  27. package/lib/core/function.js +252 -26
  28. package/lib/core/glyphlist.js +2 -1
  29. package/lib/core/image.js +124 -27
  30. package/lib/core/jbig2.js +425 -65
  31. package/lib/core/jbig2_stream.js +18 -7
  32. package/lib/core/jpeg_stream.js +24 -8
  33. package/lib/core/jpg.js +208 -16
  34. package/lib/core/jpx.js +395 -5
  35. package/lib/core/jpx_stream.js +17 -5
  36. package/lib/core/metrics.js +3 -3
  37. package/lib/core/murmurhash3.js +23 -5
  38. package/lib/core/obj.js +625 -132
  39. package/lib/core/operator_list.js +104 -3
  40. package/lib/core/parser.js +262 -25
  41. package/lib/core/pattern.js +144 -12
  42. package/lib/core/pdf_manager.js +104 -70
  43. package/lib/core/primitives.js +74 -21
  44. package/lib/core/ps_parser.js +133 -44
  45. package/lib/core/standard_fonts.js +9 -9
  46. package/lib/core/stream.js +283 -31
  47. package/lib/core/type1_parser.js +138 -6
  48. package/lib/core/unicode.js +28 -1
  49. package/lib/core/worker.js +192 -57
  50. package/lib/display/annotation_layer.js +303 -123
  51. package/lib/display/api.js +1073 -574
  52. package/lib/display/api_compatibility.js +4 -1
  53. package/lib/display/canvas.js +314 -18
  54. package/lib/display/content_disposition.js +70 -23
  55. package/lib/display/dom_utils.js +112 -59
  56. package/lib/display/fetch_stream.js +95 -50
  57. package/lib/display/font_loader.js +250 -132
  58. package/lib/display/metadata.js +37 -15
  59. package/lib/display/network.js +123 -34
  60. package/lib/display/network_utils.js +23 -10
  61. package/lib/display/node_stream.js +162 -65
  62. package/lib/display/pattern_helper.js +57 -6
  63. package/lib/display/svg.js +194 -18
  64. package/lib/display/text_layer.js +128 -14
  65. package/lib/display/transport_stream.js +83 -27
  66. package/lib/display/webgl.js +63 -17
  67. package/lib/display/worker_options.js +4 -3
  68. package/lib/display/xml_parser.js +162 -52
  69. package/lib/examples/node/domstubs.js +56 -3
  70. package/lib/pdf.js +15 -2
  71. package/lib/pdf.worker.js +4 -2
  72. package/lib/shared/compatibility.js +129 -26
  73. package/lib/shared/global_scope.js +1 -1
  74. package/lib/shared/is_node.js +3 -3
  75. package/lib/shared/message_handler.js +103 -45
  76. package/lib/shared/streams_polyfill.js +20 -16
  77. package/lib/shared/url_polyfill.js +8 -2
  78. package/lib/shared/util.js +246 -84
  79. package/lib/test/unit/annotation_spec.js +99 -73
  80. package/lib/test/unit/api_spec.js +347 -113
  81. package/lib/test/unit/bidi_spec.js +6 -6
  82. package/lib/test/unit/cff_parser_spec.js +17 -5
  83. package/lib/test/unit/clitests_helper.js +7 -8
  84. package/lib/test/unit/cmap_spec.js +79 -25
  85. package/lib/test/unit/colorspace_spec.js +65 -18
  86. package/lib/test/unit/crypto_spec.js +16 -4
  87. package/lib/test/unit/custom_spec.js +40 -52
  88. package/lib/test/unit/display_svg_spec.js +32 -16
  89. package/lib/test/unit/document_spec.js +2 -2
  90. package/lib/test/unit/dom_utils_spec.js +8 -8
  91. package/lib/test/unit/encodings_spec.js +24 -44
  92. package/lib/test/unit/evaluator_spec.js +15 -8
  93. package/lib/test/unit/function_spec.js +16 -4
  94. package/lib/test/unit/jasmine-boot.js +29 -16
  95. package/lib/test/unit/message_handler_spec.js +19 -6
  96. package/lib/test/unit/metadata_spec.js +64 -11
  97. package/lib/test/unit/murmurhash3_spec.js +2 -2
  98. package/lib/test/unit/network_spec.js +19 -4
  99. package/lib/test/unit/network_utils_spec.js +6 -4
  100. package/lib/test/unit/node_stream_spec.js +50 -26
  101. package/lib/test/unit/parser_spec.js +13 -29
  102. package/lib/test/unit/pdf_find_controller_spec.js +144 -32
  103. package/lib/test/unit/pdf_find_utils_spec.js +10 -9
  104. package/lib/test/unit/pdf_history_spec.js +20 -8
  105. package/lib/test/unit/primitives_spec.js +23 -3
  106. package/lib/test/unit/stream_spec.js +8 -3
  107. package/lib/test/unit/test_utils.js +89 -26
  108. package/lib/test/unit/testreporter.js +19 -1
  109. package/lib/test/unit/type1_parser_spec.js +7 -5
  110. package/lib/test/unit/ui_utils_spec.js +162 -38
  111. package/lib/test/unit/unicode_spec.js +13 -10
  112. package/lib/test/unit/util_spec.js +89 -9
  113. package/lib/web/annotation_layer_builder.js +38 -21
  114. package/lib/web/app.js +610 -245
  115. package/lib/web/app_options.js +54 -34
  116. package/lib/web/base_viewer.js +359 -162
  117. package/lib/web/chromecom.js +159 -80
  118. package/lib/web/debugger.js +161 -17
  119. package/lib/web/download_manager.js +29 -11
  120. package/lib/web/firefox_print_service.js +16 -8
  121. package/lib/web/firefoxcom.js +127 -91
  122. package/lib/web/genericcom.js +50 -31
  123. package/lib/web/genericl10n.js +46 -34
  124. package/lib/web/grab_to_pan.js +25 -3
  125. package/lib/web/interfaces.js +108 -61
  126. package/lib/web/overlay_manager.js +67 -45
  127. package/lib/web/password_prompt.js +20 -12
  128. package/lib/web/pdf_attachment_viewer.js +37 -17
  129. package/lib/web/pdf_cursor_tools.js +38 -15
  130. package/lib/web/pdf_document_properties.js +65 -24
  131. package/lib/web/pdf_find_bar.js +48 -20
  132. package/lib/web/pdf_find_controller.js +290 -89
  133. package/lib/web/pdf_find_utils.js +19 -3
  134. package/lib/web/pdf_history.js +186 -49
  135. package/lib/web/pdf_link_service.js +127 -52
  136. package/lib/web/pdf_outline_viewer.js +71 -21
  137. package/lib/web/pdf_page_view.js +188 -63
  138. package/lib/web/pdf_presentation_mode.js +98 -33
  139. package/lib/web/pdf_print_service.js +54 -10
  140. package/lib/web/pdf_rendering_queue.js +26 -4
  141. package/lib/web/pdf_sidebar.js +116 -62
  142. package/lib/web/pdf_sidebar_resizer.js +41 -15
  143. package/lib/web/pdf_single_page_viewer.js +65 -68
  144. package/lib/web/pdf_thumbnail_view.js +102 -31
  145. package/lib/web/pdf_thumbnail_viewer.js +62 -22
  146. package/lib/web/pdf_viewer.component.js +111 -31
  147. package/lib/web/pdf_viewer.js +80 -60
  148. package/lib/web/preferences.js +61 -39
  149. package/lib/web/secondary_toolbar.js +101 -82
  150. package/lib/web/text_layer_builder.js +124 -69
  151. package/lib/web/toolbar.js +67 -27
  152. package/lib/web/ui_utils.js +284 -128
  153. package/lib/web/view_history.js +75 -51
  154. package/lib/web/viewer_compatibility.js +2 -1
  155. package/package.json +1 -1
  156. package/web/pdf_viewer.css +1 -1
  157. package/web/pdf_viewer.js +2200 -973
  158. package/web/pdf_viewer.js.map +1 -1
  159. package/lib/web/dom_events.js +0 -140
@@ -19,52 +19,68 @@
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.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = undefined;
27
+ exports.AnnotationFactory = exports.AnnotationBorderStyle = exports.Annotation = void 0;
28
28
 
29
- var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
29
+ var _util = require("../shared/util");
30
30
 
31
- var _createClass = function () { 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
31
+ var _obj = require("./obj");
32
32
 
33
- var _util = require('../shared/util');
33
+ var _primitives = require("./primitives");
34
34
 
35
- var _obj = require('./obj');
35
+ var _colorspace = require("./colorspace");
36
36
 
37
- var _primitives = require('./primitives');
37
+ var _operator_list = require("./operator_list");
38
38
 
39
- var _colorspace = require('./colorspace');
39
+ var _stream = require("./stream");
40
40
 
41
- var _operator_list = require('./operator_list');
41
+ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
42
42
 
43
- var _stream = require('./stream');
43
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
44
44
 
45
- function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
45
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
46
46
 
47
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
47
+ function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
48
+
49
+ function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
50
+
51
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
52
+
53
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
54
+
55
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
48
56
 
49
57
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
50
58
 
51
- var AnnotationFactory = function () {
59
+ 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); } }
60
+
61
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
62
+
63
+ var AnnotationFactory =
64
+ /*#__PURE__*/
65
+ function () {
52
66
  function AnnotationFactory() {
53
67
  _classCallCheck(this, AnnotationFactory);
54
68
  }
55
69
 
56
70
  _createClass(AnnotationFactory, null, [{
57
- key: 'create',
71
+ key: "create",
58
72
  value: function create(xref, ref, pdfManager, idFactory) {
59
73
  return pdfManager.ensure(this, '_create', [xref, ref, pdfManager, idFactory]);
60
74
  }
61
75
  }, {
62
- key: '_create',
76
+ key: "_create",
63
77
  value: function _create(xref, ref, pdfManager, idFactory) {
64
78
  var dict = xref.fetchIfRef(ref);
79
+
65
80
  if (!(0, _primitives.isDict)(dict)) {
66
81
  return;
67
82
  }
83
+
68
84
  var id = (0, _primitives.isRef)(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
69
85
  var subtype = dict.get('Subtype');
70
86
  subtype = (0, _primitives.isName)(subtype) ? subtype.name : null;
@@ -76,59 +92,81 @@ var AnnotationFactory = function () {
76
92
  id: id,
77
93
  pdfManager: pdfManager
78
94
  };
95
+
79
96
  switch (subtype) {
80
97
  case 'Link':
81
98
  return new LinkAnnotation(parameters);
99
+
82
100
  case 'Text':
83
101
  return new TextAnnotation(parameters);
102
+
84
103
  case 'Widget':
85
104
  var fieldType = (0, _util.getInheritableProperty)({
86
105
  dict: dict,
87
106
  key: 'FT'
88
107
  });
89
108
  fieldType = (0, _primitives.isName)(fieldType) ? fieldType.name : null;
109
+
90
110
  switch (fieldType) {
91
111
  case 'Tx':
92
112
  return new TextWidgetAnnotation(parameters);
113
+
93
114
  case 'Btn':
94
115
  return new ButtonWidgetAnnotation(parameters);
116
+
95
117
  case 'Ch':
96
118
  return new ChoiceWidgetAnnotation(parameters);
97
119
  }
120
+
98
121
  (0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
99
122
  return new WidgetAnnotation(parameters);
123
+
100
124
  case 'Popup':
101
125
  return new PopupAnnotation(parameters);
126
+
102
127
  case 'Line':
103
128
  return new LineAnnotation(parameters);
129
+
104
130
  case 'Square':
105
131
  return new SquareAnnotation(parameters);
132
+
106
133
  case 'Circle':
107
134
  return new CircleAnnotation(parameters);
135
+
108
136
  case 'PolyLine':
109
137
  return new PolylineAnnotation(parameters);
138
+
110
139
  case 'Polygon':
111
140
  return new PolygonAnnotation(parameters);
141
+
112
142
  case 'Ink':
113
143
  return new InkAnnotation(parameters);
144
+
114
145
  case 'Highlight':
115
146
  return new HighlightAnnotation(parameters);
147
+
116
148
  case 'Underline':
117
149
  return new UnderlineAnnotation(parameters);
150
+
118
151
  case 'Squiggly':
119
152
  return new SquigglyAnnotation(parameters);
153
+
120
154
  case 'StrikeOut':
121
155
  return new StrikeOutAnnotation(parameters);
156
+
122
157
  case 'Stamp':
123
158
  return new StampAnnotation(parameters);
159
+
124
160
  case 'FileAttachment':
125
161
  return new FileAttachmentAnnotation(parameters);
162
+
126
163
  default:
127
164
  if (!subtype) {
128
165
  (0, _util.warn)('Annotation is missing the required /Subtype.');
129
166
  } else {
130
167
  (0, _util.warn)('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
131
168
  }
169
+
132
170
  return new Annotation(parameters);
133
171
  }
134
172
  }
@@ -137,21 +175,28 @@ var AnnotationFactory = function () {
137
175
  return AnnotationFactory;
138
176
  }();
139
177
 
178
+ exports.AnnotationFactory = AnnotationFactory;
179
+
140
180
  function getTransformMatrix(rect, bbox, matrix) {
141
181
  var bounds = _util.Util.getAxialAlignedBoundingBox(bbox, matrix);
182
+
142
183
  var minX = bounds[0];
143
184
  var minY = bounds[1];
144
185
  var maxX = bounds[2];
145
186
  var maxY = bounds[3];
187
+
146
188
  if (minX === maxX || minY === maxY) {
147
189
  return [1, 0, 0, 1, rect[0], rect[1]];
148
190
  }
191
+
149
192
  var xRatio = (rect[2] - rect[0]) / (maxX - minX);
150
193
  var yRatio = (rect[3] - rect[1]) / (maxY - minY);
151
194
  return [xRatio, 0, 0, yRatio, rect[0] - minX * xRatio, rect[1] - minY * yRatio];
152
195
  }
153
196
 
154
- var Annotation = function () {
197
+ var Annotation =
198
+ /*#__PURE__*/
199
+ function () {
155
200
  function Annotation(params) {
156
201
  _classCallCheck(this, Annotation);
157
202
 
@@ -173,32 +218,32 @@ var Annotation = function () {
173
218
  }
174
219
 
175
220
  _createClass(Annotation, [{
176
- key: '_hasFlag',
221
+ key: "_hasFlag",
177
222
  value: function _hasFlag(flags, flag) {
178
223
  return !!(flags & flag);
179
224
  }
180
225
  }, {
181
- key: '_isViewable',
226
+ key: "_isViewable",
182
227
  value: function _isViewable(flags) {
183
228
  return !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN) && !this._hasFlag(flags, _util.AnnotationFlag.NOVIEW);
184
229
  }
185
230
  }, {
186
- key: '_isPrintable',
231
+ key: "_isPrintable",
187
232
  value: function _isPrintable(flags) {
188
233
  return this._hasFlag(flags, _util.AnnotationFlag.PRINT) && !this._hasFlag(flags, _util.AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, _util.AnnotationFlag.HIDDEN);
189
234
  }
190
235
  }, {
191
- key: 'setFlags',
236
+ key: "setFlags",
192
237
  value: function setFlags(flags) {
193
238
  this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0;
194
239
  }
195
240
  }, {
196
- key: 'hasFlag',
241
+ key: "hasFlag",
197
242
  value: function hasFlag(flag) {
198
243
  return this._hasFlag(this.flags, flag);
199
244
  }
200
245
  }, {
201
- key: 'setRectangle',
246
+ key: "setRectangle",
202
247
  value: function setRectangle(rectangle) {
203
248
  if (Array.isArray(rectangle) && rectangle.length === 4) {
204
249
  this.rectangle = _util.Util.normalizeRect(rectangle);
@@ -207,44 +252,56 @@ var Annotation = function () {
207
252
  }
208
253
  }
209
254
  }, {
210
- key: 'setColor',
255
+ key: "setColor",
211
256
  value: function setColor(color) {
212
257
  var rgbColor = new Uint8ClampedArray(3);
258
+
213
259
  if (!Array.isArray(color)) {
214
260
  this.color = rgbColor;
215
261
  return;
216
262
  }
263
+
217
264
  switch (color.length) {
218
265
  case 0:
219
266
  this.color = null;
220
267
  break;
268
+
221
269
  case 1:
222
270
  _colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
271
+
223
272
  this.color = rgbColor;
224
273
  break;
274
+
225
275
  case 3:
226
276
  _colorspace.ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
277
+
227
278
  this.color = rgbColor;
228
279
  break;
280
+
229
281
  case 4:
230
282
  _colorspace.ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
283
+
231
284
  this.color = rgbColor;
232
285
  break;
286
+
233
287
  default:
234
288
  this.color = rgbColor;
235
289
  break;
236
290
  }
237
291
  }
238
292
  }, {
239
- key: 'setBorderStyle',
293
+ key: "setBorderStyle",
240
294
  value: function setBorderStyle(borderStyle) {
241
295
  this.borderStyle = new AnnotationBorderStyle();
296
+
242
297
  if (!(0, _primitives.isDict)(borderStyle)) {
243
298
  return;
244
299
  }
300
+
245
301
  if (borderStyle.has('BS')) {
246
302
  var dict = borderStyle.get('BS');
247
303
  var dictType = dict.get('Type');
304
+
248
305
  if (!dictType || (0, _primitives.isName)(dictType, 'Border')) {
249
306
  this.borderStyle.setWidth(dict.get('W'));
250
307
  this.borderStyle.setStyle(dict.get('S'));
@@ -252,10 +309,12 @@ var Annotation = function () {
252
309
  }
253
310
  } else if (borderStyle.has('Border')) {
254
311
  var array = borderStyle.getArray('Border');
312
+
255
313
  if (Array.isArray(array) && array.length >= 3) {
256
314
  this.borderStyle.setHorizontalCornerRadius(array[0]);
257
315
  this.borderStyle.setVerticalCornerRadius(array[1]);
258
316
  this.borderStyle.setWidth(array[2]);
317
+
259
318
  if (array.length === 4) {
260
319
  this.borderStyle.setDashArray(array[3]);
261
320
  }
@@ -265,44 +324,53 @@ var Annotation = function () {
265
324
  }
266
325
  }
267
326
  }, {
268
- key: 'setAppearance',
327
+ key: "setAppearance",
269
328
  value: function setAppearance(dict) {
270
329
  this.appearance = null;
271
330
  var appearanceStates = dict.get('AP');
331
+
272
332
  if (!(0, _primitives.isDict)(appearanceStates)) {
273
333
  return;
274
334
  }
335
+
275
336
  var normalAppearanceState = appearanceStates.get('N');
337
+
276
338
  if ((0, _primitives.isStream)(normalAppearanceState)) {
277
339
  this.appearance = normalAppearanceState;
278
340
  return;
279
341
  }
342
+
280
343
  if (!(0, _primitives.isDict)(normalAppearanceState)) {
281
344
  return;
282
345
  }
346
+
283
347
  var as = dict.get('AS');
348
+
284
349
  if (!(0, _primitives.isName)(as) || !normalAppearanceState.has(as.name)) {
285
350
  return;
286
351
  }
352
+
287
353
  this.appearance = normalAppearanceState.get(as.name);
288
354
  }
289
355
  }, {
290
- key: '_preparePopup',
356
+ key: "_preparePopup",
291
357
  value: function _preparePopup(dict) {
292
358
  if (!dict.has('C')) {
293
359
  this.data.color = null;
294
360
  }
361
+
295
362
  this.data.hasPopup = dict.has('Popup');
296
363
  this.data.title = (0, _util.stringToPDFString)(dict.get('T') || '');
297
364
  this.data.contents = (0, _util.stringToPDFString)(dict.get('Contents') || '');
298
365
  }
299
366
  }, {
300
- key: 'loadResources',
367
+ key: "loadResources",
301
368
  value: function loadResources(keys) {
302
369
  return this.appearance.dict.getAsync('Resources').then(function (resources) {
303
370
  if (!resources) {
304
371
  return;
305
372
  }
373
+
306
374
  var objectLoader = new _obj.ObjectLoader(resources, keys, resources.xref);
307
375
  return objectLoader.load().then(function () {
308
376
  return resources;
@@ -310,13 +378,14 @@ var Annotation = function () {
310
378
  });
311
379
  }
312
380
  }, {
313
- key: 'getOperatorList',
381
+ key: "getOperatorList",
314
382
  value: function getOperatorList(evaluator, task, renderForms) {
315
383
  var _this = this;
316
384
 
317
385
  if (!this.appearance) {
318
386
  return Promise.resolve(new _operator_list.OperatorList());
319
387
  }
388
+
320
389
  var data = this.data;
321
390
  var appearanceDict = this.appearance.dict;
322
391
  var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
@@ -333,25 +402,29 @@ var Annotation = function () {
333
402
  operatorList: opList
334
403
  }).then(function () {
335
404
  opList.addOp(_util.OPS.endAnnotation, []);
405
+
336
406
  _this.appearance.reset();
407
+
337
408
  return opList;
338
409
  });
339
410
  });
340
411
  }
341
412
  }, {
342
- key: 'viewable',
413
+ key: "viewable",
343
414
  get: function get() {
344
415
  if (this.flags === 0) {
345
416
  return true;
346
417
  }
418
+
347
419
  return this._isViewable(this.flags);
348
420
  }
349
421
  }, {
350
- key: 'printable',
422
+ key: "printable",
351
423
  get: function get() {
352
424
  if (this.flags === 0) {
353
425
  return false;
354
426
  }
427
+
355
428
  return this._isPrintable(this.flags);
356
429
  }
357
430
  }]);
@@ -359,7 +432,11 @@ var Annotation = function () {
359
432
  return Annotation;
360
433
  }();
361
434
 
362
- var AnnotationBorderStyle = function () {
435
+ exports.Annotation = Annotation;
436
+
437
+ var AnnotationBorderStyle =
438
+ /*#__PURE__*/
439
+ function () {
363
440
  function AnnotationBorderStyle() {
364
441
  _classCallCheck(this, AnnotationBorderStyle);
365
442
 
@@ -371,47 +448,60 @@ var AnnotationBorderStyle = function () {
371
448
  }
372
449
 
373
450
  _createClass(AnnotationBorderStyle, [{
374
- key: 'setWidth',
451
+ key: "setWidth",
375
452
  value: function setWidth(width) {
453
+ if ((0, _primitives.isName)(width)) {
454
+ this.width = 0;
455
+ return;
456
+ }
457
+
376
458
  if (Number.isInteger(width)) {
377
459
  this.width = width;
378
460
  }
379
461
  }
380
462
  }, {
381
- key: 'setStyle',
463
+ key: "setStyle",
382
464
  value: function setStyle(style) {
383
- if (!style) {
465
+ if (!(0, _primitives.isName)(style)) {
384
466
  return;
385
467
  }
468
+
386
469
  switch (style.name) {
387
470
  case 'S':
388
471
  this.style = _util.AnnotationBorderStyleType.SOLID;
389
472
  break;
473
+
390
474
  case 'D':
391
475
  this.style = _util.AnnotationBorderStyleType.DASHED;
392
476
  break;
477
+
393
478
  case 'B':
394
479
  this.style = _util.AnnotationBorderStyleType.BEVELED;
395
480
  break;
481
+
396
482
  case 'I':
397
483
  this.style = _util.AnnotationBorderStyleType.INSET;
398
484
  break;
485
+
399
486
  case 'U':
400
487
  this.style = _util.AnnotationBorderStyleType.UNDERLINE;
401
488
  break;
489
+
402
490
  default:
403
491
  break;
404
492
  }
405
493
  }
406
494
  }, {
407
- key: 'setDashArray',
495
+ key: "setDashArray",
408
496
  value: function setDashArray(dashArray) {
409
497
  if (Array.isArray(dashArray) && dashArray.length > 0) {
410
498
  var isValid = true;
411
499
  var allZeros = true;
500
+
412
501
  for (var i = 0, len = dashArray.length; i < len; i++) {
413
502
  var element = dashArray[i];
414
503
  var validNumber = +element >= 0;
504
+
415
505
  if (!validNumber) {
416
506
  isValid = false;
417
507
  break;
@@ -419,6 +509,7 @@ var AnnotationBorderStyle = function () {
419
509
  allZeros = false;
420
510
  }
421
511
  }
512
+
422
513
  if (isValid && !allZeros) {
423
514
  this.dashArray = dashArray;
424
515
  } else {
@@ -429,14 +520,14 @@ var AnnotationBorderStyle = function () {
429
520
  }
430
521
  }
431
522
  }, {
432
- key: 'setHorizontalCornerRadius',
523
+ key: "setHorizontalCornerRadius",
433
524
  value: function setHorizontalCornerRadius(radius) {
434
525
  if (Number.isInteger(radius)) {
435
526
  this.horizontalCornerRadius = radius;
436
527
  }
437
528
  }
438
529
  }, {
439
- key: 'setVerticalCornerRadius',
530
+ key: "setVerticalCornerRadius",
440
531
  value: function setVerticalCornerRadius(radius) {
441
532
  if (Number.isInteger(radius)) {
442
533
  this.verticalCornerRadius = radius;
@@ -447,14 +538,19 @@ var AnnotationBorderStyle = function () {
447
538
  return AnnotationBorderStyle;
448
539
  }();
449
540
 
450
- var WidgetAnnotation = function (_Annotation) {
541
+ exports.AnnotationBorderStyle = AnnotationBorderStyle;
542
+
543
+ var WidgetAnnotation =
544
+ /*#__PURE__*/
545
+ function (_Annotation) {
451
546
  _inherits(WidgetAnnotation, _Annotation);
452
547
 
453
548
  function WidgetAnnotation(params) {
454
- _classCallCheck(this, WidgetAnnotation);
549
+ var _this2;
455
550
 
456
- var _this2 = _possibleConstructorReturn(this, (WidgetAnnotation.__proto__ || Object.getPrototypeOf(WidgetAnnotation)).call(this, params));
551
+ _classCallCheck(this, WidgetAnnotation);
457
552
 
553
+ _this2 = _possibleConstructorReturn(this, _getPrototypeOf(WidgetAnnotation).call(this, params));
458
554
  var dict = params.dict;
459
555
  var data = _this2.data;
460
556
  data.annotationType = _util.AnnotationType.WIDGET;
@@ -482,85 +578,107 @@ var WidgetAnnotation = function (_Annotation) {
482
578
  dict: dict,
483
579
  key: 'Ff'
484
580
  });
581
+
485
582
  if (!Number.isInteger(data.fieldFlags) || data.fieldFlags < 0) {
486
583
  data.fieldFlags = 0;
487
584
  }
585
+
488
586
  data.readOnly = _this2.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
587
+
489
588
  if (data.fieldType === 'Sig') {
589
+ data.fieldValue = null;
590
+
490
591
  _this2.setFlags(_util.AnnotationFlag.HIDDEN);
491
592
  }
593
+
492
594
  return _this2;
493
595
  }
494
596
 
495
597
  _createClass(WidgetAnnotation, [{
496
- key: '_constructFieldName',
598
+ key: "_constructFieldName",
497
599
  value: function _constructFieldName(dict) {
498
600
  if (!dict.has('T') && !dict.has('Parent')) {
499
601
  (0, _util.warn)('Unknown field name, falling back to empty field name.');
500
602
  return '';
501
603
  }
604
+
502
605
  if (!dict.has('Parent')) {
503
606
  return (0, _util.stringToPDFString)(dict.get('T'));
504
607
  }
608
+
505
609
  var fieldName = [];
610
+
506
611
  if (dict.has('T')) {
507
612
  fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
508
613
  }
614
+
509
615
  var loopDict = dict;
616
+
510
617
  while (loopDict.has('Parent')) {
511
618
  loopDict = loopDict.get('Parent');
619
+
512
620
  if (!(0, _primitives.isDict)(loopDict)) {
513
621
  break;
514
622
  }
623
+
515
624
  if (loopDict.has('T')) {
516
625
  fieldName.unshift((0, _util.stringToPDFString)(loopDict.get('T')));
517
626
  }
518
627
  }
628
+
519
629
  return fieldName.join('.');
520
630
  }
521
631
  }, {
522
- key: 'hasFieldFlag',
632
+ key: "hasFieldFlag",
523
633
  value: function hasFieldFlag(flag) {
524
634
  return !!(this.data.fieldFlags & flag);
525
635
  }
526
636
  }, {
527
- key: 'getOperatorList',
637
+ key: "getOperatorList",
528
638
  value: function getOperatorList(evaluator, task, renderForms) {
529
639
  if (renderForms) {
530
640
  return Promise.resolve(new _operator_list.OperatorList());
531
641
  }
532
- return _get(WidgetAnnotation.prototype.__proto__ || Object.getPrototypeOf(WidgetAnnotation.prototype), 'getOperatorList', this).call(this, evaluator, task, renderForms);
642
+
643
+ return _get(_getPrototypeOf(WidgetAnnotation.prototype), "getOperatorList", this).call(this, evaluator, task, renderForms);
533
644
  }
534
645
  }]);
535
646
 
536
647
  return WidgetAnnotation;
537
648
  }(Annotation);
538
649
 
539
- var TextWidgetAnnotation = function (_WidgetAnnotation) {
650
+ var TextWidgetAnnotation =
651
+ /*#__PURE__*/
652
+ function (_WidgetAnnotation) {
540
653
  _inherits(TextWidgetAnnotation, _WidgetAnnotation);
541
654
 
542
655
  function TextWidgetAnnotation(params) {
543
- _classCallCheck(this, TextWidgetAnnotation);
656
+ var _this3;
544
657
 
545
- var _this3 = _possibleConstructorReturn(this, (TextWidgetAnnotation.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation)).call(this, params));
658
+ _classCallCheck(this, TextWidgetAnnotation);
546
659
 
660
+ _this3 = _possibleConstructorReturn(this, _getPrototypeOf(TextWidgetAnnotation).call(this, params));
547
661
  var dict = params.dict;
548
662
  _this3.data.fieldValue = (0, _util.stringToPDFString)(_this3.data.fieldValue || '');
549
663
  var alignment = (0, _util.getInheritableProperty)({
550
664
  dict: dict,
551
665
  key: 'Q'
552
666
  });
667
+
553
668
  if (!Number.isInteger(alignment) || alignment < 0 || alignment > 2) {
554
669
  alignment = null;
555
670
  }
671
+
556
672
  _this3.data.textAlignment = alignment;
557
673
  var maximumLength = (0, _util.getInheritableProperty)({
558
674
  dict: dict,
559
675
  key: 'MaxLen'
560
676
  });
677
+
561
678
  if (!Number.isInteger(maximumLength) || maximumLength < 0) {
562
679
  maximumLength = null;
563
680
  }
681
+
564
682
  _this3.data.maxLen = maximumLength;
565
683
  _this3.data.multiLine = _this3.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE);
566
684
  _this3.data.comb = _this3.hasFieldFlag(_util.AnnotationFieldFlag.COMB) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.MULTILINE) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.PASSWORD) && !_this3.hasFieldFlag(_util.AnnotationFieldFlag.FILESELECT) && _this3.data.maxLen !== null;
@@ -568,15 +686,18 @@ var TextWidgetAnnotation = function (_WidgetAnnotation) {
568
686
  }
569
687
 
570
688
  _createClass(TextWidgetAnnotation, [{
571
- key: 'getOperatorList',
689
+ key: "getOperatorList",
572
690
  value: function getOperatorList(evaluator, task, renderForms) {
573
691
  if (renderForms || this.appearance) {
574
- return _get(TextWidgetAnnotation.prototype.__proto__ || Object.getPrototypeOf(TextWidgetAnnotation.prototype), 'getOperatorList', this).call(this, evaluator, task, renderForms);
692
+ return _get(_getPrototypeOf(TextWidgetAnnotation.prototype), "getOperatorList", this).call(this, evaluator, task, renderForms);
575
693
  }
694
+
576
695
  var operatorList = new _operator_list.OperatorList();
696
+
577
697
  if (!this.data.defaultAppearance) {
578
698
  return Promise.resolve(operatorList);
579
699
  }
700
+
580
701
  var stream = new _stream.Stream((0, _util.stringToBytes)(this.data.defaultAppearance));
581
702
  return evaluator.getOperatorList({
582
703
  stream: stream,
@@ -592,17 +713,21 @@ var TextWidgetAnnotation = function (_WidgetAnnotation) {
592
713
  return TextWidgetAnnotation;
593
714
  }(WidgetAnnotation);
594
715
 
595
- var ButtonWidgetAnnotation = function (_WidgetAnnotation2) {
716
+ var ButtonWidgetAnnotation =
717
+ /*#__PURE__*/
718
+ function (_WidgetAnnotation2) {
596
719
  _inherits(ButtonWidgetAnnotation, _WidgetAnnotation2);
597
720
 
598
721
  function ButtonWidgetAnnotation(params) {
599
- _classCallCheck(this, ButtonWidgetAnnotation);
722
+ var _this4;
600
723
 
601
- var _this4 = _possibleConstructorReturn(this, (ButtonWidgetAnnotation.__proto__ || Object.getPrototypeOf(ButtonWidgetAnnotation)).call(this, params));
724
+ _classCallCheck(this, ButtonWidgetAnnotation);
602
725
 
726
+ _this4 = _possibleConstructorReturn(this, _getPrototypeOf(ButtonWidgetAnnotation).call(this, params));
603
727
  _this4.data.checkBox = !_this4.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
604
728
  _this4.data.radioButton = _this4.hasFieldFlag(_util.AnnotationFieldFlag.RADIO) && !_this4.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
605
729
  _this4.data.pushButton = _this4.hasFieldFlag(_util.AnnotationFieldFlag.PUSHBUTTON);
730
+
606
731
  if (_this4.data.checkBox) {
607
732
  _this4._processCheckBox(params);
608
733
  } else if (_this4.data.radioButton) {
@@ -612,50 +737,66 @@ var ButtonWidgetAnnotation = function (_WidgetAnnotation2) {
612
737
  } else {
613
738
  (0, _util.warn)('Invalid field flags for button widget annotation');
614
739
  }
740
+
615
741
  return _this4;
616
742
  }
617
743
 
618
744
  _createClass(ButtonWidgetAnnotation, [{
619
- key: '_processCheckBox',
745
+ key: "_processCheckBox",
620
746
  value: function _processCheckBox(params) {
621
747
  if ((0, _primitives.isName)(this.data.fieldValue)) {
622
748
  this.data.fieldValue = this.data.fieldValue.name;
623
749
  }
750
+
624
751
  var customAppearance = params.dict.get('AP');
752
+
625
753
  if (!(0, _primitives.isDict)(customAppearance)) {
626
754
  return;
627
755
  }
756
+
628
757
  var exportValueOptionsDict = customAppearance.get('D');
758
+
629
759
  if (!(0, _primitives.isDict)(exportValueOptionsDict)) {
630
760
  return;
631
761
  }
762
+
632
763
  var exportValues = exportValueOptionsDict.getKeys();
633
764
  var hasCorrectOptionCount = exportValues.length === 2;
765
+
634
766
  if (!hasCorrectOptionCount) {
635
767
  return;
636
768
  }
769
+
637
770
  this.data.exportValue = exportValues[0] === 'Off' ? exportValues[1] : exportValues[0];
638
771
  }
639
772
  }, {
640
- key: '_processRadioButton',
773
+ key: "_processRadioButton",
641
774
  value: function _processRadioButton(params) {
642
775
  this.data.fieldValue = this.data.buttonValue = null;
643
776
  var fieldParent = params.dict.get('Parent');
777
+
644
778
  if ((0, _primitives.isDict)(fieldParent) && fieldParent.has('V')) {
645
779
  var fieldParentValue = fieldParent.get('V');
780
+
646
781
  if ((0, _primitives.isName)(fieldParentValue)) {
647
782
  this.data.fieldValue = fieldParentValue.name;
648
783
  }
649
784
  }
785
+
650
786
  var appearanceStates = params.dict.get('AP');
787
+
651
788
  if (!(0, _primitives.isDict)(appearanceStates)) {
652
789
  return;
653
790
  }
791
+
654
792
  var normalAppearanceState = appearanceStates.get('N');
793
+
655
794
  if (!(0, _primitives.isDict)(normalAppearanceState)) {
656
795
  return;
657
796
  }
797
+
658
798
  var keys = normalAppearanceState.getKeys();
799
+
659
800
  for (var i = 0, ii = keys.length; i < ii; i++) {
660
801
  if (keys[i] !== 'Off') {
661
802
  this.data.buttonValue = keys[i];
@@ -664,12 +805,13 @@ var ButtonWidgetAnnotation = function (_WidgetAnnotation2) {
664
805
  }
665
806
  }
666
807
  }, {
667
- key: '_processPushButton',
808
+ key: "_processPushButton",
668
809
  value: function _processPushButton(params) {
669
810
  if (!params.dict.has('A')) {
670
811
  (0, _util.warn)('Push buttons without action dictionaries are not supported');
671
812
  return;
672
813
  }
814
+
673
815
  _obj.Catalog.parseDestDictionary({
674
816
  destDict: params.dict,
675
817
  resultObj: this.data,
@@ -681,21 +823,26 @@ var ButtonWidgetAnnotation = function (_WidgetAnnotation2) {
681
823
  return ButtonWidgetAnnotation;
682
824
  }(WidgetAnnotation);
683
825
 
684
- var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
826
+ var ChoiceWidgetAnnotation =
827
+ /*#__PURE__*/
828
+ function (_WidgetAnnotation3) {
685
829
  _inherits(ChoiceWidgetAnnotation, _WidgetAnnotation3);
686
830
 
687
831
  function ChoiceWidgetAnnotation(params) {
688
- _classCallCheck(this, ChoiceWidgetAnnotation);
832
+ var _this5;
689
833
 
690
- var _this5 = _possibleConstructorReturn(this, (ChoiceWidgetAnnotation.__proto__ || Object.getPrototypeOf(ChoiceWidgetAnnotation)).call(this, params));
834
+ _classCallCheck(this, ChoiceWidgetAnnotation);
691
835
 
836
+ _this5 = _possibleConstructorReturn(this, _getPrototypeOf(ChoiceWidgetAnnotation).call(this, params));
692
837
  _this5.data.options = [];
693
838
  var options = (0, _util.getInheritableProperty)({
694
839
  dict: params.dict,
695
840
  key: 'Opt'
696
841
  });
842
+
697
843
  if (Array.isArray(options)) {
698
844
  var xref = params.xref;
845
+
699
846
  for (var i = 0, ii = options.length; i < ii; i++) {
700
847
  var option = xref.fetchIfRef(options[i]);
701
848
  var isOptionArray = Array.isArray(option);
@@ -705,9 +852,11 @@ var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
705
852
  };
706
853
  }
707
854
  }
855
+
708
856
  if (!Array.isArray(_this5.data.fieldValue)) {
709
857
  _this5.data.fieldValue = [_this5.data.fieldValue];
710
858
  }
859
+
711
860
  _this5.data.combo = _this5.hasFieldFlag(_util.AnnotationFieldFlag.COMBO);
712
861
  _this5.data.multiSelect = _this5.hasFieldFlag(_util.AnnotationFieldFlag.MULTISELECT);
713
862
  return _this5;
@@ -716,17 +865,20 @@ var ChoiceWidgetAnnotation = function (_WidgetAnnotation3) {
716
865
  return ChoiceWidgetAnnotation;
717
866
  }(WidgetAnnotation);
718
867
 
719
- var TextAnnotation = function (_Annotation2) {
868
+ var TextAnnotation =
869
+ /*#__PURE__*/
870
+ function (_Annotation2) {
720
871
  _inherits(TextAnnotation, _Annotation2);
721
872
 
722
873
  function TextAnnotation(parameters) {
874
+ var _this6;
875
+
723
876
  _classCallCheck(this, TextAnnotation);
724
877
 
725
878
  var DEFAULT_ICON_SIZE = 22;
726
-
727
- var _this6 = _possibleConstructorReturn(this, (TextAnnotation.__proto__ || Object.getPrototypeOf(TextAnnotation)).call(this, parameters));
728
-
879
+ _this6 = _possibleConstructorReturn(this, _getPrototypeOf(TextAnnotation).call(this, parameters));
729
880
  _this6.data.annotationType = _util.AnnotationType.TEXT;
881
+
730
882
  if (_this6.data.hasAppearance) {
731
883
  _this6.data.name = 'NoIcon';
732
884
  } else {
@@ -734,154 +886,195 @@ var TextAnnotation = function (_Annotation2) {
734
886
  _this6.data.rect[2] = _this6.data.rect[0] + DEFAULT_ICON_SIZE;
735
887
  _this6.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
736
888
  }
889
+
737
890
  _this6._preparePopup(parameters.dict);
891
+
738
892
  return _this6;
739
893
  }
740
894
 
741
895
  return TextAnnotation;
742
896
  }(Annotation);
743
897
 
744
- var LinkAnnotation = function (_Annotation3) {
898
+ var LinkAnnotation =
899
+ /*#__PURE__*/
900
+ function (_Annotation3) {
745
901
  _inherits(LinkAnnotation, _Annotation3);
746
902
 
747
903
  function LinkAnnotation(params) {
748
- _classCallCheck(this, LinkAnnotation);
904
+ var _this7;
749
905
 
750
- var _this7 = _possibleConstructorReturn(this, (LinkAnnotation.__proto__ || Object.getPrototypeOf(LinkAnnotation)).call(this, params));
906
+ _classCallCheck(this, LinkAnnotation);
751
907
 
908
+ _this7 = _possibleConstructorReturn(this, _getPrototypeOf(LinkAnnotation).call(this, params));
752
909
  _this7.data.annotationType = _util.AnnotationType.LINK;
910
+
753
911
  _obj.Catalog.parseDestDictionary({
754
912
  destDict: params.dict,
755
913
  resultObj: _this7.data,
756
914
  docBaseUrl: params.pdfManager.docBaseUrl
757
915
  });
916
+
758
917
  return _this7;
759
918
  }
760
919
 
761
920
  return LinkAnnotation;
762
921
  }(Annotation);
763
922
 
764
- var PopupAnnotation = function (_Annotation4) {
923
+ var PopupAnnotation =
924
+ /*#__PURE__*/
925
+ function (_Annotation4) {
765
926
  _inherits(PopupAnnotation, _Annotation4);
766
927
 
767
928
  function PopupAnnotation(parameters) {
768
- _classCallCheck(this, PopupAnnotation);
929
+ var _this8;
769
930
 
770
- var _this8 = _possibleConstructorReturn(this, (PopupAnnotation.__proto__ || Object.getPrototypeOf(PopupAnnotation)).call(this, parameters));
931
+ _classCallCheck(this, PopupAnnotation);
771
932
 
933
+ _this8 = _possibleConstructorReturn(this, _getPrototypeOf(PopupAnnotation).call(this, parameters));
772
934
  _this8.data.annotationType = _util.AnnotationType.POPUP;
773
935
  var dict = parameters.dict;
774
936
  var parentItem = dict.get('Parent');
937
+
775
938
  if (!parentItem) {
776
939
  (0, _util.warn)('Popup annotation has a missing or invalid parent annotation.');
777
940
  return _possibleConstructorReturn(_this8);
778
941
  }
942
+
779
943
  var parentSubtype = parentItem.get('Subtype');
780
944
  _this8.data.parentType = (0, _primitives.isName)(parentSubtype) ? parentSubtype.name : null;
781
945
  _this8.data.parentId = dict.getRaw('Parent').toString();
782
946
  _this8.data.title = (0, _util.stringToPDFString)(parentItem.get('T') || '');
783
947
  _this8.data.contents = (0, _util.stringToPDFString)(parentItem.get('Contents') || '');
948
+
784
949
  if (!parentItem.has('C')) {
785
950
  _this8.data.color = null;
786
951
  } else {
787
952
  _this8.setColor(parentItem.getArray('C'));
953
+
788
954
  _this8.data.color = _this8.color;
789
955
  }
956
+
790
957
  if (!_this8.viewable) {
791
958
  var parentFlags = parentItem.get('F');
959
+
792
960
  if (_this8._isViewable(parentFlags)) {
793
961
  _this8.setFlags(parentFlags);
794
962
  }
795
963
  }
964
+
796
965
  return _this8;
797
966
  }
798
967
 
799
968
  return PopupAnnotation;
800
969
  }(Annotation);
801
970
 
802
- var LineAnnotation = function (_Annotation5) {
971
+ var LineAnnotation =
972
+ /*#__PURE__*/
973
+ function (_Annotation5) {
803
974
  _inherits(LineAnnotation, _Annotation5);
804
975
 
805
976
  function LineAnnotation(parameters) {
806
- _classCallCheck(this, LineAnnotation);
977
+ var _this9;
807
978
 
808
- var _this9 = _possibleConstructorReturn(this, (LineAnnotation.__proto__ || Object.getPrototypeOf(LineAnnotation)).call(this, parameters));
979
+ _classCallCheck(this, LineAnnotation);
809
980
 
981
+ _this9 = _possibleConstructorReturn(this, _getPrototypeOf(LineAnnotation).call(this, parameters));
810
982
  _this9.data.annotationType = _util.AnnotationType.LINE;
811
983
  var dict = parameters.dict;
812
984
  _this9.data.lineCoordinates = _util.Util.normalizeRect(dict.getArray('L'));
985
+
813
986
  _this9._preparePopup(dict);
987
+
814
988
  return _this9;
815
989
  }
816
990
 
817
991
  return LineAnnotation;
818
992
  }(Annotation);
819
993
 
820
- var SquareAnnotation = function (_Annotation6) {
994
+ var SquareAnnotation =
995
+ /*#__PURE__*/
996
+ function (_Annotation6) {
821
997
  _inherits(SquareAnnotation, _Annotation6);
822
998
 
823
999
  function SquareAnnotation(parameters) {
824
- _classCallCheck(this, SquareAnnotation);
1000
+ var _this10;
825
1001
 
826
- var _this10 = _possibleConstructorReturn(this, (SquareAnnotation.__proto__ || Object.getPrototypeOf(SquareAnnotation)).call(this, parameters));
1002
+ _classCallCheck(this, SquareAnnotation);
827
1003
 
1004
+ _this10 = _possibleConstructorReturn(this, _getPrototypeOf(SquareAnnotation).call(this, parameters));
828
1005
  _this10.data.annotationType = _util.AnnotationType.SQUARE;
1006
+
829
1007
  _this10._preparePopup(parameters.dict);
1008
+
830
1009
  return _this10;
831
1010
  }
832
1011
 
833
1012
  return SquareAnnotation;
834
1013
  }(Annotation);
835
1014
 
836
- var CircleAnnotation = function (_Annotation7) {
1015
+ var CircleAnnotation =
1016
+ /*#__PURE__*/
1017
+ function (_Annotation7) {
837
1018
  _inherits(CircleAnnotation, _Annotation7);
838
1019
 
839
1020
  function CircleAnnotation(parameters) {
840
- _classCallCheck(this, CircleAnnotation);
1021
+ var _this11;
841
1022
 
842
- var _this11 = _possibleConstructorReturn(this, (CircleAnnotation.__proto__ || Object.getPrototypeOf(CircleAnnotation)).call(this, parameters));
1023
+ _classCallCheck(this, CircleAnnotation);
843
1024
 
1025
+ _this11 = _possibleConstructorReturn(this, _getPrototypeOf(CircleAnnotation).call(this, parameters));
844
1026
  _this11.data.annotationType = _util.AnnotationType.CIRCLE;
1027
+
845
1028
  _this11._preparePopup(parameters.dict);
1029
+
846
1030
  return _this11;
847
1031
  }
848
1032
 
849
1033
  return CircleAnnotation;
850
1034
  }(Annotation);
851
1035
 
852
- var PolylineAnnotation = function (_Annotation8) {
1036
+ var PolylineAnnotation =
1037
+ /*#__PURE__*/
1038
+ function (_Annotation8) {
853
1039
  _inherits(PolylineAnnotation, _Annotation8);
854
1040
 
855
1041
  function PolylineAnnotation(parameters) {
856
- _classCallCheck(this, PolylineAnnotation);
1042
+ var _this12;
857
1043
 
858
- var _this12 = _possibleConstructorReturn(this, (PolylineAnnotation.__proto__ || Object.getPrototypeOf(PolylineAnnotation)).call(this, parameters));
1044
+ _classCallCheck(this, PolylineAnnotation);
859
1045
 
1046
+ _this12 = _possibleConstructorReturn(this, _getPrototypeOf(PolylineAnnotation).call(this, parameters));
860
1047
  _this12.data.annotationType = _util.AnnotationType.POLYLINE;
861
1048
  var dict = parameters.dict;
862
1049
  var rawVertices = dict.getArray('Vertices');
863
1050
  _this12.data.vertices = [];
1051
+
864
1052
  for (var i = 0, ii = rawVertices.length; i < ii; i += 2) {
865
1053
  _this12.data.vertices.push({
866
1054
  x: rawVertices[i],
867
1055
  y: rawVertices[i + 1]
868
1056
  });
869
1057
  }
1058
+
870
1059
  _this12._preparePopup(dict);
1060
+
871
1061
  return _this12;
872
1062
  }
873
1063
 
874
1064
  return PolylineAnnotation;
875
1065
  }(Annotation);
876
1066
 
877
- var PolygonAnnotation = function (_PolylineAnnotation) {
1067
+ var PolygonAnnotation =
1068
+ /*#__PURE__*/
1069
+ function (_PolylineAnnotation) {
878
1070
  _inherits(PolygonAnnotation, _PolylineAnnotation);
879
1071
 
880
1072
  function PolygonAnnotation(parameters) {
881
- _classCallCheck(this, PolygonAnnotation);
1073
+ var _this13;
882
1074
 
883
- var _this13 = _possibleConstructorReturn(this, (PolygonAnnotation.__proto__ || Object.getPrototypeOf(PolygonAnnotation)).call(this, parameters));
1075
+ _classCallCheck(this, PolygonAnnotation);
884
1076
 
1077
+ _this13 = _possibleConstructorReturn(this, _getPrototypeOf(PolygonAnnotation).call(this, parameters));
885
1078
  _this13.data.annotationType = _util.AnnotationType.POLYGON;
886
1079
  return _this13;
887
1080
  }
@@ -889,21 +1082,26 @@ var PolygonAnnotation = function (_PolylineAnnotation) {
889
1082
  return PolygonAnnotation;
890
1083
  }(PolylineAnnotation);
891
1084
 
892
- var InkAnnotation = function (_Annotation9) {
1085
+ var InkAnnotation =
1086
+ /*#__PURE__*/
1087
+ function (_Annotation9) {
893
1088
  _inherits(InkAnnotation, _Annotation9);
894
1089
 
895
1090
  function InkAnnotation(parameters) {
896
- _classCallCheck(this, InkAnnotation);
1091
+ var _this14;
897
1092
 
898
- var _this14 = _possibleConstructorReturn(this, (InkAnnotation.__proto__ || Object.getPrototypeOf(InkAnnotation)).call(this, parameters));
1093
+ _classCallCheck(this, InkAnnotation);
899
1094
 
1095
+ _this14 = _possibleConstructorReturn(this, _getPrototypeOf(InkAnnotation).call(this, parameters));
900
1096
  _this14.data.annotationType = _util.AnnotationType.INK;
901
1097
  var dict = parameters.dict;
902
1098
  var xref = parameters.xref;
903
1099
  var originalInkLists = dict.getArray('InkList');
904
1100
  _this14.data.inkLists = [];
1101
+
905
1102
  for (var i = 0, ii = originalInkLists.length; i < ii; ++i) {
906
1103
  _this14.data.inkLists.push([]);
1104
+
907
1105
  for (var j = 0, jj = originalInkLists[i].length; j < jj; j += 2) {
908
1106
  _this14.data.inkLists[i].push({
909
1107
  x: xref.fetchIfRef(originalInkLists[i][j]),
@@ -911,111 +1109,139 @@ var InkAnnotation = function (_Annotation9) {
911
1109
  });
912
1110
  }
913
1111
  }
1112
+
914
1113
  _this14._preparePopup(dict);
1114
+
915
1115
  return _this14;
916
1116
  }
917
1117
 
918
1118
  return InkAnnotation;
919
1119
  }(Annotation);
920
1120
 
921
- var HighlightAnnotation = function (_Annotation10) {
1121
+ var HighlightAnnotation =
1122
+ /*#__PURE__*/
1123
+ function (_Annotation10) {
922
1124
  _inherits(HighlightAnnotation, _Annotation10);
923
1125
 
924
1126
  function HighlightAnnotation(parameters) {
925
- _classCallCheck(this, HighlightAnnotation);
1127
+ var _this15;
926
1128
 
927
- var _this15 = _possibleConstructorReturn(this, (HighlightAnnotation.__proto__ || Object.getPrototypeOf(HighlightAnnotation)).call(this, parameters));
1129
+ _classCallCheck(this, HighlightAnnotation);
928
1130
 
1131
+ _this15 = _possibleConstructorReturn(this, _getPrototypeOf(HighlightAnnotation).call(this, parameters));
929
1132
  _this15.data.annotationType = _util.AnnotationType.HIGHLIGHT;
1133
+
930
1134
  _this15._preparePopup(parameters.dict);
1135
+
931
1136
  return _this15;
932
1137
  }
933
1138
 
934
1139
  return HighlightAnnotation;
935
1140
  }(Annotation);
936
1141
 
937
- var UnderlineAnnotation = function (_Annotation11) {
1142
+ var UnderlineAnnotation =
1143
+ /*#__PURE__*/
1144
+ function (_Annotation11) {
938
1145
  _inherits(UnderlineAnnotation, _Annotation11);
939
1146
 
940
1147
  function UnderlineAnnotation(parameters) {
941
- _classCallCheck(this, UnderlineAnnotation);
1148
+ var _this16;
942
1149
 
943
- var _this16 = _possibleConstructorReturn(this, (UnderlineAnnotation.__proto__ || Object.getPrototypeOf(UnderlineAnnotation)).call(this, parameters));
1150
+ _classCallCheck(this, UnderlineAnnotation);
944
1151
 
1152
+ _this16 = _possibleConstructorReturn(this, _getPrototypeOf(UnderlineAnnotation).call(this, parameters));
945
1153
  _this16.data.annotationType = _util.AnnotationType.UNDERLINE;
1154
+
946
1155
  _this16._preparePopup(parameters.dict);
1156
+
947
1157
  return _this16;
948
1158
  }
949
1159
 
950
1160
  return UnderlineAnnotation;
951
1161
  }(Annotation);
952
1162
 
953
- var SquigglyAnnotation = function (_Annotation12) {
1163
+ var SquigglyAnnotation =
1164
+ /*#__PURE__*/
1165
+ function (_Annotation12) {
954
1166
  _inherits(SquigglyAnnotation, _Annotation12);
955
1167
 
956
1168
  function SquigglyAnnotation(parameters) {
957
- _classCallCheck(this, SquigglyAnnotation);
1169
+ var _this17;
958
1170
 
959
- var _this17 = _possibleConstructorReturn(this, (SquigglyAnnotation.__proto__ || Object.getPrototypeOf(SquigglyAnnotation)).call(this, parameters));
1171
+ _classCallCheck(this, SquigglyAnnotation);
960
1172
 
1173
+ _this17 = _possibleConstructorReturn(this, _getPrototypeOf(SquigglyAnnotation).call(this, parameters));
961
1174
  _this17.data.annotationType = _util.AnnotationType.SQUIGGLY;
1175
+
962
1176
  _this17._preparePopup(parameters.dict);
1177
+
963
1178
  return _this17;
964
1179
  }
965
1180
 
966
1181
  return SquigglyAnnotation;
967
1182
  }(Annotation);
968
1183
 
969
- var StrikeOutAnnotation = function (_Annotation13) {
1184
+ var StrikeOutAnnotation =
1185
+ /*#__PURE__*/
1186
+ function (_Annotation13) {
970
1187
  _inherits(StrikeOutAnnotation, _Annotation13);
971
1188
 
972
1189
  function StrikeOutAnnotation(parameters) {
973
- _classCallCheck(this, StrikeOutAnnotation);
1190
+ var _this18;
974
1191
 
975
- var _this18 = _possibleConstructorReturn(this, (StrikeOutAnnotation.__proto__ || Object.getPrototypeOf(StrikeOutAnnotation)).call(this, parameters));
1192
+ _classCallCheck(this, StrikeOutAnnotation);
976
1193
 
1194
+ _this18 = _possibleConstructorReturn(this, _getPrototypeOf(StrikeOutAnnotation).call(this, parameters));
977
1195
  _this18.data.annotationType = _util.AnnotationType.STRIKEOUT;
1196
+
978
1197
  _this18._preparePopup(parameters.dict);
1198
+
979
1199
  return _this18;
980
1200
  }
981
1201
 
982
1202
  return StrikeOutAnnotation;
983
1203
  }(Annotation);
984
1204
 
985
- var StampAnnotation = function (_Annotation14) {
1205
+ var StampAnnotation =
1206
+ /*#__PURE__*/
1207
+ function (_Annotation14) {
986
1208
  _inherits(StampAnnotation, _Annotation14);
987
1209
 
988
1210
  function StampAnnotation(parameters) {
989
- _classCallCheck(this, StampAnnotation);
1211
+ var _this19;
990
1212
 
991
- var _this19 = _possibleConstructorReturn(this, (StampAnnotation.__proto__ || Object.getPrototypeOf(StampAnnotation)).call(this, parameters));
1213
+ _classCallCheck(this, StampAnnotation);
992
1214
 
1215
+ _this19 = _possibleConstructorReturn(this, _getPrototypeOf(StampAnnotation).call(this, parameters));
993
1216
  _this19.data.annotationType = _util.AnnotationType.STAMP;
1217
+
994
1218
  _this19._preparePopup(parameters.dict);
1219
+
995
1220
  return _this19;
996
1221
  }
997
1222
 
998
1223
  return StampAnnotation;
999
1224
  }(Annotation);
1000
1225
 
1001
- var FileAttachmentAnnotation = function (_Annotation15) {
1226
+ var FileAttachmentAnnotation =
1227
+ /*#__PURE__*/
1228
+ function (_Annotation15) {
1002
1229
  _inherits(FileAttachmentAnnotation, _Annotation15);
1003
1230
 
1004
1231
  function FileAttachmentAnnotation(parameters) {
1005
- _classCallCheck(this, FileAttachmentAnnotation);
1232
+ var _this20;
1006
1233
 
1007
- var _this20 = _possibleConstructorReturn(this, (FileAttachmentAnnotation.__proto__ || Object.getPrototypeOf(FileAttachmentAnnotation)).call(this, parameters));
1234
+ _classCallCheck(this, FileAttachmentAnnotation);
1008
1235
 
1236
+ _this20 = _possibleConstructorReturn(this, _getPrototypeOf(FileAttachmentAnnotation).call(this, parameters));
1009
1237
  var file = new _obj.FileSpec(parameters.dict.get('FS'), parameters.xref);
1010
1238
  _this20.data.annotationType = _util.AnnotationType.FILEATTACHMENT;
1011
1239
  _this20.data.file = file.serializable;
1240
+
1012
1241
  _this20._preparePopup(parameters.dict);
1242
+
1013
1243
  return _this20;
1014
1244
  }
1015
1245
 
1016
1246
  return FileAttachmentAnnotation;
1017
- }(Annotation);
1018
-
1019
- exports.Annotation = Annotation;
1020
- exports.AnnotationBorderStyle = AnnotationBorderStyle;
1021
- exports.AnnotationFactory = AnnotationFactory;
1247
+ }(Annotation);