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