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