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.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8382 -18492
- 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 +20417 -29816
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25688 -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 +58239 -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 +403 -0
- package/es5/web/pdf_viewer.js +7742 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1475 -4897
- 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 +750 -899
- 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 +235 -183
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +447 -542
- package/lib/core/cmap.js +222 -264
- package/lib/core/colorspace.js +699 -863
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +379 -437
- package/lib/core/document.js +573 -660
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +1103 -868
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +570 -491
- package/lib/core/function.js +291 -288
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +145 -149
- package/lib/core/image_utils.js +170 -0
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +284 -232
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2929 -2929
- package/lib/core/murmurhash3.js +90 -101
- package/lib/core/obj.js +1183 -1157
- package/lib/core/operator_list.js +99 -67
- package/lib/core/parser.js +972 -911
- package/lib/core/pattern.js +87 -70
- package/lib/core/pdf_manager.js +150 -315
- package/lib/core/primitives.js +83 -56
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +87 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +193 -390
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +741 -972
- package/lib/display/api.js +1500 -1791
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +165 -165
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +515 -0
- package/lib/display/fetch_stream.js +183 -298
- package/lib/display/font_loader.js +273 -413
- package/lib/display/metadata.js +86 -98
- package/lib/display/network.js +266 -359
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +285 -458
- package/lib/display/pattern_helper.js +113 -65
- package/lib/display/svg.js +1166 -901
- package/lib/display/text_layer.js +156 -132
- package/lib/display/transport_stream.js +262 -278
- 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 +40 -37
- package/lib/pdf.js +226 -59
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +266 -416
- package/lib/test/unit/annotation_spec.js +1555 -701
- package/lib/test/unit/api_spec.js +802 -604
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +84 -69
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +74 -76
- package/lib/test/unit/colorspace_spec.js +166 -161
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +181 -181
- package/lib/test/unit/custom_spec.js +20 -22
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +16 -21
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +83 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +46 -30
- package/lib/test/unit/message_handler_spec.js +173 -159
- 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 +13 -61
- package/lib/test/unit/network_utils_spec.js +183 -119
- package/lib/test/unit/node_stream_spec.js +78 -92
- package/lib/test/unit/parser_spec.js +172 -114
- 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 +140 -125
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +131 -143
- package/lib/test/unit/testreporter.js +19 -19
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +297 -459
- package/lib/test/unit/unicode_spec.js +38 -38
- package/lib/test/unit/util_spec.js +121 -305
- package/lib/web/annotation_layer_builder.js +66 -103
- package/lib/web/app.js +1328 -1214
- package/lib/web/app_options.js +105 -107
- package/lib/web/base_viewer.js +824 -838
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +39 -55
- package/lib/web/firefox_print_service.js +37 -27
- package/lib/web/firefoxcom.js +212 -363
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +32 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +113 -131
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +221 -306
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +491 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +140 -175
- package/lib/web/pdf_page_view.js +452 -523
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +90 -104
- package/lib/web/pdf_rendering_queue.js +84 -108
- package/lib/web/pdf_sidebar.js +276 -306
- 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 +82 -286
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +282 -339
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +267 -420
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +35 -25
- package/web/pdf_viewer.js +3489 -4855
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -494
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/lib/test/unit/dom_utils_spec.js +0 -89
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.
|
@@ -24,422 +24,399 @@
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.
|
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
|
38
|
+
var _core_utils = require("./core_utils.js");
|
38
39
|
|
39
|
-
var
|
40
|
+
var _operator_list = require("./operator_list.js");
|
40
41
|
|
41
|
-
|
42
|
+
var _stream = require("./stream.js");
|
42
43
|
|
43
|
-
|
44
|
+
class AnnotationFactory {
|
45
|
+
static create(xref, ref, pdfManager, idFactory) {
|
46
|
+
return pdfManager.ensure(this, "_create", [xref, ref, pdfManager, idFactory]);
|
47
|
+
}
|
44
48
|
|
45
|
-
|
49
|
+
static _create(xref, ref, pdfManager, idFactory) {
|
50
|
+
const dict = xref.fetchIfRef(ref);
|
46
51
|
|
47
|
-
|
52
|
+
if (!(0, _primitives.isDict)(dict)) {
|
53
|
+
return undefined;
|
54
|
+
}
|
48
55
|
|
49
|
-
|
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
|
-
|
67
|
+
switch (subtype) {
|
68
|
+
case "Link":
|
69
|
+
return new LinkAnnotation(parameters);
|
52
70
|
|
53
|
-
|
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
|
-
|
81
|
+
switch (fieldType) {
|
82
|
+
case "Tx":
|
83
|
+
return new TextWidgetAnnotation(parameters);
|
56
84
|
|
57
|
-
|
85
|
+
case "Btn":
|
86
|
+
return new ButtonWidgetAnnotation(parameters);
|
58
87
|
|
59
|
-
|
88
|
+
case "Ch":
|
89
|
+
return new ChoiceWidgetAnnotation(parameters);
|
90
|
+
}
|
60
91
|
|
61
|
-
|
92
|
+
(0, _util.warn)('Unimplemented widget field type "' + fieldType + '", ' + "falling back to base field type.");
|
93
|
+
return new WidgetAnnotation(parameters);
|
62
94
|
|
63
|
-
|
64
|
-
|
65
|
-
function () {
|
66
|
-
function AnnotationFactory() {
|
67
|
-
_classCallCheck(this, AnnotationFactory);
|
68
|
-
}
|
95
|
+
case "Popup":
|
96
|
+
return new PopupAnnotation(parameters);
|
69
97
|
|
70
|
-
|
71
|
-
|
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
|
-
|
81
|
-
return;
|
82
|
-
}
|
101
|
+
case "Line":
|
102
|
+
return new LineAnnotation(parameters);
|
83
103
|
|
84
|
-
|
85
|
-
|
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
|
-
|
97
|
-
|
98
|
-
return new LinkAnnotation(parameters);
|
107
|
+
case "Circle":
|
108
|
+
return new CircleAnnotation(parameters);
|
99
109
|
|
100
|
-
|
101
|
-
|
110
|
+
case "PolyLine":
|
111
|
+
return new PolylineAnnotation(parameters);
|
102
112
|
|
103
|
-
|
104
|
-
|
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
|
-
|
111
|
-
|
112
|
-
return new TextWidgetAnnotation(parameters);
|
116
|
+
case "Caret":
|
117
|
+
return new CaretAnnotation(parameters);
|
113
118
|
|
114
|
-
|
115
|
-
|
119
|
+
case "Ink":
|
120
|
+
return new InkAnnotation(parameters);
|
116
121
|
|
117
|
-
|
118
|
-
|
119
|
-
}
|
122
|
+
case "Highlight":
|
123
|
+
return new HighlightAnnotation(parameters);
|
120
124
|
|
121
|
-
|
122
|
-
|
125
|
+
case "Underline":
|
126
|
+
return new UnderlineAnnotation(parameters);
|
123
127
|
|
124
|
-
|
125
|
-
|
128
|
+
case "Squiggly":
|
129
|
+
return new SquigglyAnnotation(parameters);
|
126
130
|
|
127
|
-
|
128
|
-
|
131
|
+
case "StrikeOut":
|
132
|
+
return new StrikeOutAnnotation(parameters);
|
129
133
|
|
130
|
-
|
131
|
-
|
134
|
+
case "Stamp":
|
135
|
+
return new StampAnnotation(parameters);
|
132
136
|
|
133
|
-
|
134
|
-
|
137
|
+
case "FileAttachment":
|
138
|
+
return new FileAttachmentAnnotation(parameters);
|
135
139
|
|
136
|
-
|
137
|
-
|
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
|
-
|
140
|
-
|
147
|
+
return new Annotation(parameters);
|
148
|
+
}
|
149
|
+
}
|
141
150
|
|
142
|
-
|
143
|
-
return new InkAnnotation(parameters);
|
151
|
+
}
|
144
152
|
|
145
|
-
|
146
|
-
return new HighlightAnnotation(parameters);
|
153
|
+
exports.AnnotationFactory = AnnotationFactory;
|
147
154
|
|
148
|
-
|
149
|
-
|
155
|
+
function getQuadPoints(dict, rect) {
|
156
|
+
if (!dict.has("QuadPoints")) {
|
157
|
+
return null;
|
158
|
+
}
|
150
159
|
|
151
|
-
|
152
|
-
return new SquigglyAnnotation(parameters);
|
160
|
+
const quadPoints = dict.getArray("QuadPoints");
|
153
161
|
|
154
|
-
|
155
|
-
|
162
|
+
if (!Array.isArray(quadPoints) || quadPoints.length % 8 > 0) {
|
163
|
+
return null;
|
164
|
+
}
|
156
165
|
|
157
|
-
|
158
|
-
return new StampAnnotation(parameters);
|
166
|
+
const quadPointsLists = [];
|
159
167
|
|
160
|
-
|
161
|
-
|
168
|
+
for (let i = 0, ii = quadPoints.length / 8; i < ii; i++) {
|
169
|
+
quadPointsLists.push([]);
|
162
170
|
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
175
|
+
if (x < rect[0] || x > rect[2] || y < rect[1] || y > rect[3]) {
|
176
|
+
return null;
|
171
177
|
}
|
172
|
-
}
|
173
|
-
}]);
|
174
178
|
|
175
|
-
|
176
|
-
|
179
|
+
quadPointsLists[i].push({
|
180
|
+
x,
|
181
|
+
y
|
182
|
+
});
|
183
|
+
}
|
184
|
+
}
|
177
185
|
|
178
|
-
|
186
|
+
return quadPointsLists;
|
187
|
+
}
|
179
188
|
|
180
189
|
function getTransformMatrix(rect, bbox, matrix) {
|
181
|
-
|
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
|
-
|
193
|
-
|
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
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
this.
|
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
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
}
|
231
|
-
|
232
|
-
|
233
|
-
|
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
|
-
|
260
|
-
|
261
|
-
return;
|
262
|
-
}
|
241
|
+
return this._isViewable(this.flags);
|
242
|
+
}
|
263
243
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
244
|
+
get printable() {
|
245
|
+
if (this.flags === 0) {
|
246
|
+
return false;
|
247
|
+
}
|
268
248
|
|
269
|
-
|
270
|
-
|
249
|
+
return this._isPrintable(this.flags);
|
250
|
+
}
|
271
251
|
|
272
|
-
|
273
|
-
|
252
|
+
setContents(contents) {
|
253
|
+
this.contents = (0, _util.stringToPDFString)(contents || "");
|
254
|
+
}
|
274
255
|
|
275
|
-
|
276
|
-
|
256
|
+
setModificationDate(modificationDate) {
|
257
|
+
this.modificationDate = (0, _util.isString)(modificationDate) ? modificationDate : null;
|
258
|
+
}
|
277
259
|
|
278
|
-
|
279
|
-
|
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
|
-
|
282
|
-
|
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
|
-
|
285
|
-
|
276
|
+
setColor(color) {
|
277
|
+
const rgbColor = new Uint8ClampedArray(3);
|
286
278
|
|
287
|
-
|
288
|
-
|
289
|
-
|
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
|
-
|
298
|
-
|
299
|
-
|
284
|
+
switch (color.length) {
|
285
|
+
case 0:
|
286
|
+
this.color = null;
|
287
|
+
break;
|
300
288
|
|
301
|
-
|
302
|
-
|
303
|
-
var dictType = dict.get('Type');
|
289
|
+
case 1:
|
290
|
+
_colorspace.ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
|
304
291
|
|
305
|
-
|
306
|
-
|
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
|
-
|
314
|
-
|
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
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
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
|
-
|
313
|
+
setBorderStyle(borderStyle) {
|
314
|
+
this.borderStyle = new AnnotationBorderStyle();
|
337
315
|
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
}
|
316
|
+
if (!(0, _primitives.isDict)(borderStyle)) {
|
317
|
+
return;
|
318
|
+
}
|
342
319
|
|
343
|
-
|
344
|
-
|
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
|
-
|
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
|
-
|
350
|
-
|
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
|
-
|
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
|
-
|
363
|
-
|
364
|
-
|
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
|
-
|
375
|
-
|
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
|
-
|
386
|
-
return Promise.resolve(new _operator_list.OperatorList());
|
387
|
-
}
|
365
|
+
const as = dict.get("AS");
|
388
366
|
|
389
|
-
|
390
|
-
|
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
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
if (
|
425
|
-
return
|
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
|
-
|
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
|
-
|
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
|
-
|
414
|
+
}
|
436
415
|
|
437
|
-
|
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
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
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
|
-
|
459
|
-
|
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
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
448
|
+
setStyle(style) {
|
449
|
+
if (!(0, _primitives.isName)(style)) {
|
450
|
+
return;
|
451
|
+
}
|
473
452
|
|
474
|
-
|
475
|
-
|
476
|
-
|
453
|
+
switch (style.name) {
|
454
|
+
case "S":
|
455
|
+
this.style = _util.AnnotationBorderStyleType.SOLID;
|
456
|
+
break;
|
477
457
|
|
478
|
-
|
479
|
-
|
480
|
-
|
458
|
+
case "D":
|
459
|
+
this.style = _util.AnnotationBorderStyleType.DASHED;
|
460
|
+
break;
|
481
461
|
|
482
|
-
|
483
|
-
|
484
|
-
|
462
|
+
case "B":
|
463
|
+
this.style = _util.AnnotationBorderStyleType.BEVELED;
|
464
|
+
break;
|
485
465
|
|
486
|
-
|
487
|
-
|
488
|
-
|
466
|
+
case "I":
|
467
|
+
this.style = _util.AnnotationBorderStyleType.INSET;
|
468
|
+
break;
|
489
469
|
|
490
|
-
|
491
|
-
|
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
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
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
|
-
}
|
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
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
}
|
503
|
+
}
|
504
|
+
|
505
|
+
setHorizontalCornerRadius(radius) {
|
506
|
+
if (Number.isInteger(radius)) {
|
507
|
+
this.horizontalCornerRadius = radius;
|
528
508
|
}
|
529
|
-
}
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
}
|
509
|
+
}
|
510
|
+
|
511
|
+
setVerticalCornerRadius(radius) {
|
512
|
+
if (Number.isInteger(radius)) {
|
513
|
+
this.verticalCornerRadius = radius;
|
535
514
|
}
|
536
|
-
}
|
515
|
+
}
|
537
516
|
|
538
|
-
|
539
|
-
}();
|
517
|
+
}
|
540
518
|
|
541
519
|
exports.AnnotationBorderStyle = AnnotationBorderStyle;
|
542
520
|
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
521
|
+
class MarkupAnnotation extends Annotation {
|
522
|
+
constructor(parameters) {
|
523
|
+
super(parameters);
|
524
|
+
const dict = parameters.dict;
|
547
525
|
|
548
|
-
|
549
|
-
|
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
|
-
|
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
|
-
|
554
|
-
|
555
|
-
|
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 =
|
558
|
-
data.fieldValue = (0,
|
559
|
-
dict
|
560
|
-
key:
|
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(
|
564
|
-
data.defaultAppearance = (0,
|
565
|
-
dict
|
566
|
-
key:
|
567
|
-
}) ||
|
568
|
-
|
569
|
-
dict
|
570
|
-
key:
|
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
|
-
|
574
|
-
dict
|
575
|
-
key:
|
603
|
+
this.fieldResources = (0, _core_utils.getInheritableProperty)({
|
604
|
+
dict,
|
605
|
+
key: "DR"
|
576
606
|
}) || _primitives.Dict.empty;
|
577
|
-
data.fieldFlags = (0,
|
578
|
-
dict
|
579
|
-
key:
|
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 =
|
616
|
+
data.readOnly = this.hasFieldFlag(_util.AnnotationFieldFlag.READONLY);
|
587
617
|
|
588
|
-
if (data.fieldType ===
|
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
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
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
|
-
|
630
|
+
if (!dict.has("Parent")) {
|
631
|
+
return (0, _util.stringToPDFString)(dict.get("T"));
|
632
|
+
}
|
610
633
|
|
611
|
-
|
612
|
-
fieldName.unshift((0, _util.stringToPDFString)(dict.get('T')));
|
613
|
-
}
|
634
|
+
const fieldName = [];
|
614
635
|
|
615
|
-
|
636
|
+
if (dict.has("T")) {
|
637
|
+
fieldName.unshift((0, _util.stringToPDFString)(dict.get("T")));
|
638
|
+
}
|
616
639
|
|
617
|
-
|
618
|
-
loopDict = loopDict.get('Parent');
|
640
|
+
let loopDict = dict;
|
619
641
|
|
620
|
-
|
621
|
-
|
622
|
-
}
|
642
|
+
while (loopDict.has("Parent")) {
|
643
|
+
loopDict = loopDict.get("Parent");
|
623
644
|
|
624
|
-
|
625
|
-
|
626
|
-
}
|
645
|
+
if (!(0, _primitives.isDict)(loopDict)) {
|
646
|
+
break;
|
627
647
|
}
|
628
648
|
|
629
|
-
|
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
|
-
|
648
|
-
}
|
654
|
+
return fieldName.join(".");
|
655
|
+
}
|
649
656
|
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
_inherits(TextWidgetAnnotation, _WidgetAnnotation);
|
657
|
+
hasFieldFlag(flag) {
|
658
|
+
return !!(this.data.fieldFlags & flag);
|
659
|
+
}
|
654
660
|
|
655
|
-
|
656
|
-
|
661
|
+
getOperatorList(evaluator, task, renderForms) {
|
662
|
+
if (renderForms) {
|
663
|
+
return Promise.resolve(new _operator_list.OperatorList());
|
664
|
+
}
|
657
665
|
|
658
|
-
|
666
|
+
return super.getOperatorList(evaluator, task, renderForms);
|
667
|
+
}
|
659
668
|
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
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
|
-
|
673
|
-
|
674
|
-
dict
|
675
|
-
key:
|
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
|
-
|
683
|
-
|
684
|
-
|
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
|
-
|
689
|
-
|
690
|
-
|
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
|
-
|
717
|
-
/*#__PURE__*/
|
718
|
-
function (_WidgetAnnotation2) {
|
719
|
-
_inherits(ButtonWidgetAnnotation, _WidgetAnnotation2);
|
705
|
+
const operatorList = new _operator_list.OperatorList();
|
720
706
|
|
721
|
-
|
722
|
-
|
707
|
+
if (!this.data.defaultAppearance) {
|
708
|
+
return Promise.resolve(operatorList);
|
709
|
+
}
|
723
710
|
|
724
|
-
|
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
|
-
|
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
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
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)(
|
738
|
+
(0, _util.warn)("Invalid field flags for button widget annotation");
|
739
739
|
}
|
740
|
-
|
741
|
-
return _this4;
|
742
740
|
}
|
743
741
|
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
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
|
-
|
754
|
-
return;
|
755
|
-
}
|
747
|
+
const customAppearance = params.dict.get("AP");
|
756
748
|
|
757
|
-
|
749
|
+
if (!(0, _primitives.isDict)(customAppearance)) {
|
750
|
+
return;
|
751
|
+
}
|
758
752
|
|
759
|
-
|
760
|
-
return;
|
761
|
-
}
|
753
|
+
const exportValueOptionsDict = customAppearance.get("D");
|
762
754
|
|
763
|
-
|
764
|
-
|
755
|
+
if (!(0, _primitives.isDict)(exportValueOptionsDict)) {
|
756
|
+
return;
|
757
|
+
}
|
765
758
|
|
766
|
-
|
767
|
-
|
768
|
-
}
|
759
|
+
const exportValues = exportValueOptionsDict.getKeys();
|
760
|
+
const hasCorrectOptionCount = exportValues.length === 2;
|
769
761
|
|
770
|
-
|
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
|
-
|
779
|
-
|
766
|
+
this.data.exportValue = exportValues[0] === "Off" ? exportValues[1] : exportValues[0];
|
767
|
+
}
|
780
768
|
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
}
|
769
|
+
_processRadioButton(params) {
|
770
|
+
this.data.fieldValue = this.data.buttonValue = null;
|
771
|
+
const fieldParent = params.dict.get("Parent");
|
785
772
|
|
786
|
-
|
773
|
+
if ((0, _primitives.isDict)(fieldParent) && fieldParent.has("V")) {
|
774
|
+
const fieldParentValue = fieldParent.get("V");
|
787
775
|
|
788
|
-
if (
|
789
|
-
|
776
|
+
if ((0, _primitives.isName)(fieldParentValue)) {
|
777
|
+
this.data.fieldValue = fieldParentValue.name;
|
790
778
|
}
|
779
|
+
}
|
791
780
|
|
792
|
-
|
781
|
+
const appearanceStates = params.dict.get("AP");
|
793
782
|
|
794
|
-
|
795
|
-
|
796
|
-
|
783
|
+
if (!(0, _primitives.isDict)(appearanceStates)) {
|
784
|
+
return;
|
785
|
+
}
|
797
786
|
|
798
|
-
|
787
|
+
const normalAppearanceState = appearanceStates.get("N");
|
799
788
|
|
800
|
-
|
801
|
-
|
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
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
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
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
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
|
-
|
832
|
-
|
807
|
+
_obj.Catalog.parseDestDictionary({
|
808
|
+
destDict: params.dict,
|
809
|
+
resultObj: this.data,
|
810
|
+
docBaseUrl: params.pdfManager.docBaseUrl
|
811
|
+
});
|
812
|
+
}
|
833
813
|
|
834
|
-
|
814
|
+
}
|
835
815
|
|
836
|
-
|
837
|
-
|
838
|
-
|
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:
|
822
|
+
key: "Opt"
|
841
823
|
});
|
842
824
|
|
843
825
|
if (Array.isArray(options)) {
|
844
|
-
|
826
|
+
const xref = params.xref;
|
845
827
|
|
846
|
-
for (
|
847
|
-
|
848
|
-
|
849
|
-
|
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(
|
857
|
-
|
838
|
+
if (!Array.isArray(this.data.fieldValue)) {
|
839
|
+
this.data.fieldValue = [this.data.fieldValue];
|
858
840
|
}
|
859
841
|
|
860
|
-
|
861
|
-
|
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
|
-
|
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
|
-
|
879
|
-
|
880
|
-
|
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 (
|
883
|
-
|
855
|
+
if (this.data.hasAppearance) {
|
856
|
+
this.data.name = "NoIcon";
|
884
857
|
} else {
|
885
|
-
|
886
|
-
|
887
|
-
|
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
|
-
|
891
|
-
|
892
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
909
|
-
|
880
|
+
if (quadPoints) {
|
881
|
+
this.data.quadPoints = quadPoints;
|
882
|
+
}
|
910
883
|
|
911
884
|
_obj.Catalog.parseDestDictionary({
|
912
885
|
destDict: params.dict,
|
913
|
-
resultObj:
|
886
|
+
resultObj: this.data,
|
914
887
|
docBaseUrl: params.pdfManager.docBaseUrl
|
915
888
|
});
|
916
|
-
|
917
|
-
return _this7;
|
918
889
|
}
|
919
890
|
|
920
|
-
|
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
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
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)(
|
940
|
-
return
|
900
|
+
(0, _util.warn)("Popup annotation has a missing or invalid parent annotation.");
|
901
|
+
return;
|
941
902
|
}
|
942
903
|
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
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(
|
950
|
-
|
914
|
+
if (!parentItem.has("M")) {
|
915
|
+
this.data.modificationDate = null;
|
951
916
|
} else {
|
952
|
-
|
917
|
+
this.setModificationDate(parentItem.get("M"));
|
918
|
+
this.data.modificationDate = this.modificationDate;
|
919
|
+
}
|
953
920
|
|
954
|
-
|
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 (!
|
958
|
-
|
928
|
+
if (!this.viewable) {
|
929
|
+
const parentFlags = parentItem.get("F");
|
959
930
|
|
960
|
-
if (
|
961
|
-
|
931
|
+
if (this._isViewable(parentFlags)) {
|
932
|
+
this.setFlags(parentFlags);
|
962
933
|
}
|
963
934
|
}
|
964
935
|
|
965
|
-
|
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
|
-
|
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
|
-
|
942
|
+
class FreeTextAnnotation extends MarkupAnnotation {
|
943
|
+
constructor(parameters) {
|
944
|
+
super(parameters);
|
945
|
+
this.data.annotationType = _util.AnnotationType.FREETEXT;
|
989
946
|
}
|
990
947
|
|
991
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
959
|
+
class SquareAnnotation extends MarkupAnnotation {
|
960
|
+
constructor(parameters) {
|
961
|
+
super(parameters);
|
962
|
+
this.data.annotationType = _util.AnnotationType.SQUARE;
|
1031
963
|
}
|
1032
964
|
|
1033
|
-
|
1034
|
-
}(Annotation);
|
1035
|
-
|
1036
|
-
var PolylineAnnotation =
|
1037
|
-
/*#__PURE__*/
|
1038
|
-
function (_Annotation8) {
|
1039
|
-
_inherits(PolylineAnnotation, _Annotation8);
|
965
|
+
}
|
1040
966
|
|
1041
|
-
|
1042
|
-
|
967
|
+
class CircleAnnotation extends MarkupAnnotation {
|
968
|
+
constructor(parameters) {
|
969
|
+
super(parameters);
|
970
|
+
this.data.annotationType = _util.AnnotationType.CIRCLE;
|
971
|
+
}
|
1043
972
|
|
1044
|
-
|
973
|
+
}
|
1045
974
|
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
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 (
|
1053
|
-
|
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
|
-
|
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
|
-
|
1078
|
-
|
1079
|
-
|
992
|
+
class PolygonAnnotation extends PolylineAnnotation {
|
993
|
+
constructor(parameters) {
|
994
|
+
super(parameters);
|
995
|
+
this.data.annotationType = _util.AnnotationType.POLYGON;
|
1080
996
|
}
|
1081
997
|
|
1082
|
-
|
1083
|
-
}(PolylineAnnotation);
|
1084
|
-
|
1085
|
-
var InkAnnotation =
|
1086
|
-
/*#__PURE__*/
|
1087
|
-
function (_Annotation9) {
|
1088
|
-
_inherits(InkAnnotation, _Annotation9);
|
998
|
+
}
|
1089
999
|
|
1090
|
-
|
1091
|
-
|
1000
|
+
class CaretAnnotation extends MarkupAnnotation {
|
1001
|
+
constructor(parameters) {
|
1002
|
+
super(parameters);
|
1003
|
+
this.data.annotationType = _util.AnnotationType.CARET;
|
1004
|
+
}
|
1092
1005
|
|
1093
|
-
|
1006
|
+
}
|
1094
1007
|
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
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 (
|
1103
|
-
|
1016
|
+
for (let i = 0, ii = originalInkLists.length; i < ii; ++i) {
|
1017
|
+
this.data.inkLists.push([]);
|
1104
1018
|
|
1105
|
-
for (
|
1106
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
1036
|
+
if (quadPoints) {
|
1037
|
+
this.data.quadPoints = quadPoints;
|
1038
|
+
}
|
1137
1039
|
}
|
1138
1040
|
|
1139
|
-
|
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
|
-
|
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
|
-
|
1049
|
+
if (quadPoints) {
|
1050
|
+
this.data.quadPoints = quadPoints;
|
1051
|
+
}
|
1158
1052
|
}
|
1159
1053
|
|
1160
|
-
|
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
|
-
|
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
|
-
|
1062
|
+
if (quadPoints) {
|
1063
|
+
this.data.quadPoints = quadPoints;
|
1064
|
+
}
|
1179
1065
|
}
|
1180
1066
|
|
1181
|
-
|
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
|
-
|
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
|
-
|
1075
|
+
if (quadPoints) {
|
1076
|
+
this.data.quadPoints = quadPoints;
|
1077
|
+
}
|
1200
1078
|
}
|
1201
1079
|
|
1202
|
-
|
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
|
-
|
1082
|
+
class StampAnnotation extends MarkupAnnotation {
|
1083
|
+
constructor(parameters) {
|
1084
|
+
super(parameters);
|
1085
|
+
this.data.annotationType = _util.AnnotationType.STAMP;
|
1221
1086
|
}
|
1222
1087
|
|
1223
|
-
|
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
|
-
|
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
|
-
|
1247
|
-
}(Annotation);
|
1098
|
+
}
|