pdfjs-dist 2.1.266 → 2.5.207

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

Potentially problematic release.


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

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