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