pdfjs-dist 2.2.228 → 2.6.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- 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 +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -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/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- 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 +1144 -927
- 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 +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- 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 +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- 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 +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- 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 +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -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 +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- 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 +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
@@ -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.
|
@@ -21,125 +21,210 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _annotation = require("../../core/annotation");
|
24
|
+
var _annotation = require("../../core/annotation.js");
|
25
25
|
|
26
|
-
var _util = require("../../shared/util");
|
26
|
+
var _util = require("../../shared/util.js");
|
27
27
|
|
28
|
-
var _test_utils = require("./test_utils");
|
28
|
+
var _test_utils = require("./test_utils.js");
|
29
29
|
|
30
|
-
var _primitives = require("../../core/primitives");
|
30
|
+
var _primitives = require("../../core/primitives.js");
|
31
31
|
|
32
|
-
var _parser = require("../../core/parser");
|
32
|
+
var _parser = require("../../core/parser.js");
|
33
33
|
|
34
|
-
var
|
34
|
+
var _evaluator = require("../../core/evaluator.js");
|
35
35
|
|
36
|
-
|
36
|
+
var _stream = require("../../core/stream.js");
|
37
37
|
|
38
|
-
|
38
|
+
var _worker = require("../../core/worker.js");
|
39
39
|
|
40
|
-
|
40
|
+
describe("annotation", function () {
|
41
|
+
class PDFManagerMock {
|
42
|
+
constructor(params) {
|
43
|
+
this.docBaseUrl = params.docBaseUrl || null;
|
44
|
+
this.pdfDocument = {
|
45
|
+
catalog: {
|
46
|
+
acroForm: new _primitives.Dict()
|
47
|
+
}
|
48
|
+
};
|
49
|
+
}
|
41
50
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
function () {
|
46
|
-
function PDFManagerMock(params) {
|
47
|
-
_classCallCheck(this, PDFManagerMock);
|
51
|
+
ensure(obj, prop, args) {
|
52
|
+
return new Promise(function (resolve) {
|
53
|
+
const value = obj[prop];
|
48
54
|
|
49
|
-
|
55
|
+
if (typeof value === "function") {
|
56
|
+
resolve(value.apply(obj, args));
|
57
|
+
} else {
|
58
|
+
resolve(value);
|
59
|
+
}
|
60
|
+
});
|
50
61
|
}
|
51
62
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
resolve(value);
|
62
|
-
}
|
63
|
-
});
|
64
|
-
}
|
65
|
-
}]);
|
63
|
+
ensureCatalog(prop, args) {
|
64
|
+
return this.ensure(this.pdfDocument.catalog, prop, args);
|
65
|
+
}
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
function HandlerMock() {
|
70
|
+
this.inputs = [];
|
71
|
+
}
|
66
72
|
|
67
|
-
|
68
|
-
|
73
|
+
HandlerMock.prototype = {
|
74
|
+
send(name, data) {
|
75
|
+
this.inputs.push({
|
76
|
+
name,
|
77
|
+
data
|
78
|
+
});
|
79
|
+
}
|
69
80
|
|
70
|
-
|
81
|
+
};
|
82
|
+
let pdfManagerMock, idFactoryMock, partialEvaluator;
|
71
83
|
beforeAll(function (done) {
|
72
84
|
pdfManagerMock = new PDFManagerMock({
|
73
85
|
docBaseUrl: null
|
74
86
|
});
|
75
87
|
idFactoryMock = (0, _test_utils.createIdFactory)(0);
|
88
|
+
partialEvaluator = new _evaluator.PartialEvaluator({
|
89
|
+
xref: new _test_utils.XRefMock(),
|
90
|
+
handler: new HandlerMock(),
|
91
|
+
pageIndex: 0,
|
92
|
+
idFactory: (0, _test_utils.createIdFactory)(0),
|
93
|
+
fontCache: new _primitives.RefSetCache()
|
94
|
+
});
|
76
95
|
done();
|
77
96
|
});
|
78
97
|
afterAll(function () {
|
79
98
|
pdfManagerMock = null;
|
80
99
|
idFactoryMock = null;
|
100
|
+
partialEvaluator = null;
|
81
101
|
});
|
82
|
-
describe(
|
83
|
-
it(
|
84
|
-
|
85
|
-
annotationDict.set(
|
86
|
-
annotationDict.set(
|
102
|
+
describe("AnnotationFactory", function () {
|
103
|
+
it("should get id for annotation", function (done) {
|
104
|
+
const annotationDict = new _primitives.Dict();
|
105
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
106
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
87
107
|
|
88
|
-
|
108
|
+
const annotationRef = _primitives.Ref.get(10, 0);
|
89
109
|
|
90
|
-
|
110
|
+
const xref = new _test_utils.XRefMock([{
|
91
111
|
ref: annotationRef,
|
92
112
|
data: annotationDict
|
93
113
|
}]);
|
94
114
|
|
95
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
96
|
-
|
115
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
116
|
+
data
|
117
|
+
}) => {
|
97
118
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
98
|
-
expect(data.id).toEqual(
|
119
|
+
expect(data.id).toEqual("10R");
|
99
120
|
done();
|
100
121
|
}, done.fail);
|
101
122
|
});
|
102
|
-
it(
|
103
|
-
|
104
|
-
annotationDict.set(
|
105
|
-
annotationDict.set(
|
106
|
-
|
107
|
-
|
123
|
+
it("should handle, and get fallback IDs for, annotations that are not " + "indirect objects (issue 7569)", function (done) {
|
124
|
+
const annotationDict = new _primitives.Dict();
|
125
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
126
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
127
|
+
const xref = new _test_utils.XRefMock();
|
128
|
+
const idFactory = (0, _test_utils.createIdFactory)(0);
|
108
129
|
|
109
|
-
|
110
|
-
|
130
|
+
const annotation1 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(({
|
131
|
+
data
|
132
|
+
}) => {
|
111
133
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
112
|
-
expect(data.id).toEqual(
|
134
|
+
expect(data.id).toEqual("annot_p0_1");
|
113
135
|
});
|
114
136
|
|
115
|
-
|
116
|
-
|
137
|
+
const annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(({
|
138
|
+
data
|
139
|
+
}) => {
|
117
140
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
118
|
-
expect(data.id).toEqual(
|
141
|
+
expect(data.id).toEqual("annot_p0_2");
|
119
142
|
});
|
120
143
|
|
121
144
|
Promise.all([annotation1, annotation2]).then(done, done.fail);
|
122
145
|
});
|
123
|
-
it(
|
124
|
-
|
125
|
-
annotationDict.set(
|
146
|
+
it("should handle missing /Subtype", function (done) {
|
147
|
+
const annotationDict = new _primitives.Dict();
|
148
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
126
149
|
|
127
|
-
|
150
|
+
const annotationRef = _primitives.Ref.get(1, 0);
|
128
151
|
|
129
|
-
|
152
|
+
const xref = new _test_utils.XRefMock([{
|
130
153
|
ref: annotationRef,
|
131
154
|
data: annotationDict
|
132
155
|
}]);
|
133
156
|
|
134
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
135
|
-
|
157
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
158
|
+
data
|
159
|
+
}) => {
|
136
160
|
expect(data.annotationType).toBeUndefined();
|
137
161
|
done();
|
138
162
|
}, done.fail);
|
139
163
|
});
|
140
164
|
});
|
141
|
-
describe(
|
142
|
-
|
165
|
+
describe("getQuadPoints", function () {
|
166
|
+
let dict, rect;
|
167
|
+
beforeEach(function (done) {
|
168
|
+
dict = new _primitives.Dict();
|
169
|
+
rect = [];
|
170
|
+
done();
|
171
|
+
});
|
172
|
+
afterEach(function () {
|
173
|
+
dict = null;
|
174
|
+
rect = null;
|
175
|
+
});
|
176
|
+
it("should ignore missing quadpoints", function () {
|
177
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
178
|
+
});
|
179
|
+
it("should ignore non-array values", function () {
|
180
|
+
dict.set("QuadPoints", "foo");
|
181
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
182
|
+
});
|
183
|
+
it("should ignore arrays where the length is not a multiple of eight", function () {
|
184
|
+
dict.set("QuadPoints", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
185
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
186
|
+
});
|
187
|
+
it("should ignore quadpoints if one coordinate lies outside the rectangle", function () {
|
188
|
+
rect = [10, 10, 20, 20];
|
189
|
+
const inputs = [[11, 11, 12, 12, 9, 13, 14, 14], [11, 11, 12, 12, 13, 9, 14, 14], [11, 11, 12, 12, 21, 13, 14, 14], [11, 11, 12, 12, 13, 21, 14, 14]];
|
190
|
+
|
191
|
+
for (const input of inputs) {
|
192
|
+
dict.set("QuadPoints", input);
|
193
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
194
|
+
}
|
195
|
+
});
|
196
|
+
it("should process valid quadpoints arrays", function () {
|
197
|
+
rect = [10, 10, 20, 20];
|
198
|
+
dict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]);
|
199
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual([[{
|
200
|
+
x: 11,
|
201
|
+
y: 11
|
202
|
+
}, {
|
203
|
+
x: 12,
|
204
|
+
y: 12
|
205
|
+
}, {
|
206
|
+
x: 13,
|
207
|
+
y: 13
|
208
|
+
}, {
|
209
|
+
x: 14,
|
210
|
+
y: 14
|
211
|
+
}], [{
|
212
|
+
x: 15,
|
213
|
+
y: 15
|
214
|
+
}, {
|
215
|
+
x: 16,
|
216
|
+
y: 16
|
217
|
+
}, {
|
218
|
+
x: 17,
|
219
|
+
y: 17
|
220
|
+
}, {
|
221
|
+
x: 18,
|
222
|
+
y: 18
|
223
|
+
}]]);
|
224
|
+
});
|
225
|
+
});
|
226
|
+
describe("Annotation", function () {
|
227
|
+
let dict, ref;
|
143
228
|
beforeAll(function (done) {
|
144
229
|
dict = new _primitives.Dict();
|
145
230
|
ref = _primitives.Ref.get(1, 0);
|
@@ -148,42 +233,42 @@ describe('annotation', function () {
|
|
148
233
|
afterAll(function () {
|
149
234
|
dict = ref = null;
|
150
235
|
});
|
151
|
-
it(
|
152
|
-
|
153
|
-
dict
|
154
|
-
ref
|
236
|
+
it("should set and get valid contents", function () {
|
237
|
+
const annotation = new _annotation.Annotation({
|
238
|
+
dict,
|
239
|
+
ref
|
155
240
|
});
|
156
|
-
annotation.setContents(
|
157
|
-
expect(annotation.contents).toEqual(
|
241
|
+
annotation.setContents("Foo bar baz");
|
242
|
+
expect(annotation.contents).toEqual("Foo bar baz");
|
158
243
|
});
|
159
|
-
it(
|
160
|
-
|
161
|
-
dict
|
162
|
-
ref
|
244
|
+
it("should not set and get invalid contents", function () {
|
245
|
+
const annotation = new _annotation.Annotation({
|
246
|
+
dict,
|
247
|
+
ref
|
163
248
|
});
|
164
249
|
annotation.setContents(undefined);
|
165
|
-
expect(annotation.contents).toEqual(
|
250
|
+
expect(annotation.contents).toEqual("");
|
166
251
|
});
|
167
|
-
it(
|
168
|
-
|
169
|
-
dict
|
170
|
-
ref
|
252
|
+
it("should set and get a valid modification date", function () {
|
253
|
+
const annotation = new _annotation.Annotation({
|
254
|
+
dict,
|
255
|
+
ref
|
171
256
|
});
|
172
|
-
annotation.setModificationDate(
|
173
|
-
expect(annotation.modificationDate).toEqual(
|
257
|
+
annotation.setModificationDate("D:20190422");
|
258
|
+
expect(annotation.modificationDate).toEqual("D:20190422");
|
174
259
|
});
|
175
|
-
it(
|
176
|
-
|
177
|
-
dict
|
178
|
-
ref
|
260
|
+
it("should not set and get an invalid modification date", function () {
|
261
|
+
const annotation = new _annotation.Annotation({
|
262
|
+
dict,
|
263
|
+
ref
|
179
264
|
});
|
180
265
|
annotation.setModificationDate(undefined);
|
181
266
|
expect(annotation.modificationDate).toEqual(null);
|
182
267
|
});
|
183
|
-
it(
|
184
|
-
|
185
|
-
dict
|
186
|
-
ref
|
268
|
+
it("should set and get flags", function () {
|
269
|
+
const annotation = new _annotation.Annotation({
|
270
|
+
dict,
|
271
|
+
ref
|
187
272
|
});
|
188
273
|
annotation.setFlags(13);
|
189
274
|
expect(annotation.hasFlag(_util.AnnotationFlag.INVISIBLE)).toEqual(true);
|
@@ -191,141 +276,141 @@ describe('annotation', function () {
|
|
191
276
|
expect(annotation.hasFlag(_util.AnnotationFlag.PRINT)).toEqual(true);
|
192
277
|
expect(annotation.hasFlag(_util.AnnotationFlag.READONLY)).toEqual(false);
|
193
278
|
});
|
194
|
-
it(
|
195
|
-
|
196
|
-
dict
|
197
|
-
ref
|
279
|
+
it("should be viewable and not printable by default", function () {
|
280
|
+
const annotation = new _annotation.Annotation({
|
281
|
+
dict,
|
282
|
+
ref
|
198
283
|
});
|
199
284
|
expect(annotation.viewable).toEqual(true);
|
200
285
|
expect(annotation.printable).toEqual(false);
|
201
286
|
});
|
202
|
-
it(
|
203
|
-
|
204
|
-
dict
|
205
|
-
ref
|
287
|
+
it("should set and get a valid rectangle", function () {
|
288
|
+
const annotation = new _annotation.Annotation({
|
289
|
+
dict,
|
290
|
+
ref
|
206
291
|
});
|
207
292
|
annotation.setRectangle([117, 694, 164.298, 720]);
|
208
293
|
expect(annotation.rectangle).toEqual([117, 694, 164.298, 720]);
|
209
294
|
});
|
210
|
-
it(
|
211
|
-
|
212
|
-
dict
|
213
|
-
ref
|
295
|
+
it("should not set and get an invalid rectangle", function () {
|
296
|
+
const annotation = new _annotation.Annotation({
|
297
|
+
dict,
|
298
|
+
ref
|
214
299
|
});
|
215
300
|
annotation.setRectangle([117, 694, 164.298]);
|
216
301
|
expect(annotation.rectangle).toEqual([0, 0, 0, 0]);
|
217
302
|
});
|
218
|
-
it(
|
219
|
-
|
220
|
-
dict
|
221
|
-
ref
|
303
|
+
it("should reject a color if it is not an array", function () {
|
304
|
+
const annotation = new _annotation.Annotation({
|
305
|
+
dict,
|
306
|
+
ref
|
222
307
|
});
|
223
|
-
annotation.setColor(
|
308
|
+
annotation.setColor("red");
|
224
309
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
225
310
|
});
|
226
|
-
it(
|
227
|
-
|
228
|
-
dict
|
229
|
-
ref
|
311
|
+
it("should set and get a transparent color", function () {
|
312
|
+
const annotation = new _annotation.Annotation({
|
313
|
+
dict,
|
314
|
+
ref
|
230
315
|
});
|
231
316
|
annotation.setColor([]);
|
232
317
|
expect(annotation.color).toEqual(null);
|
233
318
|
});
|
234
|
-
it(
|
235
|
-
|
236
|
-
dict
|
237
|
-
ref
|
319
|
+
it("should set and get a grayscale color", function () {
|
320
|
+
const annotation = new _annotation.Annotation({
|
321
|
+
dict,
|
322
|
+
ref
|
238
323
|
});
|
239
324
|
annotation.setColor([0.4]);
|
240
325
|
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
241
326
|
});
|
242
|
-
it(
|
243
|
-
|
244
|
-
dict
|
245
|
-
ref
|
327
|
+
it("should set and get an RGB color", function () {
|
328
|
+
const annotation = new _annotation.Annotation({
|
329
|
+
dict,
|
330
|
+
ref
|
246
331
|
});
|
247
332
|
annotation.setColor([0, 0, 1]);
|
248
333
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
249
334
|
});
|
250
|
-
it(
|
251
|
-
|
252
|
-
dict
|
253
|
-
ref
|
335
|
+
it("should set and get a CMYK color", function () {
|
336
|
+
const annotation = new _annotation.Annotation({
|
337
|
+
dict,
|
338
|
+
ref
|
254
339
|
});
|
255
340
|
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
256
341
|
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
257
342
|
});
|
258
|
-
it(
|
259
|
-
|
260
|
-
dict
|
261
|
-
ref
|
343
|
+
it("should not set and get an invalid color", function () {
|
344
|
+
const annotation = new _annotation.Annotation({
|
345
|
+
dict,
|
346
|
+
ref
|
262
347
|
});
|
263
348
|
annotation.setColor([0.4, 0.6]);
|
264
349
|
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
265
350
|
});
|
266
351
|
});
|
267
|
-
describe(
|
268
|
-
it(
|
269
|
-
|
352
|
+
describe("AnnotationBorderStyle", function () {
|
353
|
+
it("should set and get a valid width", function () {
|
354
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
270
355
|
borderStyle.setWidth(3);
|
271
356
|
expect(borderStyle.width).toEqual(3);
|
272
357
|
});
|
273
|
-
it(
|
274
|
-
|
275
|
-
borderStyle.setWidth(
|
358
|
+
it("should not set and get an invalid width", function () {
|
359
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
360
|
+
borderStyle.setWidth("three");
|
276
361
|
expect(borderStyle.width).toEqual(1);
|
277
362
|
});
|
278
|
-
it(
|
279
|
-
|
280
|
-
borderStyleZero.setWidth(_primitives.Name.get(
|
281
|
-
|
282
|
-
borderStyleFive.setWidth(_primitives.Name.get(
|
363
|
+
it("should set the width to zero, when the input is a `Name` (issue 10385)", function () {
|
364
|
+
const borderStyleZero = new _annotation.AnnotationBorderStyle();
|
365
|
+
borderStyleZero.setWidth(_primitives.Name.get("0"));
|
366
|
+
const borderStyleFive = new _annotation.AnnotationBorderStyle();
|
367
|
+
borderStyleFive.setWidth(_primitives.Name.get("5"));
|
283
368
|
expect(borderStyleZero.width).toEqual(0);
|
284
369
|
expect(borderStyleFive.width).toEqual(0);
|
285
370
|
});
|
286
|
-
it(
|
287
|
-
|
288
|
-
borderStyle.setStyle(_primitives.Name.get(
|
371
|
+
it("should set and get a valid style", function () {
|
372
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
373
|
+
borderStyle.setStyle(_primitives.Name.get("D"));
|
289
374
|
expect(borderStyle.style).toEqual(_util.AnnotationBorderStyleType.DASHED);
|
290
375
|
});
|
291
|
-
it(
|
292
|
-
|
293
|
-
borderStyle.setStyle(
|
376
|
+
it("should not set and get an invalid style", function () {
|
377
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
378
|
+
borderStyle.setStyle("Dashed");
|
294
379
|
expect(borderStyle.style).toEqual(_util.AnnotationBorderStyleType.SOLID);
|
295
380
|
});
|
296
|
-
it(
|
297
|
-
|
381
|
+
it("should set and get a valid dash array", function () {
|
382
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
298
383
|
borderStyle.setDashArray([1, 2, 3]);
|
299
384
|
expect(borderStyle.dashArray).toEqual([1, 2, 3]);
|
300
385
|
});
|
301
|
-
it(
|
302
|
-
|
386
|
+
it("should not set and get an invalid dash array", function () {
|
387
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
303
388
|
borderStyle.setDashArray([0, 0]);
|
304
389
|
expect(borderStyle.dashArray).toEqual([3]);
|
305
390
|
});
|
306
|
-
it(
|
307
|
-
|
391
|
+
it("should set and get a valid horizontal corner radius", function () {
|
392
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
308
393
|
borderStyle.setHorizontalCornerRadius(3);
|
309
394
|
expect(borderStyle.horizontalCornerRadius).toEqual(3);
|
310
395
|
});
|
311
|
-
it(
|
312
|
-
|
313
|
-
borderStyle.setHorizontalCornerRadius(
|
396
|
+
it("should not set and get an invalid horizontal corner radius", function () {
|
397
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
398
|
+
borderStyle.setHorizontalCornerRadius("three");
|
314
399
|
expect(borderStyle.horizontalCornerRadius).toEqual(0);
|
315
400
|
});
|
316
|
-
it(
|
317
|
-
|
401
|
+
it("should set and get a valid vertical corner radius", function () {
|
402
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
318
403
|
borderStyle.setVerticalCornerRadius(3);
|
319
404
|
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
320
405
|
});
|
321
|
-
it(
|
322
|
-
|
323
|
-
borderStyle.setVerticalCornerRadius(
|
406
|
+
it("should not set and get an invalid vertical corner radius", function () {
|
407
|
+
const borderStyle = new _annotation.AnnotationBorderStyle();
|
408
|
+
borderStyle.setVerticalCornerRadius("three");
|
324
409
|
expect(borderStyle.verticalCornerRadius).toEqual(0);
|
325
410
|
});
|
326
411
|
});
|
327
|
-
describe(
|
328
|
-
|
412
|
+
describe("MarkupAnnotation", function () {
|
413
|
+
let dict, ref;
|
329
414
|
beforeAll(function (done) {
|
330
415
|
dict = new _primitives.Dict();
|
331
416
|
ref = _primitives.Ref.get(1, 0);
|
@@ -334,303 +419,550 @@ describe('annotation', function () {
|
|
334
419
|
afterAll(function () {
|
335
420
|
dict = ref = null;
|
336
421
|
});
|
337
|
-
it(
|
338
|
-
|
339
|
-
dict
|
340
|
-
ref
|
422
|
+
it("should set and get a valid creation date", function () {
|
423
|
+
const markupAnnotation = new _annotation.MarkupAnnotation({
|
424
|
+
dict,
|
425
|
+
ref
|
341
426
|
});
|
342
|
-
markupAnnotation.setCreationDate(
|
343
|
-
expect(markupAnnotation.creationDate).toEqual(
|
427
|
+
markupAnnotation.setCreationDate("D:20190422");
|
428
|
+
expect(markupAnnotation.creationDate).toEqual("D:20190422");
|
344
429
|
});
|
345
|
-
it(
|
346
|
-
|
347
|
-
dict
|
348
|
-
ref
|
430
|
+
it("should not set and get an invalid creation date", function () {
|
431
|
+
const markupAnnotation = new _annotation.MarkupAnnotation({
|
432
|
+
dict,
|
433
|
+
ref
|
349
434
|
});
|
350
435
|
markupAnnotation.setCreationDate(undefined);
|
351
436
|
expect(markupAnnotation.creationDate).toEqual(null);
|
352
437
|
});
|
438
|
+
it("should not parse IRT/RT when not defined", function (done) {
|
439
|
+
dict.set("Type", _primitives.Name.get("Annot"));
|
440
|
+
dict.set("Subtype", _primitives.Name.get("Text"));
|
441
|
+
const xref = new _test_utils.XRefMock([{
|
442
|
+
ref,
|
443
|
+
data: dict
|
444
|
+
}]);
|
445
|
+
|
446
|
+
_annotation.AnnotationFactory.create(xref, ref, pdfManagerMock, idFactoryMock).then(({
|
447
|
+
data
|
448
|
+
}) => {
|
449
|
+
expect(data.inReplyTo).toBeUndefined();
|
450
|
+
expect(data.replyType).toBeUndefined();
|
451
|
+
done();
|
452
|
+
}, done.fail);
|
453
|
+
});
|
454
|
+
it("should parse IRT and set default RT when not defined.", function (done) {
|
455
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
456
|
+
|
457
|
+
const annotationDict = new _primitives.Dict();
|
458
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
459
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
460
|
+
|
461
|
+
const replyRef = _primitives.Ref.get(820, 0);
|
462
|
+
|
463
|
+
const replyDict = new _primitives.Dict();
|
464
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
465
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
466
|
+
replyDict.set("IRT", annotationRef);
|
467
|
+
const xref = new _test_utils.XRefMock([{
|
468
|
+
ref: annotationRef,
|
469
|
+
data: annotationDict
|
470
|
+
}, {
|
471
|
+
ref: replyRef,
|
472
|
+
data: replyDict
|
473
|
+
}]);
|
474
|
+
annotationDict.assignXref(xref);
|
475
|
+
replyDict.assignXref(xref);
|
476
|
+
|
477
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
|
478
|
+
data
|
479
|
+
}) => {
|
480
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
481
|
+
expect(data.replyType).toEqual("R");
|
482
|
+
done();
|
483
|
+
}, done.fail);
|
484
|
+
});
|
485
|
+
it("should parse IRT/RT for a group type", function (done) {
|
486
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
487
|
+
|
488
|
+
const annotationDict = new _primitives.Dict();
|
489
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
490
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
491
|
+
annotationDict.set("T", "ParentTitle");
|
492
|
+
annotationDict.set("Contents", "ParentText");
|
493
|
+
annotationDict.set("CreationDate", "D:20180423");
|
494
|
+
annotationDict.set("M", "D:20190423");
|
495
|
+
annotationDict.set("C", [0, 0, 1]);
|
496
|
+
|
497
|
+
const popupRef = _primitives.Ref.get(820, 0);
|
498
|
+
|
499
|
+
const popupDict = new _primitives.Dict();
|
500
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
501
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
502
|
+
popupDict.set("Parent", annotationRef);
|
503
|
+
annotationDict.set("Popup", popupRef);
|
504
|
+
|
505
|
+
const replyRef = _primitives.Ref.get(821, 0);
|
506
|
+
|
507
|
+
const replyDict = new _primitives.Dict();
|
508
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
509
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
510
|
+
replyDict.set("IRT", annotationRef);
|
511
|
+
replyDict.set("RT", _primitives.Name.get("Group"));
|
512
|
+
replyDict.set("T", "ReplyTitle");
|
513
|
+
replyDict.set("Contents", "ReplyText");
|
514
|
+
replyDict.set("CreationDate", "D:20180523");
|
515
|
+
replyDict.set("M", "D:20190523");
|
516
|
+
replyDict.set("C", [0.4]);
|
517
|
+
const xref = new _test_utils.XRefMock([{
|
518
|
+
ref: annotationRef,
|
519
|
+
data: annotationDict
|
520
|
+
}, {
|
521
|
+
ref: popupRef,
|
522
|
+
data: popupDict
|
523
|
+
}, {
|
524
|
+
ref: replyRef,
|
525
|
+
data: replyDict
|
526
|
+
}]);
|
527
|
+
annotationDict.assignXref(xref);
|
528
|
+
popupDict.assignXref(xref);
|
529
|
+
replyDict.assignXref(xref);
|
530
|
+
|
531
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
|
532
|
+
data
|
533
|
+
}) => {
|
534
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
535
|
+
expect(data.replyType).toEqual("Group");
|
536
|
+
expect(data.title).toEqual("ParentTitle");
|
537
|
+
expect(data.contents).toEqual("ParentText");
|
538
|
+
expect(data.creationDate).toEqual("D:20180423");
|
539
|
+
expect(data.modificationDate).toEqual("D:20190423");
|
540
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
541
|
+
expect(data.hasPopup).toEqual(true);
|
542
|
+
done();
|
543
|
+
}, done.fail);
|
544
|
+
});
|
545
|
+
it("should parse IRT/RT for a reply type", function (done) {
|
546
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
547
|
+
|
548
|
+
const annotationDict = new _primitives.Dict();
|
549
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
550
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
551
|
+
annotationDict.set("T", "ParentTitle");
|
552
|
+
annotationDict.set("Contents", "ParentText");
|
553
|
+
annotationDict.set("CreationDate", "D:20180423");
|
554
|
+
annotationDict.set("M", "D:20190423");
|
555
|
+
annotationDict.set("C", [0, 0, 1]);
|
556
|
+
|
557
|
+
const popupRef = _primitives.Ref.get(820, 0);
|
558
|
+
|
559
|
+
const popupDict = new _primitives.Dict();
|
560
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
561
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
562
|
+
popupDict.set("Parent", annotationRef);
|
563
|
+
annotationDict.set("Popup", popupRef);
|
564
|
+
|
565
|
+
const replyRef = _primitives.Ref.get(821, 0);
|
566
|
+
|
567
|
+
const replyDict = new _primitives.Dict();
|
568
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
569
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
570
|
+
replyDict.set("IRT", annotationRef);
|
571
|
+
replyDict.set("RT", _primitives.Name.get("R"));
|
572
|
+
replyDict.set("T", "ReplyTitle");
|
573
|
+
replyDict.set("Contents", "ReplyText");
|
574
|
+
replyDict.set("CreationDate", "D:20180523");
|
575
|
+
replyDict.set("M", "D:20190523");
|
576
|
+
replyDict.set("C", [0.4]);
|
577
|
+
const xref = new _test_utils.XRefMock([{
|
578
|
+
ref: annotationRef,
|
579
|
+
data: annotationDict
|
580
|
+
}, {
|
581
|
+
ref: popupRef,
|
582
|
+
data: popupDict
|
583
|
+
}, {
|
584
|
+
ref: replyRef,
|
585
|
+
data: replyDict
|
586
|
+
}]);
|
587
|
+
annotationDict.assignXref(xref);
|
588
|
+
popupDict.assignXref(xref);
|
589
|
+
replyDict.assignXref(xref);
|
590
|
+
|
591
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
|
592
|
+
data
|
593
|
+
}) => {
|
594
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
595
|
+
expect(data.replyType).toEqual("R");
|
596
|
+
expect(data.title).toEqual("ReplyTitle");
|
597
|
+
expect(data.contents).toEqual("ReplyText");
|
598
|
+
expect(data.creationDate).toEqual("D:20180523");
|
599
|
+
expect(data.modificationDate).toEqual("D:20190523");
|
600
|
+
expect(data.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
601
|
+
expect(data.hasPopup).toEqual(false);
|
602
|
+
done();
|
603
|
+
}, done.fail);
|
604
|
+
});
|
605
|
+
});
|
606
|
+
describe("TextAnnotation", function () {
|
607
|
+
it("should not parse state model and state when not defined", function (done) {
|
608
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
609
|
+
|
610
|
+
const annotationDict = new _primitives.Dict();
|
611
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
612
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
613
|
+
annotationDict.set("Contents", "TestText");
|
614
|
+
|
615
|
+
const replyRef = _primitives.Ref.get(820, 0);
|
616
|
+
|
617
|
+
const replyDict = new _primitives.Dict();
|
618
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
619
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
620
|
+
replyDict.set("IRT", annotationRef);
|
621
|
+
replyDict.set("RT", _primitives.Name.get("R"));
|
622
|
+
replyDict.set("Contents", "ReplyText");
|
623
|
+
const xref = new _test_utils.XRefMock([{
|
624
|
+
ref: annotationRef,
|
625
|
+
data: annotationDict
|
626
|
+
}, {
|
627
|
+
ref: replyRef,
|
628
|
+
data: replyDict
|
629
|
+
}]);
|
630
|
+
annotationDict.assignXref(xref);
|
631
|
+
replyDict.assignXref(xref);
|
632
|
+
|
633
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
|
634
|
+
data
|
635
|
+
}) => {
|
636
|
+
expect(data.stateModel).toBeNull();
|
637
|
+
expect(data.state).toBeNull();
|
638
|
+
done();
|
639
|
+
}, done.fail);
|
640
|
+
});
|
641
|
+
it("should correctly parse state model and state when defined", function (done) {
|
642
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
643
|
+
|
644
|
+
const annotationDict = new _primitives.Dict();
|
645
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
646
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
647
|
+
|
648
|
+
const replyRef = _primitives.Ref.get(820, 0);
|
649
|
+
|
650
|
+
const replyDict = new _primitives.Dict();
|
651
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
652
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
653
|
+
replyDict.set("IRT", annotationRef);
|
654
|
+
replyDict.set("RT", _primitives.Name.get("R"));
|
655
|
+
replyDict.set("StateModel", "Review");
|
656
|
+
replyDict.set("State", "Rejected");
|
657
|
+
const xref = new _test_utils.XRefMock([{
|
658
|
+
ref: annotationRef,
|
659
|
+
data: annotationDict
|
660
|
+
}, {
|
661
|
+
ref: replyRef,
|
662
|
+
data: replyDict
|
663
|
+
}]);
|
664
|
+
annotationDict.assignXref(xref);
|
665
|
+
replyDict.assignXref(xref);
|
666
|
+
|
667
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(({
|
668
|
+
data
|
669
|
+
}) => {
|
670
|
+
expect(data.stateModel).toEqual("Review");
|
671
|
+
expect(data.state).toEqual("Rejected");
|
672
|
+
done();
|
673
|
+
}, done.fail);
|
674
|
+
});
|
353
675
|
});
|
354
|
-
describe(
|
355
|
-
it(
|
356
|
-
|
357
|
-
actionDict.set(
|
358
|
-
actionDict.set(
|
359
|
-
actionDict.set(
|
360
|
-
|
361
|
-
annotationDict.set(
|
362
|
-
annotationDict.set(
|
363
|
-
annotationDict.set(
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
676
|
+
describe("LinkAnnotation", function () {
|
677
|
+
it("should correctly parse a URI action", function (done) {
|
678
|
+
const actionDict = new _primitives.Dict();
|
679
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
680
|
+
actionDict.set("S", _primitives.Name.get("URI"));
|
681
|
+
actionDict.set("URI", "http://www.ctan.org/tex-archive/info/lshort");
|
682
|
+
const annotationDict = new _primitives.Dict();
|
683
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
684
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
685
|
+
annotationDict.set("A", actionDict);
|
686
|
+
|
687
|
+
const annotationRef = _primitives.Ref.get(820, 0);
|
688
|
+
|
689
|
+
const xref = new _test_utils.XRefMock([{
|
368
690
|
ref: annotationRef,
|
369
691
|
data: annotationDict
|
370
692
|
}]);
|
371
693
|
|
372
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
373
|
-
|
694
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
695
|
+
data
|
696
|
+
}) => {
|
374
697
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
375
|
-
expect(data.url).toEqual(
|
376
|
-
expect(data.unsafeUrl).toEqual(
|
698
|
+
expect(data.url).toEqual("http://www.ctan.org/tex-archive/info/lshort");
|
699
|
+
expect(data.unsafeUrl).toEqual("http://www.ctan.org/tex-archive/info/lshort");
|
377
700
|
expect(data.dest).toBeUndefined();
|
378
701
|
done();
|
379
702
|
}, done.fail);
|
380
703
|
});
|
381
|
-
it(
|
382
|
-
|
383
|
-
actionDict.set(
|
384
|
-
actionDict.set(
|
385
|
-
actionDict.set(
|
386
|
-
|
387
|
-
annotationDict.set(
|
388
|
-
annotationDict.set(
|
389
|
-
annotationDict.set(
|
704
|
+
it("should correctly parse a URI action, where the URI entry " + "is missing a protocol", function (done) {
|
705
|
+
const actionDict = new _primitives.Dict();
|
706
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
707
|
+
actionDict.set("S", _primitives.Name.get("URI"));
|
708
|
+
actionDict.set("URI", "www.hmrc.gov.uk");
|
709
|
+
const annotationDict = new _primitives.Dict();
|
710
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
711
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
712
|
+
annotationDict.set("A", actionDict);
|
390
713
|
|
391
|
-
|
714
|
+
const annotationRef = _primitives.Ref.get(353, 0);
|
392
715
|
|
393
|
-
|
716
|
+
const xref = new _test_utils.XRefMock([{
|
394
717
|
ref: annotationRef,
|
395
718
|
data: annotationDict
|
396
719
|
}]);
|
397
720
|
|
398
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
399
|
-
|
721
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
722
|
+
data
|
723
|
+
}) => {
|
400
724
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
401
|
-
expect(data.url).toEqual(
|
402
|
-
expect(data.unsafeUrl).toEqual(
|
725
|
+
expect(data.url).toEqual("http://www.hmrc.gov.uk/");
|
726
|
+
expect(data.unsafeUrl).toEqual("http://www.hmrc.gov.uk");
|
403
727
|
expect(data.dest).toBeUndefined();
|
404
728
|
done();
|
405
729
|
}, done.fail);
|
406
730
|
});
|
407
|
-
it(
|
408
|
-
|
409
|
-
|
731
|
+
it("should correctly parse a URI action, where the URI entry " + "has an incorrect encoding (bug 1122280)", function (done) {
|
732
|
+
const actionStream = new _stream.StringStream("<<\n" + "/Type /Action\n" + "/S /URI\n" + "/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n" + ">>\n");
|
733
|
+
const parser = new _parser.Parser({
|
410
734
|
lexer: new _parser.Lexer(actionStream),
|
411
735
|
xref: null
|
412
736
|
});
|
413
|
-
|
414
|
-
|
415
|
-
annotationDict.set(
|
416
|
-
annotationDict.set(
|
417
|
-
annotationDict.set(
|
737
|
+
const actionDict = parser.getObj();
|
738
|
+
const annotationDict = new _primitives.Dict();
|
739
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
740
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
741
|
+
annotationDict.set("A", actionDict);
|
418
742
|
|
419
|
-
|
743
|
+
const annotationRef = _primitives.Ref.get(8, 0);
|
420
744
|
|
421
|
-
|
745
|
+
const xref = new _test_utils.XRefMock([{
|
422
746
|
ref: annotationRef,
|
423
747
|
data: annotationDict
|
424
748
|
}]);
|
425
749
|
|
426
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
427
|
-
|
750
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
751
|
+
data
|
752
|
+
}) => {
|
428
753
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
429
|
-
expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)(
|
430
|
-
expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)(
|
754
|
+
expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)("http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4")).href);
|
755
|
+
expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)("http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4"));
|
431
756
|
expect(data.dest).toBeUndefined();
|
432
757
|
done();
|
433
758
|
}, done.fail);
|
434
759
|
});
|
435
|
-
it(
|
436
|
-
|
437
|
-
actionDict.set(
|
438
|
-
actionDict.set(
|
439
|
-
actionDict.set(
|
440
|
-
|
441
|
-
annotationDict.set(
|
442
|
-
annotationDict.set(
|
443
|
-
annotationDict.set(
|
760
|
+
it("should correctly parse a GoTo action", function (done) {
|
761
|
+
const actionDict = new _primitives.Dict();
|
762
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
763
|
+
actionDict.set("S", _primitives.Name.get("GoTo"));
|
764
|
+
actionDict.set("D", "page.157");
|
765
|
+
const annotationDict = new _primitives.Dict();
|
766
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
767
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
768
|
+
annotationDict.set("A", actionDict);
|
444
769
|
|
445
|
-
|
770
|
+
const annotationRef = _primitives.Ref.get(798, 0);
|
446
771
|
|
447
|
-
|
772
|
+
const xref = new _test_utils.XRefMock([{
|
448
773
|
ref: annotationRef,
|
449
774
|
data: annotationDict
|
450
775
|
}]);
|
451
776
|
|
452
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
453
|
-
|
777
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
778
|
+
data
|
779
|
+
}) => {
|
454
780
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
455
781
|
expect(data.url).toBeUndefined();
|
456
782
|
expect(data.unsafeUrl).toBeUndefined();
|
457
|
-
expect(data.dest).toEqual(
|
783
|
+
expect(data.dest).toEqual("page.157");
|
458
784
|
done();
|
459
785
|
}, done.fail);
|
460
786
|
});
|
461
|
-
it(
|
462
|
-
|
463
|
-
actionDict.set(
|
464
|
-
actionDict.set(
|
465
|
-
actionDict.set(
|
466
|
-
actionDict.set(
|
467
|
-
actionDict.set(
|
468
|
-
|
469
|
-
annotationDict.set(
|
470
|
-
annotationDict.set(
|
471
|
-
annotationDict.set(
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
787
|
+
it("should correctly parse a GoToR action, where the FileSpec entry " + "is a string containing a relative URL", function (done) {
|
788
|
+
const actionDict = new _primitives.Dict();
|
789
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
790
|
+
actionDict.set("S", _primitives.Name.get("GoToR"));
|
791
|
+
actionDict.set("F", "../../0013/001346/134685E.pdf");
|
792
|
+
actionDict.set("D", "4.3");
|
793
|
+
actionDict.set("NewWindow", true);
|
794
|
+
const annotationDict = new _primitives.Dict();
|
795
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
796
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
797
|
+
annotationDict.set("A", actionDict);
|
798
|
+
|
799
|
+
const annotationRef = _primitives.Ref.get(489, 0);
|
800
|
+
|
801
|
+
const xref = new _test_utils.XRefMock([{
|
476
802
|
ref: annotationRef,
|
477
803
|
data: annotationDict
|
478
804
|
}]);
|
479
805
|
|
480
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
481
|
-
|
806
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
807
|
+
data
|
808
|
+
}) => {
|
482
809
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
483
810
|
expect(data.url).toBeUndefined();
|
484
|
-
expect(data.unsafeUrl).toEqual(
|
811
|
+
expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
|
485
812
|
expect(data.dest).toBeUndefined();
|
486
813
|
expect(data.newWindow).toEqual(true);
|
487
814
|
done();
|
488
815
|
}, done.fail);
|
489
816
|
});
|
490
|
-
it(
|
491
|
-
|
492
|
-
actionDict.set(
|
493
|
-
actionDict.set(
|
494
|
-
actionDict.set(
|
495
|
-
actionDict.set(
|
496
|
-
|
497
|
-
annotationDict.set(
|
498
|
-
annotationDict.set(
|
499
|
-
annotationDict.set(
|
817
|
+
it("should correctly parse a GoToR action, containing a relative URL, " + 'with the "docBaseUrl" parameter specified', function (done) {
|
818
|
+
const actionDict = new _primitives.Dict();
|
819
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
820
|
+
actionDict.set("S", _primitives.Name.get("GoToR"));
|
821
|
+
actionDict.set("F", "../../0013/001346/134685E.pdf");
|
822
|
+
actionDict.set("D", "4.3");
|
823
|
+
const annotationDict = new _primitives.Dict();
|
824
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
825
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
826
|
+
annotationDict.set("A", actionDict);
|
500
827
|
|
501
|
-
|
828
|
+
const annotationRef = _primitives.Ref.get(489, 0);
|
502
829
|
|
503
|
-
|
830
|
+
const xref = new _test_utils.XRefMock([{
|
504
831
|
ref: annotationRef,
|
505
832
|
data: annotationDict
|
506
833
|
}]);
|
507
|
-
|
508
|
-
docBaseUrl:
|
834
|
+
const pdfManager = new PDFManagerMock({
|
835
|
+
docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf"
|
509
836
|
});
|
510
837
|
|
511
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(
|
512
|
-
|
838
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(({
|
839
|
+
data
|
840
|
+
}) => {
|
513
841
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
514
|
-
expect(data.url).toEqual(
|
515
|
-
expect(data.unsafeUrl).toEqual(
|
842
|
+
expect(data.url).toEqual("http://www.example.com/0013/001346/134685E.pdf#4.3");
|
843
|
+
expect(data.unsafeUrl).toEqual("../../0013/001346/134685E.pdf#4.3");
|
516
844
|
expect(data.dest).toBeUndefined();
|
517
845
|
done();
|
518
846
|
}, done.fail);
|
519
847
|
});
|
520
|
-
it(
|
521
|
-
|
522
|
-
actionDict.set(
|
523
|
-
actionDict.set(
|
524
|
-
actionDict.set(
|
525
|
-
actionDict.set(
|
526
|
-
|
527
|
-
annotationDict.set(
|
528
|
-
annotationDict.set(
|
529
|
-
annotationDict.set(
|
848
|
+
it("should correctly parse a GoToR action, with named destination", function (done) {
|
849
|
+
const actionDict = new _primitives.Dict();
|
850
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
851
|
+
actionDict.set("S", _primitives.Name.get("GoToR"));
|
852
|
+
actionDict.set("F", "http://www.example.com/test.pdf");
|
853
|
+
actionDict.set("D", "15");
|
854
|
+
const annotationDict = new _primitives.Dict();
|
855
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
856
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
857
|
+
annotationDict.set("A", actionDict);
|
530
858
|
|
531
|
-
|
859
|
+
const annotationRef = _primitives.Ref.get(495, 0);
|
532
860
|
|
533
|
-
|
861
|
+
const xref = new _test_utils.XRefMock([{
|
534
862
|
ref: annotationRef,
|
535
863
|
data: annotationDict
|
536
864
|
}]);
|
537
865
|
|
538
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
539
|
-
|
866
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
867
|
+
data
|
868
|
+
}) => {
|
540
869
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
541
|
-
expect(data.url).toEqual(
|
542
|
-
expect(data.unsafeUrl).toEqual(
|
870
|
+
expect(data.url).toEqual("http://www.example.com/test.pdf#15");
|
871
|
+
expect(data.unsafeUrl).toEqual("http://www.example.com/test.pdf#15");
|
543
872
|
expect(data.dest).toBeUndefined();
|
544
873
|
expect(data.newWindow).toBeFalsy();
|
545
874
|
done();
|
546
875
|
}, done.fail);
|
547
876
|
});
|
548
|
-
it(
|
549
|
-
|
550
|
-
actionDict.set(
|
551
|
-
actionDict.set(
|
552
|
-
actionDict.set(
|
553
|
-
actionDict.set(
|
554
|
-
|
555
|
-
annotationDict.set(
|
556
|
-
annotationDict.set(
|
557
|
-
annotationDict.set(
|
877
|
+
it("should correctly parse a GoToR action, with explicit destination array", function (done) {
|
878
|
+
const actionDict = new _primitives.Dict();
|
879
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
880
|
+
actionDict.set("S", _primitives.Name.get("GoToR"));
|
881
|
+
actionDict.set("F", "http://www.example.com/test.pdf");
|
882
|
+
actionDict.set("D", [14, _primitives.Name.get("XYZ"), null, 298.043, null]);
|
883
|
+
const annotationDict = new _primitives.Dict();
|
884
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
885
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
886
|
+
annotationDict.set("A", actionDict);
|
558
887
|
|
559
|
-
|
888
|
+
const annotationRef = _primitives.Ref.get(489, 0);
|
560
889
|
|
561
|
-
|
890
|
+
const xref = new _test_utils.XRefMock([{
|
562
891
|
ref: annotationRef,
|
563
892
|
data: annotationDict
|
564
893
|
}]);
|
565
894
|
|
566
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
567
|
-
|
895
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
896
|
+
data
|
897
|
+
}) => {
|
568
898
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
569
|
-
expect(data.url).toEqual(new URL(
|
570
|
-
expect(data.unsafeUrl).toEqual(
|
899
|
+
expect(data.url).toEqual(new URL("http://www.example.com/test.pdf#" + '[14,{"name":"XYZ"},null,298.043,null]').href);
|
900
|
+
expect(data.unsafeUrl).toEqual("http://www.example.com/test.pdf#" + '[14,{"name":"XYZ"},null,298.043,null]');
|
571
901
|
expect(data.dest).toBeUndefined();
|
572
902
|
expect(data.newWindow).toBeFalsy();
|
573
903
|
done();
|
574
904
|
}, done.fail);
|
575
905
|
});
|
576
|
-
it(
|
577
|
-
|
578
|
-
fileSpecDict.set(
|
579
|
-
fileSpecDict.set(
|
580
|
-
fileSpecDict.set(
|
581
|
-
|
582
|
-
actionDict.set(
|
583
|
-
actionDict.set(
|
584
|
-
actionDict.set(
|
585
|
-
actionDict.set(
|
586
|
-
|
587
|
-
annotationDict.set(
|
588
|
-
annotationDict.set(
|
589
|
-
annotationDict.set(
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
906
|
+
it("should correctly parse a Launch action, where the FileSpec dict " + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
|
907
|
+
const fileSpecDict = new _primitives.Dict();
|
908
|
+
fileSpecDict.set("Type", _primitives.Name.get("FileSpec"));
|
909
|
+
fileSpecDict.set("F", "Part II/Part II.pdf");
|
910
|
+
fileSpecDict.set("UF", "Part II/Part II.pdf");
|
911
|
+
const actionDict = new _primitives.Dict();
|
912
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
913
|
+
actionDict.set("S", _primitives.Name.get("Launch"));
|
914
|
+
actionDict.set("F", fileSpecDict);
|
915
|
+
actionDict.set("NewWindow", true);
|
916
|
+
const annotationDict = new _primitives.Dict();
|
917
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
918
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
919
|
+
annotationDict.set("A", actionDict);
|
920
|
+
|
921
|
+
const annotationRef = _primitives.Ref.get(88, 0);
|
922
|
+
|
923
|
+
const xref = new _test_utils.XRefMock([{
|
594
924
|
ref: annotationRef,
|
595
925
|
data: annotationDict
|
596
926
|
}]);
|
597
|
-
|
598
|
-
docBaseUrl:
|
927
|
+
const pdfManager = new PDFManagerMock({
|
928
|
+
docBaseUrl: "http://www.example.com/test/pdfs/qwerty.pdf"
|
599
929
|
});
|
600
930
|
|
601
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(
|
602
|
-
|
931
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(({
|
932
|
+
data
|
933
|
+
}) => {
|
603
934
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
604
|
-
expect(data.url).toEqual(new URL(
|
605
|
-
expect(data.unsafeUrl).toEqual(
|
935
|
+
expect(data.url).toEqual(new URL("http://www.example.com/test/pdfs/Part II/Part II.pdf").href);
|
936
|
+
expect(data.unsafeUrl).toEqual("Part II/Part II.pdf");
|
606
937
|
expect(data.dest).toBeUndefined();
|
607
938
|
expect(data.newWindow).toEqual(true);
|
608
939
|
done();
|
609
940
|
}, done.fail);
|
610
941
|
});
|
611
|
-
it(
|
942
|
+
it("should recover valid URLs from JavaScript actions having certain " + "white-listed formats", function (done) {
|
612
943
|
function checkJsAction(params) {
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
actionDict.set(
|
619
|
-
actionDict.set(
|
620
|
-
actionDict.set(
|
621
|
-
|
622
|
-
annotationDict.set(
|
623
|
-
annotationDict.set(
|
624
|
-
annotationDict.set(
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
944
|
+
const jsEntry = params.jsEntry;
|
945
|
+
const expectedUrl = params.expectedUrl;
|
946
|
+
const expectedUnsafeUrl = params.expectedUnsafeUrl;
|
947
|
+
const expectedNewWindow = params.expectedNewWindow;
|
948
|
+
const actionDict = new _primitives.Dict();
|
949
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
950
|
+
actionDict.set("S", _primitives.Name.get("JavaScript"));
|
951
|
+
actionDict.set("JS", jsEntry);
|
952
|
+
const annotationDict = new _primitives.Dict();
|
953
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
954
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
955
|
+
annotationDict.set("A", actionDict);
|
956
|
+
|
957
|
+
const annotationRef = _primitives.Ref.get(46, 0);
|
958
|
+
|
959
|
+
const xref = new _test_utils.XRefMock([{
|
629
960
|
ref: annotationRef,
|
630
961
|
data: annotationDict
|
631
962
|
}]);
|
632
|
-
return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
633
|
-
|
963
|
+
return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
964
|
+
data
|
965
|
+
}) => {
|
634
966
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
635
967
|
expect(data.url).toEqual(expectedUrl);
|
636
968
|
expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
|
@@ -639,89 +971,92 @@ describe('annotation', function () {
|
|
639
971
|
});
|
640
972
|
}
|
641
973
|
|
642
|
-
|
974
|
+
const annotation1 = checkJsAction({
|
643
975
|
jsEntry: 'function someFun() { return "qwerty"; } someFun();',
|
644
976
|
expectedUrl: undefined,
|
645
977
|
expectedUnsafeUrl: undefined,
|
646
978
|
expectedNewWindow: undefined
|
647
979
|
});
|
648
|
-
|
649
|
-
jsEntry:
|
650
|
-
expectedUrl: new URL(
|
651
|
-
expectedUnsafeUrl:
|
980
|
+
const annotation2 = checkJsAction({
|
981
|
+
jsEntry: "window.open('http://www.example.com/test.pdf')",
|
982
|
+
expectedUrl: new URL("http://www.example.com/test.pdf").href,
|
983
|
+
expectedUnsafeUrl: "http://www.example.com/test.pdf",
|
652
984
|
expectedNewWindow: undefined
|
653
985
|
});
|
654
|
-
|
986
|
+
const annotation3 = checkJsAction({
|
655
987
|
jsEntry: new _stream.StringStream('app.launchURL("http://www.example.com/test.pdf", true)'),
|
656
|
-
expectedUrl: new URL(
|
657
|
-
expectedUnsafeUrl:
|
988
|
+
expectedUrl: new URL("http://www.example.com/test.pdf").href,
|
989
|
+
expectedUnsafeUrl: "http://www.example.com/test.pdf",
|
658
990
|
expectedNewWindow: true
|
659
991
|
});
|
660
992
|
Promise.all([annotation1, annotation2, annotation3]).then(done, done.fail);
|
661
993
|
});
|
662
|
-
it(
|
663
|
-
|
664
|
-
actionDict.set(
|
665
|
-
actionDict.set(
|
666
|
-
actionDict.set(
|
667
|
-
|
668
|
-
annotationDict.set(
|
669
|
-
annotationDict.set(
|
670
|
-
annotationDict.set(
|
994
|
+
it("should correctly parse a Named action", function (done) {
|
995
|
+
const actionDict = new _primitives.Dict();
|
996
|
+
actionDict.set("Type", _primitives.Name.get("Action"));
|
997
|
+
actionDict.set("S", _primitives.Name.get("Named"));
|
998
|
+
actionDict.set("N", _primitives.Name.get("GoToPage"));
|
999
|
+
const annotationDict = new _primitives.Dict();
|
1000
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1001
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1002
|
+
annotationDict.set("A", actionDict);
|
671
1003
|
|
672
|
-
|
1004
|
+
const annotationRef = _primitives.Ref.get(12, 0);
|
673
1005
|
|
674
|
-
|
1006
|
+
const xref = new _test_utils.XRefMock([{
|
675
1007
|
ref: annotationRef,
|
676
1008
|
data: annotationDict
|
677
1009
|
}]);
|
678
1010
|
|
679
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
680
|
-
|
1011
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1012
|
+
data
|
1013
|
+
}) => {
|
681
1014
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
682
1015
|
expect(data.url).toBeUndefined();
|
683
1016
|
expect(data.unsafeUrl).toBeUndefined();
|
684
|
-
expect(data.action).toEqual(
|
1017
|
+
expect(data.action).toEqual("GoToPage");
|
685
1018
|
done();
|
686
1019
|
}, done.fail);
|
687
1020
|
});
|
688
|
-
it(
|
689
|
-
|
690
|
-
annotationDict.set(
|
691
|
-
annotationDict.set(
|
692
|
-
annotationDict.set(
|
1021
|
+
it("should correctly parse a simple Dest", function (done) {
|
1022
|
+
const annotationDict = new _primitives.Dict();
|
1023
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1024
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1025
|
+
annotationDict.set("Dest", _primitives.Name.get("LI0"));
|
693
1026
|
|
694
|
-
|
1027
|
+
const annotationRef = _primitives.Ref.get(583, 0);
|
695
1028
|
|
696
|
-
|
1029
|
+
const xref = new _test_utils.XRefMock([{
|
697
1030
|
ref: annotationRef,
|
698
1031
|
data: annotationDict
|
699
1032
|
}]);
|
700
1033
|
|
701
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
702
|
-
|
1034
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1035
|
+
data
|
1036
|
+
}) => {
|
703
1037
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
704
1038
|
expect(data.url).toBeUndefined();
|
705
1039
|
expect(data.unsafeUrl).toBeUndefined();
|
706
|
-
expect(data.dest).toEqual(
|
1040
|
+
expect(data.dest).toEqual("LI0");
|
707
1041
|
done();
|
708
1042
|
}, done.fail);
|
709
1043
|
});
|
710
|
-
it(
|
711
|
-
|
712
|
-
annotationDict.set(
|
713
|
-
annotationDict.set(
|
714
|
-
annotationDict.set(
|
1044
|
+
it("should correctly parse a simple Dest, with explicit destination array", function (done) {
|
1045
|
+
const annotationDict = new _primitives.Dict();
|
1046
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1047
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1048
|
+
annotationDict.set("Dest", [_primitives.Ref.get(17, 0), _primitives.Name.get("XYZ"), 0, 841.89, null]);
|
715
1049
|
|
716
|
-
|
1050
|
+
const annotationRef = _primitives.Ref.get(10, 0);
|
717
1051
|
|
718
|
-
|
1052
|
+
const xref = new _test_utils.XRefMock([{
|
719
1053
|
ref: annotationRef,
|
720
1054
|
data: annotationDict
|
721
1055
|
}]);
|
722
1056
|
|
723
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
724
|
-
|
1057
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1058
|
+
data
|
1059
|
+
}) => {
|
725
1060
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
726
1061
|
expect(data.url).toBeUndefined();
|
727
1062
|
expect(data.unsafeUrl).toBeUndefined();
|
@@ -729,148 +1064,226 @@ describe('annotation', function () {
|
|
729
1064
|
num: 17,
|
730
1065
|
gen: 0
|
731
1066
|
}, {
|
732
|
-
name:
|
1067
|
+
name: "XYZ"
|
733
1068
|
}, 0, 841.89, null]);
|
734
1069
|
done();
|
735
1070
|
}, done.fail);
|
736
1071
|
});
|
737
|
-
it(
|
738
|
-
|
739
|
-
destDict.set(
|
740
|
-
destDict.set(
|
741
|
-
destDict.set(
|
742
|
-
|
743
|
-
annotationDict.set(
|
744
|
-
annotationDict.set(
|
745
|
-
annotationDict.set(
|
1072
|
+
it("should correctly parse a Dest, which violates the specification " + "by containing a dictionary", function (done) {
|
1073
|
+
const destDict = new _primitives.Dict();
|
1074
|
+
destDict.set("Type", _primitives.Name.get("Action"));
|
1075
|
+
destDict.set("S", _primitives.Name.get("GoTo"));
|
1076
|
+
destDict.set("D", "page.157");
|
1077
|
+
const annotationDict = new _primitives.Dict();
|
1078
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1079
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1080
|
+
annotationDict.set("Dest", destDict);
|
746
1081
|
|
747
|
-
|
1082
|
+
const annotationRef = _primitives.Ref.get(798, 0);
|
748
1083
|
|
749
|
-
|
1084
|
+
const xref = new _test_utils.XRefMock([{
|
750
1085
|
ref: annotationRef,
|
751
1086
|
data: annotationDict
|
752
1087
|
}]);
|
753
1088
|
|
754
|
-
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(
|
755
|
-
|
1089
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1090
|
+
data
|
1091
|
+
}) => {
|
756
1092
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
757
1093
|
expect(data.url).toBeUndefined();
|
758
1094
|
expect(data.unsafeUrl).toBeUndefined();
|
759
|
-
expect(data.dest).toEqual(
|
1095
|
+
expect(data.dest).toEqual("page.157");
|
1096
|
+
done();
|
1097
|
+
}, done.fail);
|
1098
|
+
});
|
1099
|
+
it("should not set quadpoints if not defined", function (done) {
|
1100
|
+
const annotationDict = new _primitives.Dict();
|
1101
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1102
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1103
|
+
|
1104
|
+
const annotationRef = _primitives.Ref.get(121, 0);
|
1105
|
+
|
1106
|
+
const xref = new _test_utils.XRefMock([{
|
1107
|
+
ref: annotationRef,
|
1108
|
+
data: annotationDict
|
1109
|
+
}]);
|
1110
|
+
|
1111
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1112
|
+
data
|
1113
|
+
}) => {
|
1114
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1115
|
+
expect(data.quadPoints).toBeUndefined();
|
1116
|
+
done();
|
1117
|
+
}, done.fail);
|
1118
|
+
});
|
1119
|
+
it("should set quadpoints if defined", function (done) {
|
1120
|
+
const annotationDict = new _primitives.Dict();
|
1121
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
1122
|
+
annotationDict.set("Subtype", _primitives.Name.get("Link"));
|
1123
|
+
annotationDict.set("Rect", [10, 10, 20, 20]);
|
1124
|
+
annotationDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
|
1125
|
+
|
1126
|
+
const annotationRef = _primitives.Ref.get(121, 0);
|
1127
|
+
|
1128
|
+
const xref = new _test_utils.XRefMock([{
|
1129
|
+
ref: annotationRef,
|
1130
|
+
data: annotationDict
|
1131
|
+
}]);
|
1132
|
+
|
1133
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(({
|
1134
|
+
data
|
1135
|
+
}) => {
|
1136
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1137
|
+
expect(data.quadPoints).toEqual([[{
|
1138
|
+
x: 11,
|
1139
|
+
y: 11
|
1140
|
+
}, {
|
1141
|
+
x: 12,
|
1142
|
+
y: 12
|
1143
|
+
}, {
|
1144
|
+
x: 13,
|
1145
|
+
y: 13
|
1146
|
+
}, {
|
1147
|
+
x: 14,
|
1148
|
+
y: 14
|
1149
|
+
}]]);
|
760
1150
|
done();
|
761
1151
|
}, done.fail);
|
762
1152
|
});
|
763
1153
|
});
|
764
|
-
describe(
|
765
|
-
|
1154
|
+
describe("WidgetAnnotation", function () {
|
1155
|
+
let widgetDict;
|
766
1156
|
beforeEach(function (done) {
|
767
1157
|
widgetDict = new _primitives.Dict();
|
768
|
-
widgetDict.set(
|
769
|
-
widgetDict.set(
|
1158
|
+
widgetDict.set("Type", _primitives.Name.get("Annot"));
|
1159
|
+
widgetDict.set("Subtype", _primitives.Name.get("Widget"));
|
770
1160
|
done();
|
771
1161
|
});
|
772
1162
|
afterEach(function () {
|
773
1163
|
widgetDict = null;
|
774
1164
|
});
|
775
|
-
it(
|
776
|
-
|
1165
|
+
it("should handle unknown field names", function (done) {
|
1166
|
+
const widgetRef = _primitives.Ref.get(20, 0);
|
777
1167
|
|
778
|
-
|
1168
|
+
const xref = new _test_utils.XRefMock([{
|
779
1169
|
ref: widgetRef,
|
780
1170
|
data: widgetDict
|
781
1171
|
}]);
|
782
1172
|
|
783
|
-
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(
|
784
|
-
|
1173
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
|
1174
|
+
data
|
1175
|
+
}) => {
|
785
1176
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
786
|
-
expect(data.fieldName).toEqual(
|
1177
|
+
expect(data.fieldName).toEqual("");
|
787
1178
|
done();
|
788
1179
|
}, done.fail);
|
789
1180
|
});
|
790
|
-
it(
|
791
|
-
widgetDict.set(
|
1181
|
+
it("should construct the field name when there are no ancestors", function (done) {
|
1182
|
+
widgetDict.set("T", "foo");
|
792
1183
|
|
793
|
-
|
1184
|
+
const widgetRef = _primitives.Ref.get(21, 0);
|
794
1185
|
|
795
|
-
|
1186
|
+
const xref = new _test_utils.XRefMock([{
|
796
1187
|
ref: widgetRef,
|
797
1188
|
data: widgetDict
|
798
1189
|
}]);
|
799
1190
|
|
800
|
-
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(
|
801
|
-
|
1191
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
|
1192
|
+
data
|
1193
|
+
}) => {
|
802
1194
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
803
|
-
expect(data.fieldName).toEqual(
|
1195
|
+
expect(data.fieldName).toEqual("foo");
|
804
1196
|
done();
|
805
1197
|
}, done.fail);
|
806
1198
|
});
|
807
|
-
it(
|
808
|
-
|
809
|
-
firstParent.set(
|
810
|
-
|
811
|
-
secondParent.set(
|
812
|
-
secondParent.set(
|
813
|
-
widgetDict.set(
|
814
|
-
widgetDict.set(
|
1199
|
+
it("should construct the field name when there are ancestors", function (done) {
|
1200
|
+
const firstParent = new _primitives.Dict();
|
1201
|
+
firstParent.set("T", "foo");
|
1202
|
+
const secondParent = new _primitives.Dict();
|
1203
|
+
secondParent.set("Parent", firstParent);
|
1204
|
+
secondParent.set("T", "bar");
|
1205
|
+
widgetDict.set("Parent", secondParent);
|
1206
|
+
widgetDict.set("T", "baz");
|
815
1207
|
|
816
|
-
|
1208
|
+
const widgetRef = _primitives.Ref.get(22, 0);
|
817
1209
|
|
818
|
-
|
1210
|
+
const xref = new _test_utils.XRefMock([{
|
819
1211
|
ref: widgetRef,
|
820
1212
|
data: widgetDict
|
821
1213
|
}]);
|
822
1214
|
|
823
|
-
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(
|
824
|
-
|
1215
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
|
1216
|
+
data
|
1217
|
+
}) => {
|
825
1218
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
826
|
-
expect(data.fieldName).toEqual(
|
1219
|
+
expect(data.fieldName).toEqual("foo.bar.baz");
|
827
1220
|
done();
|
828
1221
|
}, done.fail);
|
829
1222
|
});
|
830
|
-
it(
|
831
|
-
|
832
|
-
parentDict.set(
|
833
|
-
parentDict.set(
|
834
|
-
widgetDict.set(
|
835
|
-
widgetDict.set(
|
1223
|
+
it("should construct the field name if a parent is not a dictionary " + "(issue 8143)", function (done) {
|
1224
|
+
const parentDict = new _primitives.Dict();
|
1225
|
+
parentDict.set("Parent", null);
|
1226
|
+
parentDict.set("T", "foo");
|
1227
|
+
widgetDict.set("Parent", parentDict);
|
1228
|
+
widgetDict.set("T", "bar");
|
836
1229
|
|
837
|
-
|
1230
|
+
const widgetRef = _primitives.Ref.get(22, 0);
|
838
1231
|
|
839
|
-
|
1232
|
+
const xref = new _test_utils.XRefMock([{
|
840
1233
|
ref: widgetRef,
|
841
1234
|
data: widgetDict
|
842
1235
|
}]);
|
843
1236
|
|
844
|
-
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(
|
845
|
-
|
1237
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(({
|
1238
|
+
data
|
1239
|
+
}) => {
|
846
1240
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
847
|
-
expect(data.fieldName).toEqual(
|
1241
|
+
expect(data.fieldName).toEqual("foo.bar");
|
848
1242
|
done();
|
849
1243
|
}, done.fail);
|
850
1244
|
});
|
851
1245
|
});
|
852
|
-
describe(
|
853
|
-
|
1246
|
+
describe("TextWidgetAnnotation", function () {
|
1247
|
+
let textWidgetDict, fontRefObj;
|
854
1248
|
beforeEach(function (done) {
|
855
1249
|
textWidgetDict = new _primitives.Dict();
|
856
|
-
textWidgetDict.set(
|
857
|
-
textWidgetDict.set(
|
858
|
-
textWidgetDict.set(
|
1250
|
+
textWidgetDict.set("Type", _primitives.Name.get("Annot"));
|
1251
|
+
textWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
|
1252
|
+
textWidgetDict.set("FT", _primitives.Name.get("Tx"));
|
1253
|
+
const helvDict = new _primitives.Dict();
|
1254
|
+
helvDict.set("BaseFont", _primitives.Name.get("Helvetica"));
|
1255
|
+
helvDict.set("Type", _primitives.Name.get("Font"));
|
1256
|
+
helvDict.set("Subtype", _primitives.Name.get("Type1"));
|
1257
|
+
|
1258
|
+
const fontRef = _primitives.Ref.get(314, 0);
|
1259
|
+
|
1260
|
+
fontRefObj = {
|
1261
|
+
ref: fontRef,
|
1262
|
+
data: helvDict
|
1263
|
+
};
|
1264
|
+
const resourceDict = new _primitives.Dict();
|
1265
|
+
const fontDict = new _primitives.Dict();
|
1266
|
+
fontDict.set("Helv", fontRef);
|
1267
|
+
resourceDict.set("Font", fontDict);
|
1268
|
+
textWidgetDict.set("DA", "/Helv 5 Tf");
|
1269
|
+
textWidgetDict.set("DR", resourceDict);
|
1270
|
+
textWidgetDict.set("Rect", [0, 0, 32, 10]);
|
859
1271
|
done();
|
860
1272
|
});
|
861
1273
|
afterEach(function () {
|
862
|
-
textWidgetDict = null;
|
1274
|
+
textWidgetDict = fontRefObj = null;
|
863
1275
|
});
|
864
|
-
it(
|
865
|
-
|
1276
|
+
it("should handle unknown text alignment, maximum length and flags", function (done) {
|
1277
|
+
const textWidgetRef = _primitives.Ref.get(124, 0);
|
866
1278
|
|
867
|
-
|
1279
|
+
const xref = new _test_utils.XRefMock([{
|
868
1280
|
ref: textWidgetRef,
|
869
1281
|
data: textWidgetDict
|
870
1282
|
}]);
|
871
1283
|
|
872
|
-
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
873
|
-
|
1284
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1285
|
+
data
|
1286
|
+
}) => {
|
874
1287
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
875
1288
|
expect(data.textAlignment).toEqual(null);
|
876
1289
|
expect(data.maxLen).toEqual(null);
|
@@ -880,20 +1293,21 @@ describe('annotation', function () {
|
|
880
1293
|
done();
|
881
1294
|
}, done.fail);
|
882
1295
|
});
|
883
|
-
it(
|
884
|
-
textWidgetDict.set(
|
885
|
-
textWidgetDict.set(
|
886
|
-
textWidgetDict.set(
|
1296
|
+
it("should not set invalid text alignment, maximum length and flags", function (done) {
|
1297
|
+
textWidgetDict.set("Q", "center");
|
1298
|
+
textWidgetDict.set("MaxLen", "five");
|
1299
|
+
textWidgetDict.set("Ff", "readonly");
|
887
1300
|
|
888
|
-
|
1301
|
+
const textWidgetRef = _primitives.Ref.get(43, 0);
|
889
1302
|
|
890
|
-
|
1303
|
+
const xref = new _test_utils.XRefMock([{
|
891
1304
|
ref: textWidgetRef,
|
892
1305
|
data: textWidgetDict
|
893
1306
|
}]);
|
894
1307
|
|
895
|
-
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
896
|
-
|
1308
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1309
|
+
data
|
1310
|
+
}) => {
|
897
1311
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
898
1312
|
expect(data.textAlignment).toEqual(null);
|
899
1313
|
expect(data.maxLen).toEqual(null);
|
@@ -903,20 +1317,21 @@ describe('annotation', function () {
|
|
903
1317
|
done();
|
904
1318
|
}, done.fail);
|
905
1319
|
});
|
906
|
-
it(
|
907
|
-
textWidgetDict.set(
|
908
|
-
textWidgetDict.set(
|
909
|
-
textWidgetDict.set(
|
1320
|
+
it("should set valid text alignment, maximum length and flags", function (done) {
|
1321
|
+
textWidgetDict.set("Q", 1);
|
1322
|
+
textWidgetDict.set("MaxLen", 20);
|
1323
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
|
910
1324
|
|
911
|
-
|
1325
|
+
const textWidgetRef = _primitives.Ref.get(84, 0);
|
912
1326
|
|
913
|
-
|
1327
|
+
const xref = new _test_utils.XRefMock([{
|
914
1328
|
ref: textWidgetRef,
|
915
1329
|
data: textWidgetDict
|
916
1330
|
}]);
|
917
1331
|
|
918
|
-
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
919
|
-
|
1332
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1333
|
+
data
|
1334
|
+
}) => {
|
920
1335
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
921
1336
|
expect(data.textAlignment).toEqual(1);
|
922
1337
|
expect(data.maxLen).toEqual(20);
|
@@ -925,61 +1340,64 @@ describe('annotation', function () {
|
|
925
1340
|
done();
|
926
1341
|
}, done.fail);
|
927
1342
|
});
|
928
|
-
it(
|
929
|
-
textWidgetDict.set(
|
1343
|
+
it("should reject comb fields without a maximum length", function (done) {
|
1344
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
|
930
1345
|
|
931
|
-
|
1346
|
+
const textWidgetRef = _primitives.Ref.get(46, 0);
|
932
1347
|
|
933
|
-
|
1348
|
+
const xref = new _test_utils.XRefMock([{
|
934
1349
|
ref: textWidgetRef,
|
935
1350
|
data: textWidgetDict
|
936
1351
|
}]);
|
937
1352
|
|
938
|
-
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
939
|
-
|
1353
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1354
|
+
data
|
1355
|
+
}) => {
|
940
1356
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
941
1357
|
expect(data.comb).toEqual(false);
|
942
1358
|
done();
|
943
1359
|
}, done.fail);
|
944
1360
|
});
|
945
|
-
it(
|
946
|
-
textWidgetDict.set(
|
947
|
-
textWidgetDict.set(
|
1361
|
+
it("should accept comb fields with a maximum length", function (done) {
|
1362
|
+
textWidgetDict.set("MaxLen", 20);
|
1363
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
|
948
1364
|
|
949
|
-
|
1365
|
+
const textWidgetRef = _primitives.Ref.get(46, 0);
|
950
1366
|
|
951
|
-
|
1367
|
+
const xref = new _test_utils.XRefMock([{
|
952
1368
|
ref: textWidgetRef,
|
953
1369
|
data: textWidgetDict
|
954
1370
|
}]);
|
955
1371
|
|
956
|
-
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
957
|
-
|
1372
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1373
|
+
data
|
1374
|
+
}) => {
|
958
1375
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
959
1376
|
expect(data.comb).toEqual(true);
|
960
1377
|
done();
|
961
1378
|
}, done.fail);
|
962
1379
|
});
|
963
|
-
it(
|
964
|
-
|
965
|
-
|
966
|
-
|
1380
|
+
it("should only accept comb fields when the flags are valid", function (done) {
|
1381
|
+
const invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
|
1382
|
+
let flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
|
1383
|
+
let promise = Promise.resolve();
|
967
1384
|
|
968
|
-
for (
|
969
|
-
promise = promise.then(
|
970
|
-
textWidgetDict.set(
|
971
|
-
textWidgetDict.set(
|
1385
|
+
for (let i = 0, ii = invalidFieldFlags.length; i <= ii; i++) {
|
1386
|
+
promise = promise.then(() => {
|
1387
|
+
textWidgetDict.set("MaxLen", 20);
|
1388
|
+
textWidgetDict.set("Ff", flags);
|
972
1389
|
|
973
|
-
|
1390
|
+
const textWidgetRef = _primitives.Ref.get(93, 0);
|
974
1391
|
|
975
|
-
|
1392
|
+
const xref = new _test_utils.XRefMock([{
|
976
1393
|
ref: textWidgetRef,
|
977
1394
|
data: textWidgetDict
|
978
1395
|
}]);
|
979
|
-
return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(
|
980
|
-
|
1396
|
+
return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1397
|
+
data
|
1398
|
+
}) => {
|
981
1399
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
982
|
-
|
1400
|
+
const valid = invalidFieldFlags.length === 0;
|
983
1401
|
expect(data.comb).toEqual(valid);
|
984
1402
|
|
985
1403
|
if (!valid) {
|
@@ -991,166 +1409,551 @@ describe('annotation', function () {
|
|
991
1409
|
|
992
1410
|
promise.then(done, done.fail);
|
993
1411
|
});
|
1412
|
+
it("should render regular text for printing", function (done) {
|
1413
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1414
|
+
|
1415
|
+
const xref = new _test_utils.XRefMock([{
|
1416
|
+
ref: textWidgetRef,
|
1417
|
+
data: textWidgetDict
|
1418
|
+
}, fontRefObj]);
|
1419
|
+
const task = new _worker.WorkerTask("test print");
|
1420
|
+
partialEvaluator.xref = xref;
|
1421
|
+
|
1422
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1423
|
+
const id = annotation.data.id;
|
1424
|
+
const annotationStorage = {};
|
1425
|
+
annotationStorage[id] = "test\\print";
|
1426
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1427
|
+
}, done.fail).then(appearance => {
|
1428
|
+
expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" + " 2.00 2.00 Td (test\\\\print) Tj ET Q EMC");
|
1429
|
+
done();
|
1430
|
+
}, done.fail);
|
1431
|
+
});
|
1432
|
+
it("should render auto-sized text for printing", function (done) {
|
1433
|
+
textWidgetDict.set("DA", "/Helv 0 Tf");
|
1434
|
+
|
1435
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1436
|
+
|
1437
|
+
const xref = new _test_utils.XRefMock([{
|
1438
|
+
ref: textWidgetRef,
|
1439
|
+
data: textWidgetDict
|
1440
|
+
}, fontRefObj]);
|
1441
|
+
const task = new _worker.WorkerTask("test print");
|
1442
|
+
partialEvaluator.xref = xref;
|
1443
|
+
|
1444
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1445
|
+
const id = annotation.data.id;
|
1446
|
+
const annotationStorage = {};
|
1447
|
+
annotationStorage[id] = "test (print)";
|
1448
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1449
|
+
}, done.fail).then(appearance => {
|
1450
|
+
expect(appearance).toEqual("/Tx BMC q BT /Helv 11 Tf 1 0 0 1 0 0 Tm" + " 2.00 2.00 Td (test \\(print\\)) Tj ET Q EMC");
|
1451
|
+
done();
|
1452
|
+
}, done.fail);
|
1453
|
+
});
|
1454
|
+
it("should not render a password for printing", function (done) {
|
1455
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.PASSWORD);
|
1456
|
+
|
1457
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1458
|
+
|
1459
|
+
const xref = new _test_utils.XRefMock([{
|
1460
|
+
ref: textWidgetRef,
|
1461
|
+
data: textWidgetDict
|
1462
|
+
}, fontRefObj]);
|
1463
|
+
const task = new _worker.WorkerTask("test print");
|
1464
|
+
partialEvaluator.xref = xref;
|
1465
|
+
|
1466
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1467
|
+
const id = annotation.data.id;
|
1468
|
+
const annotationStorage = {};
|
1469
|
+
annotationStorage[id] = "mypassword";
|
1470
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1471
|
+
}, done.fail).then(appearance => {
|
1472
|
+
expect(appearance).toEqual(null);
|
1473
|
+
done();
|
1474
|
+
}, done.fail);
|
1475
|
+
});
|
1476
|
+
it("should render multiline text for printing", function (done) {
|
1477
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
1478
|
+
|
1479
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1480
|
+
|
1481
|
+
const xref = new _test_utils.XRefMock([{
|
1482
|
+
ref: textWidgetRef,
|
1483
|
+
data: textWidgetDict
|
1484
|
+
}, fontRefObj]);
|
1485
|
+
const task = new _worker.WorkerTask("test print");
|
1486
|
+
partialEvaluator.xref = xref;
|
1487
|
+
|
1488
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1489
|
+
const id = annotation.data.id;
|
1490
|
+
const annotationStorage = {};
|
1491
|
+
annotationStorage[id] = "a aa aaa aaaa aaaaa aaaaaa " + "pneumonoultramicroscopicsilicovolcanoconiosis";
|
1492
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1493
|
+
}, done.fail).then(appearance => {
|
1494
|
+
expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " + "2.00 -5.00 Td (a aa aaa ) Tj\n" + "0.00 -5.00 Td (aaaa aaaaa ) Tj\n" + "0.00 -5.00 Td (aaaaaa ) Tj\n" + "0.00 -5.00 Td (pneumonoultr) Tj\n" + "0.00 -5.00 Td (amicroscopi) Tj\n" + "0.00 -5.00 Td (csilicovolca) Tj\n" + "0.00 -5.00 Td (noconiosis) Tj ET Q EMC");
|
1495
|
+
done();
|
1496
|
+
}, done.fail);
|
1497
|
+
});
|
1498
|
+
it("should render multiline text with various EOL for printing", function (done) {
|
1499
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.MULTILINE);
|
1500
|
+
textWidgetDict.set("Rect", [0, 0, 128, 10]);
|
1501
|
+
|
1502
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1503
|
+
|
1504
|
+
const xref = new _test_utils.XRefMock([{
|
1505
|
+
ref: textWidgetRef,
|
1506
|
+
data: textWidgetDict
|
1507
|
+
}, fontRefObj]);
|
1508
|
+
const task = new _worker.WorkerTask("test print");
|
1509
|
+
partialEvaluator.xref = xref;
|
1510
|
+
const expectedAppearance = "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 10 Tm " + "2.00 -5.00 Td " + "(Lorem ipsum dolor sit amet, consectetur adipiscing elit.) Tj\n" + "0.00 -5.00 Td " + "(Aliquam vitae felis ac lectus bibendum ultricies quis non) Tj\n" + "0.00 -5.00 Td " + "( diam.) Tj\n" + "0.00 -5.00 Td " + "(Morbi id porttitor quam, a iaculis dui.) Tj\n" + "0.00 -5.00 Td " + "(Pellentesque habitant morbi tristique senectus et netus ) Tj\n" + "0.00 -5.00 Td " + "(et malesuada fames ac turpis egestas.) Tj\n" + "0.00 -5.00 Td () Tj\n" + "0.00 -5.00 Td () Tj\n" + "0.00 -5.00 Td " + "(Nulla consectetur, ligula in tincidunt placerat, velit ) Tj\n" + "0.00 -5.00 Td " + "(augue consectetur orci, sed mattis libero nunc ut massa.) Tj\n" + "0.00 -5.00 Td " + "(Etiam facilisis tempus interdum.) Tj ET Q EMC";
|
1511
|
+
|
1512
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1513
|
+
const id = annotation.data.id;
|
1514
|
+
const annotationStorage = {};
|
1515
|
+
annotationStorage[id] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r" + "Aliquam vitae felis ac lectus bibendum ultricies quis non diam.\n" + "Morbi id porttitor quam, a iaculis dui.\r\n" + "Pellentesque habitant morbi tristique senectus et " + "netus et malesuada fames ac turpis egestas.\n\r\n\r" + "Nulla consectetur, ligula in tincidunt placerat, " + "velit augue consectetur orci, sed mattis libero nunc ut massa.\r" + "Etiam facilisis tempus interdum.";
|
1516
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1517
|
+
}, done.fail).then(appearance => {
|
1518
|
+
expect(appearance).toEqual(expectedAppearance);
|
1519
|
+
done();
|
1520
|
+
}, done.fail);
|
1521
|
+
});
|
1522
|
+
it("should render comb for printing", function (done) {
|
1523
|
+
textWidgetDict.set("Ff", _util.AnnotationFieldFlag.COMB);
|
1524
|
+
textWidgetDict.set("MaxLen", 4);
|
1525
|
+
|
1526
|
+
const textWidgetRef = _primitives.Ref.get(271, 0);
|
1527
|
+
|
1528
|
+
const xref = new _test_utils.XRefMock([{
|
1529
|
+
ref: textWidgetRef,
|
1530
|
+
data: textWidgetDict
|
1531
|
+
}, fontRefObj]);
|
1532
|
+
const task = new _worker.WorkerTask("test print");
|
1533
|
+
partialEvaluator.xref = xref;
|
1534
|
+
|
1535
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1536
|
+
const id = annotation.data.id;
|
1537
|
+
const annotationStorage = {};
|
1538
|
+
annotationStorage[id] = "aa(aa)a\\";
|
1539
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
1540
|
+
}, done.fail).then(appearance => {
|
1541
|
+
expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 2 2 Tm" + " (a) Tj 8.00 0 Td (a) Tj 8.00 0 Td (\\() Tj" + " 8.00 0 Td (a) Tj 8.00 0 Td (a) Tj" + " 8.00 0 Td (\\)) Tj 8.00 0 Td (a) Tj" + " 8.00 0 Td (\\\\) Tj ET Q EMC");
|
1542
|
+
done();
|
1543
|
+
}, done.fail);
|
1544
|
+
});
|
1545
|
+
it("should save text", function (done) {
|
1546
|
+
const textWidgetRef = _primitives.Ref.get(123, 0);
|
1547
|
+
|
1548
|
+
const xref = new _test_utils.XRefMock([{
|
1549
|
+
ref: textWidgetRef,
|
1550
|
+
data: textWidgetDict
|
1551
|
+
}]);
|
1552
|
+
partialEvaluator.xref = xref;
|
1553
|
+
const task = new _worker.WorkerTask("test save");
|
1554
|
+
|
1555
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1556
|
+
const annotationStorage = {};
|
1557
|
+
annotationStorage[annotation.data.id] = "hello world";
|
1558
|
+
return annotation.save(partialEvaluator, task, annotationStorage);
|
1559
|
+
}, done.fail).then(data => {
|
1560
|
+
expect(data.length).toEqual(2);
|
1561
|
+
const [oldData, newData] = data;
|
1562
|
+
expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
1563
|
+
expect(newData.ref).toEqual(_primitives.Ref.get(1, 0));
|
1564
|
+
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
1565
|
+
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Tx /DA (/Helv 5 Tf) /DR " + "<< /Font << /Helv 314 0 R>>>> /Rect [0 0 32 10] " + "/V (hello world) /AP << /N 1 0 R>> /M (date)>>\nendobj\n");
|
1566
|
+
expect(newData.data).toEqual("1 0 obj\n<< /Length 77 /Subtype /Form /Resources " + "<< /Font << /Helv 314 0 R>>>> /BBox [0 0 32 10]>> stream\n" + "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2.00 2.00 Td (hello world) Tj " + "ET Q EMC\nendstream\nendobj\n");
|
1567
|
+
done();
|
1568
|
+
}, done.fail);
|
1569
|
+
});
|
994
1570
|
});
|
995
|
-
describe(
|
996
|
-
|
1571
|
+
describe("ButtonWidgetAnnotation", function () {
|
1572
|
+
let buttonWidgetDict;
|
997
1573
|
beforeEach(function (done) {
|
998
1574
|
buttonWidgetDict = new _primitives.Dict();
|
999
|
-
buttonWidgetDict.set(
|
1000
|
-
buttonWidgetDict.set(
|
1001
|
-
buttonWidgetDict.set(
|
1575
|
+
buttonWidgetDict.set("Type", _primitives.Name.get("Annot"));
|
1576
|
+
buttonWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
|
1577
|
+
buttonWidgetDict.set("FT", _primitives.Name.get("Btn"));
|
1002
1578
|
done();
|
1003
1579
|
});
|
1004
1580
|
afterEach(function () {
|
1005
1581
|
buttonWidgetDict = null;
|
1006
1582
|
});
|
1007
|
-
it(
|
1008
|
-
buttonWidgetDict.set(
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
appearanceStatesDict.set(
|
1014
|
-
buttonWidgetDict.set(
|
1583
|
+
it("should handle checkboxes with export value", function (done) {
|
1584
|
+
buttonWidgetDict.set("V", _primitives.Name.get("1"));
|
1585
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1586
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1587
|
+
normalAppearanceDict.set("Off", 0);
|
1588
|
+
normalAppearanceDict.set("Checked", 1);
|
1589
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1590
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1591
|
+
|
1592
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1593
|
+
|
1594
|
+
const xref = new _test_utils.XRefMock([{
|
1595
|
+
ref: buttonWidgetRef,
|
1596
|
+
data: buttonWidgetDict
|
1597
|
+
}]);
|
1598
|
+
|
1599
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1600
|
+
data
|
1601
|
+
}) => {
|
1602
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1603
|
+
expect(data.checkBox).toEqual(true);
|
1604
|
+
expect(data.fieldValue).toEqual("1");
|
1605
|
+
expect(data.radioButton).toEqual(false);
|
1606
|
+
expect(data.exportValue).toEqual("Checked");
|
1607
|
+
done();
|
1608
|
+
}, done.fail);
|
1609
|
+
});
|
1610
|
+
it("should handle checkboxes without export value", function (done) {
|
1611
|
+
buttonWidgetDict.set("V", _primitives.Name.get("1"));
|
1015
1612
|
|
1016
|
-
|
1613
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1017
1614
|
|
1018
|
-
|
1615
|
+
const xref = new _test_utils.XRefMock([{
|
1019
1616
|
ref: buttonWidgetRef,
|
1020
1617
|
data: buttonWidgetDict
|
1021
1618
|
}]);
|
1022
1619
|
|
1023
|
-
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1024
|
-
|
1620
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1621
|
+
data
|
1622
|
+
}) => {
|
1025
1623
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1026
1624
|
expect(data.checkBox).toEqual(true);
|
1027
|
-
expect(data.fieldValue).toEqual(
|
1625
|
+
expect(data.fieldValue).toEqual("1");
|
1028
1626
|
expect(data.radioButton).toEqual(false);
|
1029
|
-
expect(data.exportValue).toEqual('Checked');
|
1030
1627
|
done();
|
1031
1628
|
}, done.fail);
|
1032
1629
|
});
|
1033
|
-
it(
|
1034
|
-
buttonWidgetDict.set(
|
1630
|
+
it("should handle checkboxes without /Off appearance", function (done) {
|
1631
|
+
buttonWidgetDict.set("V", _primitives.Name.get("1"));
|
1632
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1633
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1634
|
+
normalAppearanceDict.set("Checked", 1);
|
1635
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1636
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1035
1637
|
|
1036
|
-
|
1638
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1037
1639
|
|
1038
|
-
|
1640
|
+
const xref = new _test_utils.XRefMock([{
|
1039
1641
|
ref: buttonWidgetRef,
|
1040
1642
|
data: buttonWidgetDict
|
1041
1643
|
}]);
|
1042
1644
|
|
1043
|
-
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1044
|
-
|
1645
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1646
|
+
data
|
1647
|
+
}) => {
|
1045
1648
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1046
1649
|
expect(data.checkBox).toEqual(true);
|
1047
|
-
expect(data.fieldValue).toEqual(
|
1650
|
+
expect(data.fieldValue).toEqual("1");
|
1048
1651
|
expect(data.radioButton).toEqual(false);
|
1652
|
+
expect(data.exportValue).toEqual("Checked");
|
1049
1653
|
done();
|
1050
1654
|
}, done.fail);
|
1051
1655
|
});
|
1052
|
-
it(
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1656
|
+
it("should render checkboxes for printing", function (done) {
|
1657
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1658
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1659
|
+
const checkedAppearanceDict = new _primitives.Dict();
|
1660
|
+
const uncheckedAppearanceDict = new _primitives.Dict();
|
1661
|
+
const checkedStream = new _stream.StringStream("0.1 0.2 0.3 rg");
|
1662
|
+
checkedStream.dict = checkedAppearanceDict;
|
1663
|
+
const uncheckedStream = new _stream.StringStream("0.3 0.2 0.1 rg");
|
1664
|
+
uncheckedStream.dict = uncheckedAppearanceDict;
|
1665
|
+
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
1666
|
+
checkedAppearanceDict.set("FormType", 1);
|
1667
|
+
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
1668
|
+
normalAppearanceDict.set("Checked", checkedStream);
|
1669
|
+
normalAppearanceDict.set("Off", uncheckedStream);
|
1670
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1671
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1672
|
+
|
1673
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1674
|
+
|
1675
|
+
const xref = new _test_utils.XRefMock([{
|
1676
|
+
ref: buttonWidgetRef,
|
1677
|
+
data: buttonWidgetDict
|
1678
|
+
}]);
|
1679
|
+
const task = new _worker.WorkerTask("test print");
|
1680
|
+
|
1681
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1682
|
+
const annotationStorage = {};
|
1683
|
+
annotationStorage[annotation.data.id] = true;
|
1684
|
+
return Promise.all([annotation, annotation.getOperatorList(partialEvaluator, task, false, annotationStorage)]);
|
1685
|
+
}, done.fail).then(([annotation, opList]) => {
|
1686
|
+
expect(opList.argsArray.length).toEqual(3);
|
1687
|
+
expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
1688
|
+
expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
1689
|
+
return annotation;
|
1690
|
+
}, done.fail).then(annotation => {
|
1691
|
+
const annotationStorage = {};
|
1692
|
+
annotationStorage[annotation.data.id] = false;
|
1693
|
+
return annotation.getOperatorList(partialEvaluator, task, false, annotationStorage);
|
1694
|
+
}, done.fail).then(opList => {
|
1695
|
+
expect(opList.argsArray.length).toEqual(3);
|
1696
|
+
expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
1697
|
+
expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
1698
|
+
done();
|
1699
|
+
}, done.fail);
|
1700
|
+
});
|
1701
|
+
it("should save checkboxes", function (done) {
|
1702
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1703
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1704
|
+
normalAppearanceDict.set("Checked", _primitives.Ref.get(314, 0));
|
1705
|
+
normalAppearanceDict.set("Off", _primitives.Ref.get(271, 0));
|
1706
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1707
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1708
|
+
buttonWidgetDict.set("V", _primitives.Name.get("Off"));
|
1062
1709
|
|
1063
|
-
|
1710
|
+
const buttonWidgetRef = _primitives.Ref.get(123, 0);
|
1064
1711
|
|
1065
|
-
|
1712
|
+
const xref = new _test_utils.XRefMock([{
|
1066
1713
|
ref: buttonWidgetRef,
|
1067
1714
|
data: buttonWidgetDict
|
1068
1715
|
}]);
|
1716
|
+
partialEvaluator.xref = xref;
|
1717
|
+
const task = new _worker.WorkerTask("test save");
|
1718
|
+
|
1719
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1720
|
+
const annotationStorage = {};
|
1721
|
+
annotationStorage[annotation.data.id] = true;
|
1722
|
+
return Promise.all([annotation, annotation.save(partialEvaluator, task, annotationStorage)]);
|
1723
|
+
}, done.fail).then(([annotation, [oldData]]) => {
|
1724
|
+
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
1725
|
+
expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
1726
|
+
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Btn " + "/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " + "/V /Checked /AS /Checked /M (date)>>\nendobj\n");
|
1727
|
+
return annotation;
|
1728
|
+
}, done.fail).then(annotation => {
|
1729
|
+
const annotationStorage = {};
|
1730
|
+
annotationStorage[annotation.data.id] = false;
|
1731
|
+
return annotation.save(partialEvaluator, task, annotationStorage);
|
1732
|
+
}, done.fail).then(data => {
|
1733
|
+
expect(data).toEqual(null);
|
1734
|
+
done();
|
1735
|
+
}, done.fail);
|
1736
|
+
});
|
1737
|
+
it("should handle radio buttons with a field value", function (done) {
|
1738
|
+
const parentDict = new _primitives.Dict();
|
1739
|
+
parentDict.set("V", _primitives.Name.get("1"));
|
1740
|
+
const normalAppearanceStateDict = new _primitives.Dict();
|
1741
|
+
normalAppearanceStateDict.set("2", null);
|
1742
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1743
|
+
appearanceStatesDict.set("N", normalAppearanceStateDict);
|
1744
|
+
buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
|
1745
|
+
buttonWidgetDict.set("Parent", parentDict);
|
1746
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1747
|
+
|
1748
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1069
1749
|
|
1070
|
-
|
1071
|
-
|
1750
|
+
const xref = new _test_utils.XRefMock([{
|
1751
|
+
ref: buttonWidgetRef,
|
1752
|
+
data: buttonWidgetDict
|
1753
|
+
}]);
|
1754
|
+
|
1755
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1756
|
+
data
|
1757
|
+
}) => {
|
1072
1758
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1073
1759
|
expect(data.checkBox).toEqual(false);
|
1074
1760
|
expect(data.radioButton).toEqual(true);
|
1075
|
-
expect(data.fieldValue).toEqual(
|
1076
|
-
expect(data.buttonValue).toEqual(
|
1761
|
+
expect(data.fieldValue).toEqual("1");
|
1762
|
+
expect(data.buttonValue).toEqual("2");
|
1077
1763
|
done();
|
1078
1764
|
}, done.fail);
|
1079
1765
|
});
|
1080
|
-
it(
|
1081
|
-
|
1082
|
-
normalAppearanceStateDict.set(
|
1083
|
-
|
1084
|
-
appearanceStatesDict.set(
|
1085
|
-
buttonWidgetDict.set(
|
1086
|
-
buttonWidgetDict.set(
|
1766
|
+
it("should handle radio buttons without a field value", function (done) {
|
1767
|
+
const normalAppearanceStateDict = new _primitives.Dict();
|
1768
|
+
normalAppearanceStateDict.set("2", null);
|
1769
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1770
|
+
appearanceStatesDict.set("N", normalAppearanceStateDict);
|
1771
|
+
buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
|
1772
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1087
1773
|
|
1088
|
-
|
1774
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1089
1775
|
|
1090
|
-
|
1776
|
+
const xref = new _test_utils.XRefMock([{
|
1091
1777
|
ref: buttonWidgetRef,
|
1092
1778
|
data: buttonWidgetDict
|
1093
1779
|
}]);
|
1094
1780
|
|
1095
|
-
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1096
|
-
|
1781
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1782
|
+
data
|
1783
|
+
}) => {
|
1097
1784
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1098
1785
|
expect(data.checkBox).toEqual(false);
|
1099
1786
|
expect(data.radioButton).toEqual(true);
|
1100
1787
|
expect(data.fieldValue).toEqual(null);
|
1101
|
-
expect(data.buttonValue).toEqual(
|
1788
|
+
expect(data.buttonValue).toEqual("2");
|
1789
|
+
done();
|
1790
|
+
}, done.fail);
|
1791
|
+
});
|
1792
|
+
it("should render radio buttons for printing", function (done) {
|
1793
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1794
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1795
|
+
const checkedAppearanceDict = new _primitives.Dict();
|
1796
|
+
const uncheckedAppearanceDict = new _primitives.Dict();
|
1797
|
+
const checkedStream = new _stream.StringStream("0.1 0.2 0.3 rg");
|
1798
|
+
checkedStream.dict = checkedAppearanceDict;
|
1799
|
+
const uncheckedStream = new _stream.StringStream("0.3 0.2 0.1 rg");
|
1800
|
+
uncheckedStream.dict = uncheckedAppearanceDict;
|
1801
|
+
checkedAppearanceDict.set("BBox", [0, 0, 8, 8]);
|
1802
|
+
checkedAppearanceDict.set("FormType", 1);
|
1803
|
+
checkedAppearanceDict.set("Matrix", [1, 0, 0, 1, 0, 0]);
|
1804
|
+
normalAppearanceDict.set("Checked", checkedStream);
|
1805
|
+
normalAppearanceDict.set("Off", uncheckedStream);
|
1806
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1807
|
+
buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
|
1808
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1809
|
+
|
1810
|
+
const buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1811
|
+
|
1812
|
+
const xref = new _test_utils.XRefMock([{
|
1813
|
+
ref: buttonWidgetRef,
|
1814
|
+
data: buttonWidgetDict
|
1815
|
+
}]);
|
1816
|
+
const task = new _worker.WorkerTask("test print");
|
1817
|
+
|
1818
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1819
|
+
const annotationStorage = {};
|
1820
|
+
annotationStorage[annotation.data.id] = true;
|
1821
|
+
return Promise.all([annotation, annotation.getOperatorList(partialEvaluator, task, false, annotationStorage)]);
|
1822
|
+
}, done.fail).then(([annotation, opList]) => {
|
1823
|
+
expect(opList.argsArray.length).toEqual(3);
|
1824
|
+
expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
1825
|
+
expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([26, 51, 76]));
|
1826
|
+
return annotation;
|
1827
|
+
}, done.fail).then(annotation => {
|
1828
|
+
const annotationStorage = {};
|
1829
|
+
annotationStorage[annotation.data.id] = false;
|
1830
|
+
return annotation.getOperatorList(partialEvaluator, task, false, annotationStorage);
|
1831
|
+
}, done.fail).then(opList => {
|
1832
|
+
expect(opList.argsArray.length).toEqual(3);
|
1833
|
+
expect(opList.fnArray).toEqual([_util.OPS.beginAnnotation, _util.OPS.setFillRGBColor, _util.OPS.endAnnotation]);
|
1834
|
+
expect(opList.argsArray[1]).toEqual(new Uint8ClampedArray([76, 51, 26]));
|
1835
|
+
done();
|
1836
|
+
}, done.fail);
|
1837
|
+
});
|
1838
|
+
it("should save radio buttons", function (done) {
|
1839
|
+
const appearanceStatesDict = new _primitives.Dict();
|
1840
|
+
const normalAppearanceDict = new _primitives.Dict();
|
1841
|
+
normalAppearanceDict.set("Checked", _primitives.Ref.get(314, 0));
|
1842
|
+
normalAppearanceDict.set("Off", _primitives.Ref.get(271, 0));
|
1843
|
+
appearanceStatesDict.set("N", normalAppearanceDict);
|
1844
|
+
buttonWidgetDict.set("Ff", _util.AnnotationFieldFlag.RADIO);
|
1845
|
+
buttonWidgetDict.set("AP", appearanceStatesDict);
|
1846
|
+
|
1847
|
+
const buttonWidgetRef = _primitives.Ref.get(123, 0);
|
1848
|
+
|
1849
|
+
const parentRef = _primitives.Ref.get(456, 0);
|
1850
|
+
|
1851
|
+
const parentDict = new _primitives.Dict();
|
1852
|
+
parentDict.set("V", _primitives.Name.get("Off"));
|
1853
|
+
parentDict.set("Kids", [buttonWidgetRef]);
|
1854
|
+
buttonWidgetDict.set("Parent", parentRef);
|
1855
|
+
const xref = new _test_utils.XRefMock([{
|
1856
|
+
ref: buttonWidgetRef,
|
1857
|
+
data: buttonWidgetDict
|
1858
|
+
}, {
|
1859
|
+
ref: parentRef,
|
1860
|
+
data: parentDict
|
1861
|
+
}]);
|
1862
|
+
parentDict.xref = xref;
|
1863
|
+
buttonWidgetDict.xref = xref;
|
1864
|
+
partialEvaluator.xref = xref;
|
1865
|
+
const task = new _worker.WorkerTask("test save");
|
1866
|
+
|
1867
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
1868
|
+
const annotationStorage = {};
|
1869
|
+
annotationStorage[annotation.data.id] = true;
|
1870
|
+
return Promise.all([annotation, annotation.save(partialEvaluator, task, annotationStorage)]);
|
1871
|
+
}, done.fail).then(([annotation, data]) => {
|
1872
|
+
expect(data.length).toEqual(2);
|
1873
|
+
const [radioData, parentData] = data;
|
1874
|
+
radioData.data = radioData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
1875
|
+
expect(radioData.ref).toEqual(_primitives.Ref.get(123, 0));
|
1876
|
+
expect(radioData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Btn /Ff 32768 " + "/AP << /N << /Checked 314 0 R /Off 271 0 R>>>> " + "/Parent 456 0 R /AS /Checked /M (date)>>\nendobj\n");
|
1877
|
+
expect(parentData.ref).toEqual(_primitives.Ref.get(456, 0));
|
1878
|
+
expect(parentData.data).toEqual("456 0 obj\n<< /V /Checked /Kids [123 0 R]>>\nendobj\n");
|
1879
|
+
return annotation;
|
1880
|
+
}, done.fail).then(annotation => {
|
1881
|
+
const annotationStorage = {};
|
1882
|
+
annotationStorage[annotation.data.id] = false;
|
1883
|
+
return annotation.save(partialEvaluator, task, annotationStorage);
|
1884
|
+
}, done.fail).then(data => {
|
1885
|
+
expect(data).toEqual(null);
|
1102
1886
|
done();
|
1103
1887
|
}, done.fail);
|
1104
1888
|
});
|
1105
1889
|
});
|
1106
|
-
describe(
|
1107
|
-
|
1890
|
+
describe("ChoiceWidgetAnnotation", function () {
|
1891
|
+
let choiceWidgetDict, fontRefObj;
|
1108
1892
|
beforeEach(function (done) {
|
1109
1893
|
choiceWidgetDict = new _primitives.Dict();
|
1110
|
-
choiceWidgetDict.set(
|
1111
|
-
choiceWidgetDict.set(
|
1112
|
-
choiceWidgetDict.set(
|
1894
|
+
choiceWidgetDict.set("Type", _primitives.Name.get("Annot"));
|
1895
|
+
choiceWidgetDict.set("Subtype", _primitives.Name.get("Widget"));
|
1896
|
+
choiceWidgetDict.set("FT", _primitives.Name.get("Ch"));
|
1897
|
+
const helvDict = new _primitives.Dict();
|
1898
|
+
helvDict.set("BaseFont", _primitives.Name.get("Helvetica"));
|
1899
|
+
helvDict.set("Type", _primitives.Name.get("Font"));
|
1900
|
+
helvDict.set("Subtype", _primitives.Name.get("Type1"));
|
1901
|
+
|
1902
|
+
const fontRef = _primitives.Ref.get(314, 0);
|
1903
|
+
|
1904
|
+
fontRefObj = {
|
1905
|
+
ref: fontRef,
|
1906
|
+
data: helvDict
|
1907
|
+
};
|
1908
|
+
const resourceDict = new _primitives.Dict();
|
1909
|
+
const fontDict = new _primitives.Dict();
|
1910
|
+
fontDict.set("Helv", fontRef);
|
1911
|
+
resourceDict.set("Font", fontDict);
|
1912
|
+
choiceWidgetDict.set("DA", "/Helv 5 Tf");
|
1913
|
+
choiceWidgetDict.set("DR", resourceDict);
|
1914
|
+
choiceWidgetDict.set("Rect", [0, 0, 32, 10]);
|
1113
1915
|
done();
|
1114
1916
|
});
|
1115
1917
|
afterEach(function () {
|
1116
|
-
choiceWidgetDict = null;
|
1918
|
+
choiceWidgetDict = fontRefObj = null;
|
1117
1919
|
});
|
1118
|
-
it(
|
1119
|
-
|
1920
|
+
it("should handle missing option arrays", function (done) {
|
1921
|
+
const choiceWidgetRef = _primitives.Ref.get(122, 0);
|
1120
1922
|
|
1121
|
-
|
1923
|
+
const xref = new _test_utils.XRefMock([{
|
1122
1924
|
ref: choiceWidgetRef,
|
1123
1925
|
data: choiceWidgetDict
|
1124
1926
|
}]);
|
1125
1927
|
|
1126
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1127
|
-
|
1928
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1929
|
+
data
|
1930
|
+
}) => {
|
1128
1931
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1129
1932
|
expect(data.options).toEqual([]);
|
1130
1933
|
done();
|
1131
1934
|
}, done.fail);
|
1132
1935
|
});
|
1133
|
-
it(
|
1134
|
-
|
1936
|
+
it("should handle option arrays with array elements", function (done) {
|
1937
|
+
const optionBarRef = _primitives.Ref.get(20, 0);
|
1135
1938
|
|
1136
|
-
|
1939
|
+
const optionBarStr = "Bar";
|
1137
1940
|
|
1138
|
-
|
1941
|
+
const optionOneRef = _primitives.Ref.get(10, 0);
|
1139
1942
|
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
exportValue:
|
1144
|
-
displayValue:
|
1943
|
+
const optionOneArr = ["bar_export", optionBarRef];
|
1944
|
+
const options = [["foo_export", "Foo"], optionOneRef];
|
1945
|
+
const expected = [{
|
1946
|
+
exportValue: "foo_export",
|
1947
|
+
displayValue: "Foo"
|
1145
1948
|
}, {
|
1146
|
-
exportValue:
|
1147
|
-
displayValue:
|
1949
|
+
exportValue: "bar_export",
|
1950
|
+
displayValue: "Bar"
|
1148
1951
|
}];
|
1149
|
-
choiceWidgetDict.set(
|
1952
|
+
choiceWidgetDict.set("Opt", options);
|
1150
1953
|
|
1151
|
-
|
1954
|
+
const choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1152
1955
|
|
1153
|
-
|
1956
|
+
const xref = new _test_utils.XRefMock([{
|
1154
1957
|
ref: choiceWidgetRef,
|
1155
1958
|
data: choiceWidgetDict
|
1156
1959
|
}, {
|
@@ -1161,30 +1964,31 @@ describe('annotation', function () {
|
|
1161
1964
|
data: optionOneArr
|
1162
1965
|
}]);
|
1163
1966
|
|
1164
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1165
|
-
|
1967
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
1968
|
+
data
|
1969
|
+
}) => {
|
1166
1970
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1167
1971
|
expect(data.options).toEqual(expected);
|
1168
1972
|
done();
|
1169
1973
|
}, done.fail);
|
1170
1974
|
});
|
1171
|
-
it(
|
1172
|
-
|
1975
|
+
it("should handle option arrays with string elements", function (done) {
|
1976
|
+
const optionBarRef = _primitives.Ref.get(10, 0);
|
1173
1977
|
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
exportValue:
|
1178
|
-
displayValue:
|
1978
|
+
const optionBarStr = "Bar";
|
1979
|
+
const options = ["Foo", optionBarRef];
|
1980
|
+
const expected = [{
|
1981
|
+
exportValue: "Foo",
|
1982
|
+
displayValue: "Foo"
|
1179
1983
|
}, {
|
1180
|
-
exportValue:
|
1181
|
-
displayValue:
|
1984
|
+
exportValue: "Bar",
|
1985
|
+
displayValue: "Bar"
|
1182
1986
|
}];
|
1183
|
-
choiceWidgetDict.set(
|
1987
|
+
choiceWidgetDict.set("Opt", options);
|
1184
1988
|
|
1185
|
-
|
1989
|
+
const choiceWidgetRef = _primitives.Ref.get(981, 0);
|
1186
1990
|
|
1187
|
-
|
1991
|
+
const xref = new _test_utils.XRefMock([{
|
1188
1992
|
ref: choiceWidgetRef,
|
1189
1993
|
data: choiceWidgetDict
|
1190
1994
|
}, {
|
@@ -1192,108 +1996,104 @@ describe('annotation', function () {
|
|
1192
1996
|
data: optionBarStr
|
1193
1997
|
}]);
|
1194
1998
|
|
1195
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1196
|
-
|
1999
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2000
|
+
data
|
2001
|
+
}) => {
|
1197
2002
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1198
2003
|
expect(data.options).toEqual(expected);
|
1199
2004
|
done();
|
1200
2005
|
}, done.fail);
|
1201
2006
|
});
|
1202
|
-
it(
|
1203
|
-
|
1204
|
-
|
1205
|
-
exportValue:
|
1206
|
-
displayValue:
|
2007
|
+
it("should handle inherited option arrays (issue 8094)", function (done) {
|
2008
|
+
const options = [["Value1", "Description1"], ["Value2", "Description2"]];
|
2009
|
+
const expected = [{
|
2010
|
+
exportValue: "Value1",
|
2011
|
+
displayValue: "Description1"
|
1207
2012
|
}, {
|
1208
|
-
exportValue:
|
1209
|
-
displayValue:
|
2013
|
+
exportValue: "Value2",
|
2014
|
+
displayValue: "Description2"
|
1210
2015
|
}];
|
1211
|
-
|
1212
|
-
parentDict.set(
|
1213
|
-
choiceWidgetDict.set(
|
2016
|
+
const parentDict = new _primitives.Dict();
|
2017
|
+
parentDict.set("Opt", options);
|
2018
|
+
choiceWidgetDict.set("Parent", parentDict);
|
1214
2019
|
|
1215
|
-
|
2020
|
+
const choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1216
2021
|
|
1217
|
-
|
2022
|
+
const xref = new _test_utils.XRefMock([{
|
1218
2023
|
ref: choiceWidgetRef,
|
1219
2024
|
data: choiceWidgetDict
|
1220
2025
|
}]);
|
1221
2026
|
|
1222
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1223
|
-
|
2027
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2028
|
+
data
|
2029
|
+
}) => {
|
1224
2030
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1225
2031
|
expect(data.options).toEqual(expected);
|
1226
2032
|
done();
|
1227
2033
|
}, done.fail);
|
1228
2034
|
});
|
1229
|
-
it(
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
}];
|
1235
|
-
choiceWidgetDict.set('Opt', options);
|
2035
|
+
it("should decode form values", function (done) {
|
2036
|
+
const encodedString = "\xFE\xFF\x00F\x00o\x00o";
|
2037
|
+
const decodedString = "Foo";
|
2038
|
+
choiceWidgetDict.set("Opt", [encodedString]);
|
2039
|
+
choiceWidgetDict.set("V", encodedString);
|
1236
2040
|
|
1237
|
-
|
2041
|
+
const choiceWidgetRef = _primitives.Ref.get(984, 0);
|
1238
2042
|
|
1239
|
-
|
2043
|
+
const xref = new _test_utils.XRefMock([{
|
1240
2044
|
ref: choiceWidgetRef,
|
1241
2045
|
data: choiceWidgetDict
|
1242
2046
|
}]);
|
1243
2047
|
|
1244
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1245
|
-
|
2048
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2049
|
+
data
|
2050
|
+
}) => {
|
1246
2051
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1247
|
-
expect(data.
|
2052
|
+
expect(data.fieldValue).toEqual([decodedString]);
|
2053
|
+
expect(data.options).toEqual([{
|
2054
|
+
exportValue: decodedString,
|
2055
|
+
displayValue: decodedString
|
2056
|
+
}]);
|
1248
2057
|
done();
|
1249
2058
|
}, done.fail);
|
1250
2059
|
});
|
1251
|
-
it(
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
var choiceWidgetRef = _primitives.Ref.get(968, 0);
|
1256
|
-
|
1257
|
-
var xref = new _test_utils.XRefMock([{
|
1258
|
-
ref: choiceWidgetRef,
|
1259
|
-
data: choiceWidgetDict
|
1260
|
-
}]);
|
2060
|
+
it("should convert the field value to an array", function (done) {
|
2061
|
+
const inputs = [null, "Foo", ["Foo", "Bar"]];
|
2062
|
+
const outputs = [[], ["Foo"], ["Foo", "Bar"]];
|
2063
|
+
let promise = Promise.resolve();
|
1261
2064
|
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
expect(data.fieldValue).toEqual(fieldValue);
|
1266
|
-
done();
|
1267
|
-
}, done.fail);
|
1268
|
-
});
|
1269
|
-
it('should handle string field values', function (done) {
|
1270
|
-
var fieldValue = 'Foo';
|
1271
|
-
choiceWidgetDict.set('V', fieldValue);
|
2065
|
+
for (let i = 0, ii = inputs.length; i < ii; i++) {
|
2066
|
+
promise = promise.then(() => {
|
2067
|
+
choiceWidgetDict.set("V", inputs[i]);
|
1272
2068
|
|
1273
|
-
|
2069
|
+
const choiceWidgetRef = _primitives.Ref.get(968, 0);
|
1274
2070
|
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
2071
|
+
const xref = new _test_utils.XRefMock([{
|
2072
|
+
ref: choiceWidgetRef,
|
2073
|
+
data: choiceWidgetDict
|
2074
|
+
}]);
|
2075
|
+
return _annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2076
|
+
data
|
2077
|
+
}) => {
|
2078
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
2079
|
+
expect(data.fieldValue).toEqual(outputs[i]);
|
2080
|
+
});
|
2081
|
+
});
|
2082
|
+
}
|
1279
2083
|
|
1280
|
-
|
1281
|
-
var data = _ref39.data;
|
1282
|
-
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1283
|
-
expect(data.fieldValue).toEqual([fieldValue]);
|
1284
|
-
done();
|
1285
|
-
}, done.fail);
|
2084
|
+
promise.then(done, done.fail);
|
1286
2085
|
});
|
1287
|
-
it(
|
1288
|
-
|
2086
|
+
it("should handle unknown flags", function (done) {
|
2087
|
+
const choiceWidgetRef = _primitives.Ref.get(166, 0);
|
1289
2088
|
|
1290
|
-
|
2089
|
+
const xref = new _test_utils.XRefMock([{
|
1291
2090
|
ref: choiceWidgetRef,
|
1292
2091
|
data: choiceWidgetDict
|
1293
2092
|
}]);
|
1294
2093
|
|
1295
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1296
|
-
|
2094
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2095
|
+
data
|
2096
|
+
}) => {
|
1297
2097
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1298
2098
|
expect(data.readOnly).toEqual(false);
|
1299
2099
|
expect(data.combo).toEqual(false);
|
@@ -1301,18 +2101,19 @@ describe('annotation', function () {
|
|
1301
2101
|
done();
|
1302
2102
|
}, done.fail);
|
1303
2103
|
});
|
1304
|
-
it(
|
1305
|
-
choiceWidgetDict.set(
|
2104
|
+
it("should not set invalid flags", function (done) {
|
2105
|
+
choiceWidgetDict.set("Ff", "readonly");
|
1306
2106
|
|
1307
|
-
|
2107
|
+
const choiceWidgetRef = _primitives.Ref.get(165, 0);
|
1308
2108
|
|
1309
|
-
|
2109
|
+
const xref = new _test_utils.XRefMock([{
|
1310
2110
|
ref: choiceWidgetRef,
|
1311
2111
|
data: choiceWidgetDict
|
1312
2112
|
}]);
|
1313
2113
|
|
1314
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1315
|
-
|
2114
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2115
|
+
data
|
2116
|
+
}) => {
|
1316
2117
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1317
2118
|
expect(data.readOnly).toEqual(false);
|
1318
2119
|
expect(data.combo).toEqual(false);
|
@@ -1320,18 +2121,19 @@ describe('annotation', function () {
|
|
1320
2121
|
done();
|
1321
2122
|
}, done.fail);
|
1322
2123
|
});
|
1323
|
-
it(
|
1324
|
-
choiceWidgetDict.set(
|
2124
|
+
it("should set valid flags", function (done) {
|
2125
|
+
choiceWidgetDict.set("Ff", _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
|
1325
2126
|
|
1326
|
-
|
2127
|
+
const choiceWidgetRef = _primitives.Ref.get(512, 0);
|
1327
2128
|
|
1328
|
-
|
2129
|
+
const xref = new _test_utils.XRefMock([{
|
1329
2130
|
ref: choiceWidgetRef,
|
1330
2131
|
data: choiceWidgetDict
|
1331
2132
|
}]);
|
1332
2133
|
|
1333
|
-
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(
|
1334
|
-
|
2134
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(({
|
2135
|
+
data
|
2136
|
+
}) => {
|
1335
2137
|
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1336
2138
|
expect(data.readOnly).toEqual(true);
|
1337
2139
|
expect(data.combo).toEqual(true);
|
@@ -1339,61 +2141,110 @@ describe('annotation', function () {
|
|
1339
2141
|
done();
|
1340
2142
|
}, done.fail);
|
1341
2143
|
});
|
2144
|
+
it("should render choice for printing", function (done) {
|
2145
|
+
const choiceWidgetRef = _primitives.Ref.get(271, 0);
|
2146
|
+
|
2147
|
+
const xref = new _test_utils.XRefMock([{
|
2148
|
+
ref: choiceWidgetRef,
|
2149
|
+
data: choiceWidgetDict
|
2150
|
+
}, fontRefObj]);
|
2151
|
+
const task = new _worker.WorkerTask("test print");
|
2152
|
+
partialEvaluator.xref = xref;
|
2153
|
+
|
2154
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
2155
|
+
const id = annotation.data.id;
|
2156
|
+
const annotationStorage = {};
|
2157
|
+
annotationStorage[id] = "a value";
|
2158
|
+
return annotation._getAppearance(partialEvaluator, task, annotationStorage);
|
2159
|
+
}, done.fail).then(appearance => {
|
2160
|
+
expect(appearance).toEqual("/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm" + " 2.00 2.00 Td (a value) Tj ET Q EMC");
|
2161
|
+
done();
|
2162
|
+
}, done.fail);
|
2163
|
+
});
|
2164
|
+
it("should save choice", function (done) {
|
2165
|
+
choiceWidgetDict.set("Opt", ["A", "B", "C"]);
|
2166
|
+
choiceWidgetDict.set("V", "A");
|
2167
|
+
|
2168
|
+
const choiceWidgetRef = _primitives.Ref.get(123, 0);
|
2169
|
+
|
2170
|
+
const xref = new _test_utils.XRefMock([{
|
2171
|
+
ref: choiceWidgetRef,
|
2172
|
+
data: choiceWidgetDict
|
2173
|
+
}]);
|
2174
|
+
partialEvaluator.xref = xref;
|
2175
|
+
const task = new _worker.WorkerTask("test save");
|
2176
|
+
|
2177
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(annotation => {
|
2178
|
+
const annotationStorage = {};
|
2179
|
+
annotationStorage[annotation.data.id] = "C";
|
2180
|
+
return annotation.save(partialEvaluator, task, annotationStorage);
|
2181
|
+
}, done.fail).then(data => {
|
2182
|
+
expect(data.length).toEqual(2);
|
2183
|
+
const [oldData, newData] = data;
|
2184
|
+
expect(oldData.ref).toEqual(_primitives.Ref.get(123, 0));
|
2185
|
+
expect(newData.ref).toEqual(_primitives.Ref.get(1, 0));
|
2186
|
+
oldData.data = oldData.data.replace(/\(D:[0-9]+\)/, "(date)");
|
2187
|
+
expect(oldData.data).toEqual("123 0 obj\n" + "<< /Type /Annot /Subtype /Widget /FT /Ch /DA (/Helv 5 Tf) /DR " + "<< /Font << /Helv 314 0 R>>>> " + "/Rect [0 0 32 10] /Opt [(A) (B) (C)] /V (C) " + "/AP << /N 1 0 R>> /M (date)>>\nendobj\n");
|
2188
|
+
expect(newData.data).toEqual("1 0 obj\n" + "<< /Length 67 /Subtype /Form /Resources << /Font << /Helv 314 0 R>>>> " + "/BBox [0 0 32 10]>> stream\n" + "/Tx BMC q BT /Helv 5 Tf 1 0 0 1 0 0 Tm 2.00 2.00 Td (C) Tj ET Q EMC\n" + "endstream\nendobj\n");
|
2189
|
+
done();
|
2190
|
+
}, done.fail);
|
2191
|
+
});
|
1342
2192
|
});
|
1343
|
-
describe(
|
1344
|
-
it(
|
1345
|
-
|
1346
|
-
lineDict.set(
|
1347
|
-
lineDict.set(
|
1348
|
-
lineDict.set(
|
2193
|
+
describe("LineAnnotation", function () {
|
2194
|
+
it("should set the line coordinates", function (done) {
|
2195
|
+
const lineDict = new _primitives.Dict();
|
2196
|
+
lineDict.set("Type", _primitives.Name.get("Annot"));
|
2197
|
+
lineDict.set("Subtype", _primitives.Name.get("Line"));
|
2198
|
+
lineDict.set("L", [1, 2, 3, 4]);
|
1349
2199
|
|
1350
|
-
|
2200
|
+
const lineRef = _primitives.Ref.get(122, 0);
|
1351
2201
|
|
1352
|
-
|
2202
|
+
const xref = new _test_utils.XRefMock([{
|
1353
2203
|
ref: lineRef,
|
1354
2204
|
data: lineDict
|
1355
2205
|
}]);
|
1356
2206
|
|
1357
|
-
_annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(
|
1358
|
-
|
2207
|
+
_annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(({
|
2208
|
+
data
|
2209
|
+
}) => {
|
1359
2210
|
expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
|
1360
2211
|
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
1361
2212
|
done();
|
1362
2213
|
}, done.fail);
|
1363
2214
|
});
|
1364
2215
|
});
|
1365
|
-
describe(
|
1366
|
-
it(
|
1367
|
-
|
1368
|
-
|
2216
|
+
describe("FileAttachmentAnnotation", function () {
|
2217
|
+
it("should correctly parse a file attachment", function (done) {
|
2218
|
+
const fileStream = new _stream.StringStream("<<\n" + "/Type /EmbeddedFile\n" + "/Subtype /text#2Fplain\n" + ">>\n" + "stream\n" + "Test attachment" + "endstream\n");
|
2219
|
+
const parser = new _parser.Parser({
|
1369
2220
|
lexer: new _parser.Lexer(fileStream),
|
1370
2221
|
xref: null,
|
1371
2222
|
allowStreams: true
|
1372
2223
|
});
|
1373
2224
|
|
1374
|
-
|
2225
|
+
const fileStreamRef = _primitives.Ref.get(18, 0);
|
1375
2226
|
|
1376
|
-
|
1377
|
-
|
1378
|
-
embeddedFileDict.set(
|
2227
|
+
const fileStreamDict = parser.getObj();
|
2228
|
+
const embeddedFileDict = new _primitives.Dict();
|
2229
|
+
embeddedFileDict.set("F", fileStreamRef);
|
1379
2230
|
|
1380
|
-
|
2231
|
+
const fileSpecRef = _primitives.Ref.get(19, 0);
|
1381
2232
|
|
1382
|
-
|
1383
|
-
fileSpecDict.set(
|
1384
|
-
fileSpecDict.set(
|
1385
|
-
fileSpecDict.set(
|
1386
|
-
fileSpecDict.set(
|
2233
|
+
const fileSpecDict = new _primitives.Dict();
|
2234
|
+
fileSpecDict.set("Type", _primitives.Name.get("Filespec"));
|
2235
|
+
fileSpecDict.set("Desc", "");
|
2236
|
+
fileSpecDict.set("EF", embeddedFileDict);
|
2237
|
+
fileSpecDict.set("UF", "Test.txt");
|
1387
2238
|
|
1388
|
-
|
2239
|
+
const fileAttachmentRef = _primitives.Ref.get(20, 0);
|
1389
2240
|
|
1390
|
-
|
1391
|
-
fileAttachmentDict.set(
|
1392
|
-
fileAttachmentDict.set(
|
1393
|
-
fileAttachmentDict.set(
|
1394
|
-
fileAttachmentDict.set(
|
1395
|
-
fileAttachmentDict.set(
|
1396
|
-
|
2241
|
+
const fileAttachmentDict = new _primitives.Dict();
|
2242
|
+
fileAttachmentDict.set("Type", _primitives.Name.get("Annot"));
|
2243
|
+
fileAttachmentDict.set("Subtype", _primitives.Name.get("FileAttachment"));
|
2244
|
+
fileAttachmentDict.set("FS", fileSpecRef);
|
2245
|
+
fileAttachmentDict.set("T", "Topic");
|
2246
|
+
fileAttachmentDict.set("Contents", "Test.txt");
|
2247
|
+
const xref = new _test_utils.XRefMock([{
|
1397
2248
|
ref: fileStreamRef,
|
1398
2249
|
data: fileStreamDict
|
1399
2250
|
}, {
|
@@ -1407,112 +2258,175 @@ describe('annotation', function () {
|
|
1407
2258
|
fileSpecDict.assignXref(xref);
|
1408
2259
|
fileAttachmentDict.assignXref(xref);
|
1409
2260
|
|
1410
|
-
_annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(
|
1411
|
-
|
2261
|
+
_annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(({
|
2262
|
+
data
|
2263
|
+
}) => {
|
1412
2264
|
expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
|
1413
|
-
expect(data.file.filename).toEqual(
|
1414
|
-
expect(data.file.content).toEqual((0, _util.stringToBytes)(
|
2265
|
+
expect(data.file.filename).toEqual("Test.txt");
|
2266
|
+
expect(data.file.content).toEqual((0, _util.stringToBytes)("Test attachment"));
|
1415
2267
|
done();
|
1416
2268
|
}, done.fail);
|
1417
2269
|
});
|
1418
2270
|
});
|
1419
|
-
describe(
|
1420
|
-
it(
|
1421
|
-
|
1422
|
-
parentDict.set(
|
1423
|
-
parentDict.set(
|
1424
|
-
parentDict.set(
|
1425
|
-
parentDict.set(
|
1426
|
-
|
1427
|
-
popupDict.set(
|
1428
|
-
popupDict.set(
|
1429
|
-
popupDict.set(
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
2271
|
+
describe("PopupAnnotation", function () {
|
2272
|
+
it("should inherit properties from its parent", function (done) {
|
2273
|
+
const parentDict = new _primitives.Dict();
|
2274
|
+
parentDict.set("Type", _primitives.Name.get("Annot"));
|
2275
|
+
parentDict.set("Subtype", _primitives.Name.get("Text"));
|
2276
|
+
parentDict.set("M", "D:20190423");
|
2277
|
+
parentDict.set("C", [0, 0, 1]);
|
2278
|
+
const popupDict = new _primitives.Dict();
|
2279
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
2280
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
2281
|
+
popupDict.set("Parent", parentDict);
|
2282
|
+
|
2283
|
+
const popupRef = _primitives.Ref.get(13, 0);
|
2284
|
+
|
2285
|
+
const xref = new _test_utils.XRefMock([{
|
1434
2286
|
ref: popupRef,
|
1435
2287
|
data: popupDict
|
1436
2288
|
}]);
|
1437
2289
|
|
1438
|
-
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(
|
1439
|
-
|
1440
|
-
|
2290
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
|
2291
|
+
data,
|
2292
|
+
viewable
|
2293
|
+
}) => {
|
1441
2294
|
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1442
|
-
expect(data.modificationDate).toEqual(
|
2295
|
+
expect(data.modificationDate).toEqual("D:20190423");
|
1443
2296
|
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
1444
2297
|
done();
|
1445
2298
|
}, done.fail);
|
1446
2299
|
});
|
1447
|
-
it(
|
1448
|
-
|
1449
|
-
parentDict.set(
|
1450
|
-
parentDict.set(
|
1451
|
-
|
1452
|
-
popupDict.set(
|
1453
|
-
popupDict.set(
|
1454
|
-
popupDict.set(
|
2300
|
+
it("should handle missing parent properties", function (done) {
|
2301
|
+
const parentDict = new _primitives.Dict();
|
2302
|
+
parentDict.set("Type", _primitives.Name.get("Annot"));
|
2303
|
+
parentDict.set("Subtype", _primitives.Name.get("Text"));
|
2304
|
+
const popupDict = new _primitives.Dict();
|
2305
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
2306
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
2307
|
+
popupDict.set("Parent", parentDict);
|
1455
2308
|
|
1456
|
-
|
2309
|
+
const popupRef = _primitives.Ref.get(13, 0);
|
1457
2310
|
|
1458
|
-
|
2311
|
+
const xref = new _test_utils.XRefMock([{
|
1459
2312
|
ref: popupRef,
|
1460
2313
|
data: popupDict
|
1461
2314
|
}]);
|
1462
2315
|
|
1463
|
-
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(
|
1464
|
-
|
1465
|
-
|
2316
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
|
2317
|
+
data,
|
2318
|
+
viewable
|
2319
|
+
}) => {
|
1466
2320
|
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1467
2321
|
expect(data.modificationDate).toEqual(null);
|
1468
2322
|
expect(data.color).toEqual(null);
|
1469
2323
|
done();
|
1470
2324
|
}, done.fail);
|
1471
2325
|
});
|
1472
|
-
it(
|
1473
|
-
|
1474
|
-
parentDict.set(
|
1475
|
-
parentDict.set(
|
1476
|
-
parentDict.set(
|
1477
|
-
|
1478
|
-
popupDict.set(
|
1479
|
-
popupDict.set(
|
1480
|
-
popupDict.set(
|
1481
|
-
popupDict.set(
|
2326
|
+
it("should inherit the parent flags when the Popup is not viewable, " + "but the parent is (PR 7352)", function (done) {
|
2327
|
+
const parentDict = new _primitives.Dict();
|
2328
|
+
parentDict.set("Type", _primitives.Name.get("Annot"));
|
2329
|
+
parentDict.set("Subtype", _primitives.Name.get("Text"));
|
2330
|
+
parentDict.set("F", 28);
|
2331
|
+
const popupDict = new _primitives.Dict();
|
2332
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
2333
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
2334
|
+
popupDict.set("F", 25);
|
2335
|
+
popupDict.set("Parent", parentDict);
|
1482
2336
|
|
1483
|
-
|
2337
|
+
const popupRef = _primitives.Ref.get(13, 0);
|
1484
2338
|
|
1485
|
-
|
2339
|
+
const xref = new _test_utils.XRefMock([{
|
1486
2340
|
ref: popupRef,
|
1487
2341
|
data: popupDict
|
1488
2342
|
}]);
|
1489
2343
|
|
1490
|
-
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(
|
1491
|
-
|
1492
|
-
|
2344
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
|
2345
|
+
data,
|
2346
|
+
viewable
|
2347
|
+
}) => {
|
1493
2348
|
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1494
2349
|
expect(data.annotationFlags).toEqual(25);
|
1495
2350
|
expect(viewable).toEqual(true);
|
1496
2351
|
done();
|
1497
2352
|
}, done.fail);
|
1498
2353
|
});
|
2354
|
+
it("should correctly inherit Contents from group-master annotation " + "if parent has ReplyType == Group", function (done) {
|
2355
|
+
const annotationRef = _primitives.Ref.get(819, 0);
|
2356
|
+
|
2357
|
+
const annotationDict = new _primitives.Dict();
|
2358
|
+
annotationDict.set("Type", _primitives.Name.get("Annot"));
|
2359
|
+
annotationDict.set("Subtype", _primitives.Name.get("Text"));
|
2360
|
+
annotationDict.set("T", "Correct Title");
|
2361
|
+
annotationDict.set("Contents", "Correct Text");
|
2362
|
+
annotationDict.set("M", "D:20190423");
|
2363
|
+
annotationDict.set("C", [0, 0, 1]);
|
2364
|
+
|
2365
|
+
const replyRef = _primitives.Ref.get(820, 0);
|
2366
|
+
|
2367
|
+
const replyDict = new _primitives.Dict();
|
2368
|
+
replyDict.set("Type", _primitives.Name.get("Annot"));
|
2369
|
+
replyDict.set("Subtype", _primitives.Name.get("Text"));
|
2370
|
+
replyDict.set("IRT", annotationRef);
|
2371
|
+
replyDict.set("RT", _primitives.Name.get("Group"));
|
2372
|
+
replyDict.set("T", "Reply Title");
|
2373
|
+
replyDict.set("Contents", "Reply Text");
|
2374
|
+
replyDict.set("M", "D:20190523");
|
2375
|
+
replyDict.set("C", [0.4]);
|
2376
|
+
|
2377
|
+
const popupRef = _primitives.Ref.get(821, 0);
|
2378
|
+
|
2379
|
+
const popupDict = new _primitives.Dict();
|
2380
|
+
popupDict.set("Type", _primitives.Name.get("Annot"));
|
2381
|
+
popupDict.set("Subtype", _primitives.Name.get("Popup"));
|
2382
|
+
popupDict.set("T", "Wrong Title");
|
2383
|
+
popupDict.set("Contents", "Wrong Text");
|
2384
|
+
popupDict.set("Parent", replyRef);
|
2385
|
+
popupDict.set("M", "D:20190623");
|
2386
|
+
popupDict.set("C", [0.8]);
|
2387
|
+
replyDict.set("Popup", popupRef);
|
2388
|
+
const xref = new _test_utils.XRefMock([{
|
2389
|
+
ref: annotationRef,
|
2390
|
+
data: annotationDict
|
2391
|
+
}, {
|
2392
|
+
ref: replyRef,
|
2393
|
+
data: replyDict
|
2394
|
+
}, {
|
2395
|
+
ref: popupRef,
|
2396
|
+
data: popupDict
|
2397
|
+
}]);
|
2398
|
+
annotationDict.assignXref(xref);
|
2399
|
+
popupDict.assignXref(xref);
|
2400
|
+
replyDict.assignXref(xref);
|
2401
|
+
|
2402
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(({
|
2403
|
+
data
|
2404
|
+
}) => {
|
2405
|
+
expect(data.title).toEqual("Correct Title");
|
2406
|
+
expect(data.contents).toEqual("Correct Text");
|
2407
|
+
expect(data.modificationDate).toEqual("D:20190423");
|
2408
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
2409
|
+
done();
|
2410
|
+
}, done.fail);
|
2411
|
+
});
|
1499
2412
|
});
|
1500
|
-
describe(
|
1501
|
-
it(
|
1502
|
-
|
1503
|
-
inkDict.set(
|
1504
|
-
inkDict.set(
|
1505
|
-
inkDict.set(
|
2413
|
+
describe("InkAnnotation", function () {
|
2414
|
+
it("should handle a single ink list", function (done) {
|
2415
|
+
const inkDict = new _primitives.Dict();
|
2416
|
+
inkDict.set("Type", _primitives.Name.get("Annot"));
|
2417
|
+
inkDict.set("Subtype", _primitives.Name.get("Ink"));
|
2418
|
+
inkDict.set("InkList", [[1, 1, 1, 2, 2, 2, 3, 3]]);
|
1506
2419
|
|
1507
|
-
|
2420
|
+
const inkRef = _primitives.Ref.get(142, 0);
|
1508
2421
|
|
1509
|
-
|
2422
|
+
const xref = new _test_utils.XRefMock([{
|
1510
2423
|
ref: inkRef,
|
1511
2424
|
data: inkDict
|
1512
2425
|
}]);
|
1513
2426
|
|
1514
|
-
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(
|
1515
|
-
|
2427
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(({
|
2428
|
+
data
|
2429
|
+
}) => {
|
1516
2430
|
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1517
2431
|
expect(data.inkLists.length).toEqual(1);
|
1518
2432
|
expect(data.inkLists[0]).toEqual([{
|
@@ -1531,21 +2445,22 @@ describe('annotation', function () {
|
|
1531
2445
|
done();
|
1532
2446
|
}, done.fail);
|
1533
2447
|
});
|
1534
|
-
it(
|
1535
|
-
|
1536
|
-
inkDict.set(
|
1537
|
-
inkDict.set(
|
1538
|
-
inkDict.set(
|
2448
|
+
it("should handle multiple ink lists", function (done) {
|
2449
|
+
const inkDict = new _primitives.Dict();
|
2450
|
+
inkDict.set("Type", _primitives.Name.get("Annot"));
|
2451
|
+
inkDict.set("Subtype", _primitives.Name.get("Ink"));
|
2452
|
+
inkDict.set("InkList", [[1, 1, 1, 2], [3, 3, 4, 5]]);
|
1539
2453
|
|
1540
|
-
|
2454
|
+
const inkRef = _primitives.Ref.get(143, 0);
|
1541
2455
|
|
1542
|
-
|
2456
|
+
const xref = new _test_utils.XRefMock([{
|
1543
2457
|
ref: inkRef,
|
1544
2458
|
data: inkDict
|
1545
2459
|
}]);
|
1546
2460
|
|
1547
|
-
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(
|
1548
|
-
|
2461
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(({
|
2462
|
+
data
|
2463
|
+
}) => {
|
1549
2464
|
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1550
2465
|
expect(data.inkLists.length).toEqual(2);
|
1551
2466
|
expect(data.inkLists[0]).toEqual([{
|
@@ -1566,4 +2481,228 @@ describe('annotation', function () {
|
|
1566
2481
|
}, done.fail);
|
1567
2482
|
});
|
1568
2483
|
});
|
2484
|
+
describe("HightlightAnnotation", function () {
|
2485
|
+
it("should not set quadpoints if not defined", function (done) {
|
2486
|
+
const highlightDict = new _primitives.Dict();
|
2487
|
+
highlightDict.set("Type", _primitives.Name.get("Annot"));
|
2488
|
+
highlightDict.set("Subtype", _primitives.Name.get("Highlight"));
|
2489
|
+
|
2490
|
+
const highlightRef = _primitives.Ref.get(121, 0);
|
2491
|
+
|
2492
|
+
const xref = new _test_utils.XRefMock([{
|
2493
|
+
ref: highlightRef,
|
2494
|
+
data: highlightDict
|
2495
|
+
}]);
|
2496
|
+
|
2497
|
+
_annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(({
|
2498
|
+
data
|
2499
|
+
}) => {
|
2500
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
|
2501
|
+
expect(data.quadPoints).toBeUndefined();
|
2502
|
+
done();
|
2503
|
+
}, done.fail);
|
2504
|
+
});
|
2505
|
+
it("should set quadpoints if defined", function (done) {
|
2506
|
+
const highlightDict = new _primitives.Dict();
|
2507
|
+
highlightDict.set("Type", _primitives.Name.get("Annot"));
|
2508
|
+
highlightDict.set("Subtype", _primitives.Name.get("Highlight"));
|
2509
|
+
highlightDict.set("Rect", [10, 10, 20, 20]);
|
2510
|
+
highlightDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
|
2511
|
+
|
2512
|
+
const highlightRef = _primitives.Ref.get(121, 0);
|
2513
|
+
|
2514
|
+
const xref = new _test_utils.XRefMock([{
|
2515
|
+
ref: highlightRef,
|
2516
|
+
data: highlightDict
|
2517
|
+
}]);
|
2518
|
+
|
2519
|
+
_annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(({
|
2520
|
+
data
|
2521
|
+
}) => {
|
2522
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
|
2523
|
+
expect(data.quadPoints).toEqual([[{
|
2524
|
+
x: 11,
|
2525
|
+
y: 11
|
2526
|
+
}, {
|
2527
|
+
x: 12,
|
2528
|
+
y: 12
|
2529
|
+
}, {
|
2530
|
+
x: 13,
|
2531
|
+
y: 13
|
2532
|
+
}, {
|
2533
|
+
x: 14,
|
2534
|
+
y: 14
|
2535
|
+
}]]);
|
2536
|
+
done();
|
2537
|
+
}, done.fail);
|
2538
|
+
});
|
2539
|
+
});
|
2540
|
+
describe("UnderlineAnnotation", function () {
|
2541
|
+
it("should not set quadpoints if not defined", function (done) {
|
2542
|
+
const underlineDict = new _primitives.Dict();
|
2543
|
+
underlineDict.set("Type", _primitives.Name.get("Annot"));
|
2544
|
+
underlineDict.set("Subtype", _primitives.Name.get("Underline"));
|
2545
|
+
|
2546
|
+
const underlineRef = _primitives.Ref.get(121, 0);
|
2547
|
+
|
2548
|
+
const xref = new _test_utils.XRefMock([{
|
2549
|
+
ref: underlineRef,
|
2550
|
+
data: underlineDict
|
2551
|
+
}]);
|
2552
|
+
|
2553
|
+
_annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(({
|
2554
|
+
data
|
2555
|
+
}) => {
|
2556
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
|
2557
|
+
expect(data.quadPoints).toBeUndefined();
|
2558
|
+
done();
|
2559
|
+
}, done.fail);
|
2560
|
+
});
|
2561
|
+
it("should set quadpoints if defined", function (done) {
|
2562
|
+
const underlineDict = new _primitives.Dict();
|
2563
|
+
underlineDict.set("Type", _primitives.Name.get("Annot"));
|
2564
|
+
underlineDict.set("Subtype", _primitives.Name.get("Underline"));
|
2565
|
+
underlineDict.set("Rect", [10, 10, 20, 20]);
|
2566
|
+
underlineDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
|
2567
|
+
|
2568
|
+
const underlineRef = _primitives.Ref.get(121, 0);
|
2569
|
+
|
2570
|
+
const xref = new _test_utils.XRefMock([{
|
2571
|
+
ref: underlineRef,
|
2572
|
+
data: underlineDict
|
2573
|
+
}]);
|
2574
|
+
|
2575
|
+
_annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(({
|
2576
|
+
data
|
2577
|
+
}) => {
|
2578
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
|
2579
|
+
expect(data.quadPoints).toEqual([[{
|
2580
|
+
x: 11,
|
2581
|
+
y: 11
|
2582
|
+
}, {
|
2583
|
+
x: 12,
|
2584
|
+
y: 12
|
2585
|
+
}, {
|
2586
|
+
x: 13,
|
2587
|
+
y: 13
|
2588
|
+
}, {
|
2589
|
+
x: 14,
|
2590
|
+
y: 14
|
2591
|
+
}]]);
|
2592
|
+
done();
|
2593
|
+
}, done.fail);
|
2594
|
+
});
|
2595
|
+
});
|
2596
|
+
describe("SquigglyAnnotation", function () {
|
2597
|
+
it("should not set quadpoints if not defined", function (done) {
|
2598
|
+
const squigglyDict = new _primitives.Dict();
|
2599
|
+
squigglyDict.set("Type", _primitives.Name.get("Annot"));
|
2600
|
+
squigglyDict.set("Subtype", _primitives.Name.get("Squiggly"));
|
2601
|
+
|
2602
|
+
const squigglyRef = _primitives.Ref.get(121, 0);
|
2603
|
+
|
2604
|
+
const xref = new _test_utils.XRefMock([{
|
2605
|
+
ref: squigglyRef,
|
2606
|
+
data: squigglyDict
|
2607
|
+
}]);
|
2608
|
+
|
2609
|
+
_annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(({
|
2610
|
+
data
|
2611
|
+
}) => {
|
2612
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
|
2613
|
+
expect(data.quadPoints).toBeUndefined();
|
2614
|
+
done();
|
2615
|
+
}, done.fail);
|
2616
|
+
});
|
2617
|
+
it("should set quadpoints if defined", function (done) {
|
2618
|
+
const squigglyDict = new _primitives.Dict();
|
2619
|
+
squigglyDict.set("Type", _primitives.Name.get("Annot"));
|
2620
|
+
squigglyDict.set("Subtype", _primitives.Name.get("Squiggly"));
|
2621
|
+
squigglyDict.set("Rect", [10, 10, 20, 20]);
|
2622
|
+
squigglyDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
|
2623
|
+
|
2624
|
+
const squigglyRef = _primitives.Ref.get(121, 0);
|
2625
|
+
|
2626
|
+
const xref = new _test_utils.XRefMock([{
|
2627
|
+
ref: squigglyRef,
|
2628
|
+
data: squigglyDict
|
2629
|
+
}]);
|
2630
|
+
|
2631
|
+
_annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(({
|
2632
|
+
data
|
2633
|
+
}) => {
|
2634
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
|
2635
|
+
expect(data.quadPoints).toEqual([[{
|
2636
|
+
x: 11,
|
2637
|
+
y: 11
|
2638
|
+
}, {
|
2639
|
+
x: 12,
|
2640
|
+
y: 12
|
2641
|
+
}, {
|
2642
|
+
x: 13,
|
2643
|
+
y: 13
|
2644
|
+
}, {
|
2645
|
+
x: 14,
|
2646
|
+
y: 14
|
2647
|
+
}]]);
|
2648
|
+
done();
|
2649
|
+
}, done.fail);
|
2650
|
+
});
|
2651
|
+
});
|
2652
|
+
describe("StrikeOutAnnotation", function () {
|
2653
|
+
it("should not set quadpoints if not defined", function (done) {
|
2654
|
+
const strikeOutDict = new _primitives.Dict();
|
2655
|
+
strikeOutDict.set("Type", _primitives.Name.get("Annot"));
|
2656
|
+
strikeOutDict.set("Subtype", _primitives.Name.get("StrikeOut"));
|
2657
|
+
|
2658
|
+
const strikeOutRef = _primitives.Ref.get(121, 0);
|
2659
|
+
|
2660
|
+
const xref = new _test_utils.XRefMock([{
|
2661
|
+
ref: strikeOutRef,
|
2662
|
+
data: strikeOutDict
|
2663
|
+
}]);
|
2664
|
+
|
2665
|
+
_annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(({
|
2666
|
+
data
|
2667
|
+
}) => {
|
2668
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
|
2669
|
+
expect(data.quadPoints).toBeUndefined();
|
2670
|
+
done();
|
2671
|
+
}, done.fail);
|
2672
|
+
});
|
2673
|
+
it("should set quadpoints if defined", function (done) {
|
2674
|
+
const strikeOutDict = new _primitives.Dict();
|
2675
|
+
strikeOutDict.set("Type", _primitives.Name.get("Annot"));
|
2676
|
+
strikeOutDict.set("Subtype", _primitives.Name.get("StrikeOut"));
|
2677
|
+
strikeOutDict.set("Rect", [10, 10, 20, 20]);
|
2678
|
+
strikeOutDict.set("QuadPoints", [11, 11, 12, 12, 13, 13, 14, 14]);
|
2679
|
+
|
2680
|
+
const strikeOutRef = _primitives.Ref.get(121, 0);
|
2681
|
+
|
2682
|
+
const xref = new _test_utils.XRefMock([{
|
2683
|
+
ref: strikeOutRef,
|
2684
|
+
data: strikeOutDict
|
2685
|
+
}]);
|
2686
|
+
|
2687
|
+
_annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(({
|
2688
|
+
data
|
2689
|
+
}) => {
|
2690
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
|
2691
|
+
expect(data.quadPoints).toEqual([[{
|
2692
|
+
x: 11,
|
2693
|
+
y: 11
|
2694
|
+
}, {
|
2695
|
+
x: 12,
|
2696
|
+
y: 12
|
2697
|
+
}, {
|
2698
|
+
x: 13,
|
2699
|
+
y: 13
|
2700
|
+
}, {
|
2701
|
+
x: 14,
|
2702
|
+
y: 14
|
2703
|
+
}]]);
|
2704
|
+
done();
|
2705
|
+
}, done.fail);
|
2706
|
+
});
|
2707
|
+
});
|
1569
2708
|
});
|