pdfjs-dist 2.0.550 → 2.3.200

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