pdfjs-dist 2.0.550 → 2.3.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +21618 -14369
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +22758 -11399
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +11500 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +767 -258
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +428 -157
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +173 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +575 -272
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1032 -351
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +813 -196
- package/lib/core/function.js +253 -27
- package/lib/core/glyphlist.js +5 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +502 -72
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +293 -52
- package/lib/core/jpx.js +419 -12
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1368 -500
- package/lib/core/operator_list.js +159 -43
- package/lib/core/parser.js +544 -199
- package/lib/core/pattern.js +170 -21
- package/lib/core/pdf_manager.js +324 -134
- package/lib/core/primitives.js +169 -61
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +327 -34
- package/lib/core/type1_parser.js +148 -8
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +215 -229
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +618 -192
- package/lib/display/api.js +1798 -882
- package/lib/display/api_compatibility.js +5 -10
- package/lib/display/canvas.js +366 -45
- package/lib/display/content_disposition.js +71 -24
- package/lib/display/display_utils.js +777 -0
- package/lib/display/fetch_stream.js +205 -87
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +38 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +103 -36
- package/lib/display/svg.js +1232 -519
- package/lib/display/text_layer.js +208 -75
- package/lib/display/transport_stream.js +345 -94
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +60 -4
- package/lib/pdf.js +35 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +170 -572
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +216 -163
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/util.js +495 -385
- package/lib/test/unit/annotation_spec.js +1464 -401
- package/lib/test/unit/api_spec.js +718 -361
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +9 -10
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +59 -20
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/message_handler_spec.js +30 -13
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +22 -55
- package/lib/test/unit/network_utils_spec.js +105 -14
- package/lib/test/unit/node_stream_spec.js +58 -34
- package/lib/test/unit/parser_spec.js +162 -71
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +55 -22
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +9 -7
- package/lib/test/unit/ui_utils_spec.js +236 -36
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1252 -609
- package/lib/web/app_options.js +103 -65
- package/lib/web/base_viewer.js +522 -242
- package/lib/web/chromecom.js +259 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -12
- package/lib/web/firefox_print_service.js +27 -14
- package/lib/web/firefoxcom.js +318 -78
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +174 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +255 -136
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +144 -79
- package/lib/web/pdf_outline_viewer.js +124 -47
- package/lib/web/pdf_page_view.js +194 -74
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +59 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +144 -81
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +82 -87
- package/lib/web/preferences.js +284 -91
- package/lib/web/secondary_toolbar.js +132 -59
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +80 -43
- package/lib/web/ui_utils.js +400 -134
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +3 -8
- package/package.json +3 -2
- package/web/pdf_viewer.css +23 -15
- package/web/pdf_viewer.js +3429 -1245
- package/web/pdf_viewer.js.map +1 -1
- package/external/streams/streams-lib.js +0 -3962
- package/lib/display/dom_utils.js +0 -429
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
@@ -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 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,39 +19,60 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
|
-
var _annotation = require(
|
24
|
+
var _annotation = require("../../core/annotation");
|
25
25
|
|
26
|
-
var _util = require(
|
26
|
+
var _util = require("../../shared/util");
|
27
27
|
|
28
|
-
var
|
28
|
+
var _test_utils = require("./test_utils");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _primitives = require("../../core/primitives");
|
31
31
|
|
32
|
-
var
|
32
|
+
var _parser = require("../../core/parser");
|
33
33
|
|
34
|
-
var
|
34
|
+
var _stream = require("../../core/stream");
|
35
|
+
|
36
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
37
|
+
|
38
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
39
|
+
|
40
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
35
41
|
|
36
42
|
describe('annotation', function () {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
var PDFManagerMock =
|
44
|
+
/*#__PURE__*/
|
45
|
+
function () {
|
46
|
+
function PDFManagerMock(params) {
|
47
|
+
_classCallCheck(this, PDFManagerMock);
|
48
|
+
|
49
|
+
this.docBaseUrl = params.docBaseUrl || null;
|
50
|
+
}
|
51
|
+
|
52
|
+
_createClass(PDFManagerMock, [{
|
53
|
+
key: "ensure",
|
54
|
+
value: function ensure(obj, prop, args) {
|
55
|
+
return new Promise(function (resolve) {
|
56
|
+
var value = obj[prop];
|
57
|
+
|
58
|
+
if (typeof value === 'function') {
|
59
|
+
resolve(value.apply(obj, args));
|
60
|
+
} else {
|
61
|
+
resolve(value);
|
62
|
+
}
|
63
|
+
});
|
47
64
|
}
|
48
|
-
};
|
49
|
-
|
50
|
-
|
65
|
+
}]);
|
66
|
+
|
67
|
+
return PDFManagerMock;
|
68
|
+
}();
|
69
|
+
|
51
70
|
var pdfManagerMock, idFactoryMock;
|
52
71
|
beforeAll(function (done) {
|
53
|
-
pdfManagerMock = new PDFManagerMock({
|
54
|
-
|
72
|
+
pdfManagerMock = new PDFManagerMock({
|
73
|
+
docBaseUrl: null
|
74
|
+
});
|
75
|
+
idFactoryMock = (0, _test_utils.createIdFactory)(0);
|
55
76
|
done();
|
56
77
|
});
|
57
78
|
afterAll(function () {
|
@@ -59,61 +80,168 @@ describe('annotation', function () {
|
|
59
80
|
idFactoryMock = null;
|
60
81
|
});
|
61
82
|
describe('AnnotationFactory', function () {
|
62
|
-
it('should get id for annotation', function () {
|
83
|
+
it('should get id for annotation', function (done) {
|
63
84
|
var annotationDict = new _primitives.Dict();
|
64
85
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
65
86
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
66
|
-
|
87
|
+
|
88
|
+
var annotationRef = _primitives.Ref.get(10, 0);
|
89
|
+
|
67
90
|
var xref = new _test_utils.XRefMock([{
|
68
91
|
ref: annotationRef,
|
69
92
|
data: annotationDict
|
70
93
|
}]);
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
94
|
+
|
95
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref) {
|
96
|
+
var data = _ref.data;
|
97
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
98
|
+
expect(data.id).toEqual('10R');
|
99
|
+
done();
|
100
|
+
}, done.fail);
|
75
101
|
});
|
76
|
-
it('should handle, and get fallback
|
102
|
+
it('should handle, and get fallback IDs for, annotations that are not ' + 'indirect objects (issue 7569)', function (done) {
|
77
103
|
var annotationDict = new _primitives.Dict();
|
78
104
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
79
105
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
80
106
|
var xref = new _test_utils.XRefMock();
|
81
|
-
var idFactory =
|
82
|
-
|
83
|
-
|
107
|
+
var idFactory = (0, _test_utils.createIdFactory)(0);
|
108
|
+
|
109
|
+
var annotation1 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref2) {
|
110
|
+
var data = _ref2.data;
|
111
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
112
|
+
expect(data.id).toEqual('annot_p0_1');
|
84
113
|
});
|
85
|
-
|
86
|
-
var annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
});
|
94
|
-
it('should handle missing /Subtype', function () {
|
114
|
+
|
115
|
+
var annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref3) {
|
116
|
+
var data = _ref3.data;
|
117
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
118
|
+
expect(data.id).toEqual('annot_p0_2');
|
119
|
+
});
|
120
|
+
|
121
|
+
Promise.all([annotation1, annotation2]).then(done, done.fail);
|
122
|
+
});
|
123
|
+
it('should handle missing /Subtype', function (done) {
|
95
124
|
var annotationDict = new _primitives.Dict();
|
96
125
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
97
|
-
|
126
|
+
|
127
|
+
var annotationRef = _primitives.Ref.get(1, 0);
|
128
|
+
|
98
129
|
var xref = new _test_utils.XRefMock([{
|
99
130
|
ref: annotationRef,
|
100
131
|
data: annotationDict
|
101
132
|
}]);
|
102
|
-
|
103
|
-
|
104
|
-
|
133
|
+
|
134
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref4) {
|
135
|
+
var data = _ref4.data;
|
136
|
+
expect(data.annotationType).toBeUndefined();
|
137
|
+
done();
|
138
|
+
}, done.fail);
|
139
|
+
});
|
140
|
+
});
|
141
|
+
describe('getQuadPoints', function () {
|
142
|
+
var dict, rect;
|
143
|
+
beforeEach(function (done) {
|
144
|
+
dict = new _primitives.Dict();
|
145
|
+
rect = [];
|
146
|
+
done();
|
147
|
+
});
|
148
|
+
afterEach(function () {
|
149
|
+
dict = null;
|
150
|
+
rect = null;
|
151
|
+
});
|
152
|
+
it('should ignore missing quadpoints', function () {
|
153
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
154
|
+
});
|
155
|
+
it('should ignore non-array values', function () {
|
156
|
+
dict.set('QuadPoints', 'foo');
|
157
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
158
|
+
});
|
159
|
+
it('should ignore arrays where the length is not a multiple of eight', function () {
|
160
|
+
dict.set('QuadPoints', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
161
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
162
|
+
});
|
163
|
+
it('should ignore quadpoints if one coordinate lies outside the rectangle', function () {
|
164
|
+
rect = [10, 10, 20, 20];
|
165
|
+
var 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]];
|
166
|
+
|
167
|
+
for (var _i = 0, _inputs = inputs; _i < _inputs.length; _i++) {
|
168
|
+
var input = _inputs[_i];
|
169
|
+
dict.set('QuadPoints', input);
|
170
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual(null);
|
171
|
+
}
|
172
|
+
});
|
173
|
+
it('should process valid quadpoints arrays', function () {
|
174
|
+
rect = [10, 10, 20, 20];
|
175
|
+
dict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18]);
|
176
|
+
expect((0, _annotation.getQuadPoints)(dict, rect)).toEqual([[{
|
177
|
+
x: 11,
|
178
|
+
y: 11
|
179
|
+
}, {
|
180
|
+
x: 12,
|
181
|
+
y: 12
|
182
|
+
}, {
|
183
|
+
x: 13,
|
184
|
+
y: 13
|
185
|
+
}, {
|
186
|
+
x: 14,
|
187
|
+
y: 14
|
188
|
+
}], [{
|
189
|
+
x: 15,
|
190
|
+
y: 15
|
191
|
+
}, {
|
192
|
+
x: 16,
|
193
|
+
y: 16
|
194
|
+
}, {
|
195
|
+
x: 17,
|
196
|
+
y: 17
|
197
|
+
}, {
|
198
|
+
x: 18,
|
199
|
+
y: 18
|
200
|
+
}]]);
|
105
201
|
});
|
106
202
|
});
|
107
203
|
describe('Annotation', function () {
|
108
204
|
var dict, ref;
|
109
205
|
beforeAll(function (done) {
|
110
206
|
dict = new _primitives.Dict();
|
111
|
-
ref =
|
207
|
+
ref = _primitives.Ref.get(1, 0);
|
112
208
|
done();
|
113
209
|
});
|
114
210
|
afterAll(function () {
|
115
211
|
dict = ref = null;
|
116
212
|
});
|
213
|
+
it('should set and get valid contents', function () {
|
214
|
+
var annotation = new _annotation.Annotation({
|
215
|
+
dict: dict,
|
216
|
+
ref: ref
|
217
|
+
});
|
218
|
+
annotation.setContents('Foo bar baz');
|
219
|
+
expect(annotation.contents).toEqual('Foo bar baz');
|
220
|
+
});
|
221
|
+
it('should not set and get invalid contents', function () {
|
222
|
+
var annotation = new _annotation.Annotation({
|
223
|
+
dict: dict,
|
224
|
+
ref: ref
|
225
|
+
});
|
226
|
+
annotation.setContents(undefined);
|
227
|
+
expect(annotation.contents).toEqual('');
|
228
|
+
});
|
229
|
+
it('should set and get a valid modification date', function () {
|
230
|
+
var annotation = new _annotation.Annotation({
|
231
|
+
dict: dict,
|
232
|
+
ref: ref
|
233
|
+
});
|
234
|
+
annotation.setModificationDate('D:20190422');
|
235
|
+
expect(annotation.modificationDate).toEqual('D:20190422');
|
236
|
+
});
|
237
|
+
it('should not set and get an invalid modification date', function () {
|
238
|
+
var annotation = new _annotation.Annotation({
|
239
|
+
dict: dict,
|
240
|
+
ref: ref
|
241
|
+
});
|
242
|
+
annotation.setModificationDate(undefined);
|
243
|
+
expect(annotation.modificationDate).toEqual(null);
|
244
|
+
});
|
117
245
|
it('should set and get flags', function () {
|
118
246
|
var annotation = new _annotation.Annotation({
|
119
247
|
dict: dict,
|
@@ -155,7 +283,7 @@ describe('annotation', function () {
|
|
155
283
|
ref: ref
|
156
284
|
});
|
157
285
|
annotation.setColor('red');
|
158
|
-
expect(annotation.color).toEqual(new
|
286
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
159
287
|
});
|
160
288
|
it('should set and get a transparent color', function () {
|
161
289
|
var annotation = new _annotation.Annotation({
|
@@ -171,7 +299,7 @@ describe('annotation', function () {
|
|
171
299
|
ref: ref
|
172
300
|
});
|
173
301
|
annotation.setColor([0.4]);
|
174
|
-
expect(annotation.color).toEqual(new
|
302
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
175
303
|
});
|
176
304
|
it('should set and get an RGB color', function () {
|
177
305
|
var annotation = new _annotation.Annotation({
|
@@ -179,7 +307,7 @@ describe('annotation', function () {
|
|
179
307
|
ref: ref
|
180
308
|
});
|
181
309
|
annotation.setColor([0, 0, 1]);
|
182
|
-
expect(annotation.color).toEqual(new
|
310
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
183
311
|
});
|
184
312
|
it('should set and get a CMYK color', function () {
|
185
313
|
var annotation = new _annotation.Annotation({
|
@@ -187,7 +315,7 @@ describe('annotation', function () {
|
|
187
315
|
ref: ref
|
188
316
|
});
|
189
317
|
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
190
|
-
expect(annotation.color).toEqual(new
|
318
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
191
319
|
});
|
192
320
|
it('should not set and get an invalid color', function () {
|
193
321
|
var annotation = new _annotation.Annotation({
|
@@ -195,7 +323,7 @@ describe('annotation', function () {
|
|
195
323
|
ref: ref
|
196
324
|
});
|
197
325
|
annotation.setColor([0.4, 0.6]);
|
198
|
-
expect(annotation.color).toEqual(new
|
326
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
199
327
|
});
|
200
328
|
});
|
201
329
|
describe('AnnotationBorderStyle', function () {
|
@@ -209,6 +337,14 @@ describe('annotation', function () {
|
|
209
337
|
borderStyle.setWidth('three');
|
210
338
|
expect(borderStyle.width).toEqual(1);
|
211
339
|
});
|
340
|
+
it('should set the width to zero, when the input is a `Name` (issue 10385)', function () {
|
341
|
+
var borderStyleZero = new _annotation.AnnotationBorderStyle();
|
342
|
+
borderStyleZero.setWidth(_primitives.Name.get('0'));
|
343
|
+
var borderStyleFive = new _annotation.AnnotationBorderStyle();
|
344
|
+
borderStyleFive.setWidth(_primitives.Name.get('5'));
|
345
|
+
expect(borderStyleZero.width).toEqual(0);
|
346
|
+
expect(borderStyleFive.width).toEqual(0);
|
347
|
+
});
|
212
348
|
it('should set and get a valid style', function () {
|
213
349
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
214
350
|
borderStyle.setStyle(_primitives.Name.get('D'));
|
@@ -244,14 +380,253 @@ describe('annotation', function () {
|
|
244
380
|
borderStyle.setVerticalCornerRadius(3);
|
245
381
|
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
246
382
|
});
|
247
|
-
it('should not set and get an invalid
|
383
|
+
it('should not set and get an invalid vertical corner radius', function () {
|
248
384
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
249
385
|
borderStyle.setVerticalCornerRadius('three');
|
250
386
|
expect(borderStyle.verticalCornerRadius).toEqual(0);
|
251
387
|
});
|
252
388
|
});
|
389
|
+
describe('MarkupAnnotation', function () {
|
390
|
+
var dict, ref;
|
391
|
+
beforeAll(function (done) {
|
392
|
+
dict = new _primitives.Dict();
|
393
|
+
ref = _primitives.Ref.get(1, 0);
|
394
|
+
done();
|
395
|
+
});
|
396
|
+
afterAll(function () {
|
397
|
+
dict = ref = null;
|
398
|
+
});
|
399
|
+
it('should set and get a valid creation date', function () {
|
400
|
+
var markupAnnotation = new _annotation.MarkupAnnotation({
|
401
|
+
dict: dict,
|
402
|
+
ref: ref
|
403
|
+
});
|
404
|
+
markupAnnotation.setCreationDate('D:20190422');
|
405
|
+
expect(markupAnnotation.creationDate).toEqual('D:20190422');
|
406
|
+
});
|
407
|
+
it('should not set and get an invalid creation date', function () {
|
408
|
+
var markupAnnotation = new _annotation.MarkupAnnotation({
|
409
|
+
dict: dict,
|
410
|
+
ref: ref
|
411
|
+
});
|
412
|
+
markupAnnotation.setCreationDate(undefined);
|
413
|
+
expect(markupAnnotation.creationDate).toEqual(null);
|
414
|
+
});
|
415
|
+
it('should not parse IRT/RT when not defined', function (done) {
|
416
|
+
dict.set('Type', _primitives.Name.get('Annot'));
|
417
|
+
dict.set('Subtype', _primitives.Name.get('Text'));
|
418
|
+
var xref = new _test_utils.XRefMock([{
|
419
|
+
ref: ref,
|
420
|
+
data: dict
|
421
|
+
}]);
|
422
|
+
|
423
|
+
_annotation.AnnotationFactory.create(xref, ref, pdfManagerMock, idFactoryMock).then(function (_ref5) {
|
424
|
+
var data = _ref5.data;
|
425
|
+
expect(data.inReplyTo).toBeUndefined();
|
426
|
+
expect(data.replyType).toBeUndefined();
|
427
|
+
done();
|
428
|
+
}, done.fail);
|
429
|
+
});
|
430
|
+
it('should parse IRT and set default RT when not defined.', function (done) {
|
431
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
432
|
+
var annotationDict = new _primitives.Dict();
|
433
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
434
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
435
|
+
var replyRef = new _primitives.Ref(820, 0);
|
436
|
+
var replyDict = new _primitives.Dict();
|
437
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
438
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
439
|
+
replyDict.set('IRT', annotationRef);
|
440
|
+
var xref = new _test_utils.XRefMock([{
|
441
|
+
ref: annotationRef,
|
442
|
+
data: annotationDict
|
443
|
+
}, {
|
444
|
+
ref: replyRef,
|
445
|
+
data: replyDict
|
446
|
+
}]);
|
447
|
+
annotationDict.assignXref(xref);
|
448
|
+
replyDict.assignXref(xref);
|
449
|
+
|
450
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
|
451
|
+
var data = _ref6.data;
|
452
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
453
|
+
expect(data.replyType).toEqual('R');
|
454
|
+
done();
|
455
|
+
}, done.fail);
|
456
|
+
});
|
457
|
+
it('should parse IRT/RT for a group type', function (done) {
|
458
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
459
|
+
var annotationDict = new _primitives.Dict();
|
460
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
461
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
462
|
+
annotationDict.set('T', 'ParentTitle');
|
463
|
+
annotationDict.set('Contents', 'ParentText');
|
464
|
+
annotationDict.set('CreationDate', 'D:20180423');
|
465
|
+
annotationDict.set('M', 'D:20190423');
|
466
|
+
annotationDict.set('C', [0, 0, 1]);
|
467
|
+
var popupRef = new _primitives.Ref(820, 0);
|
468
|
+
var popupDict = new _primitives.Dict();
|
469
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
470
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
471
|
+
popupDict.set('Parent', annotationRef);
|
472
|
+
annotationDict.set('Popup', popupRef);
|
473
|
+
var replyRef = new _primitives.Ref(821, 0);
|
474
|
+
var replyDict = new _primitives.Dict();
|
475
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
476
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
477
|
+
replyDict.set('IRT', annotationRef);
|
478
|
+
replyDict.set('RT', _primitives.Name.get('Group'));
|
479
|
+
replyDict.set('T', 'ReplyTitle');
|
480
|
+
replyDict.set('Contents', 'ReplyText');
|
481
|
+
replyDict.set('CreationDate', 'D:20180523');
|
482
|
+
replyDict.set('M', 'D:20190523');
|
483
|
+
replyDict.set('C', [0.4]);
|
484
|
+
var xref = new _test_utils.XRefMock([{
|
485
|
+
ref: annotationRef,
|
486
|
+
data: annotationDict
|
487
|
+
}, {
|
488
|
+
ref: popupRef,
|
489
|
+
data: popupDict
|
490
|
+
}, {
|
491
|
+
ref: replyRef,
|
492
|
+
data: replyDict
|
493
|
+
}]);
|
494
|
+
annotationDict.assignXref(xref);
|
495
|
+
popupDict.assignXref(xref);
|
496
|
+
replyDict.assignXref(xref);
|
497
|
+
|
498
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
|
499
|
+
var data = _ref7.data;
|
500
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
501
|
+
expect(data.replyType).toEqual('Group');
|
502
|
+
expect(data.title).toEqual('ParentTitle');
|
503
|
+
expect(data.contents).toEqual('ParentText');
|
504
|
+
expect(data.creationDate).toEqual('D:20180423');
|
505
|
+
expect(data.modificationDate).toEqual('D:20190423');
|
506
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
507
|
+
expect(data.hasPopup).toEqual(true);
|
508
|
+
done();
|
509
|
+
}, done.fail);
|
510
|
+
});
|
511
|
+
it('should parse IRT/RT for a reply type', function (done) {
|
512
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
513
|
+
var annotationDict = new _primitives.Dict();
|
514
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
515
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
516
|
+
annotationDict.set('T', 'ParentTitle');
|
517
|
+
annotationDict.set('Contents', 'ParentText');
|
518
|
+
annotationDict.set('CreationDate', 'D:20180423');
|
519
|
+
annotationDict.set('M', 'D:20190423');
|
520
|
+
annotationDict.set('C', [0, 0, 1]);
|
521
|
+
var popupRef = new _primitives.Ref(820, 0);
|
522
|
+
var popupDict = new _primitives.Dict();
|
523
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
524
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
525
|
+
popupDict.set('Parent', annotationRef);
|
526
|
+
annotationDict.set('Popup', popupRef);
|
527
|
+
var replyRef = new _primitives.Ref(821, 0);
|
528
|
+
var replyDict = new _primitives.Dict();
|
529
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
530
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
531
|
+
replyDict.set('IRT', annotationRef);
|
532
|
+
replyDict.set('RT', _primitives.Name.get('R'));
|
533
|
+
replyDict.set('T', 'ReplyTitle');
|
534
|
+
replyDict.set('Contents', 'ReplyText');
|
535
|
+
replyDict.set('CreationDate', 'D:20180523');
|
536
|
+
replyDict.set('M', 'D:20190523');
|
537
|
+
replyDict.set('C', [0.4]);
|
538
|
+
var xref = new _test_utils.XRefMock([{
|
539
|
+
ref: annotationRef,
|
540
|
+
data: annotationDict
|
541
|
+
}, {
|
542
|
+
ref: popupRef,
|
543
|
+
data: popupDict
|
544
|
+
}, {
|
545
|
+
ref: replyRef,
|
546
|
+
data: replyDict
|
547
|
+
}]);
|
548
|
+
annotationDict.assignXref(xref);
|
549
|
+
popupDict.assignXref(xref);
|
550
|
+
replyDict.assignXref(xref);
|
551
|
+
|
552
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
|
553
|
+
var data = _ref8.data;
|
554
|
+
expect(data.inReplyTo).toEqual(annotationRef.toString());
|
555
|
+
expect(data.replyType).toEqual('R');
|
556
|
+
expect(data.title).toEqual('ReplyTitle');
|
557
|
+
expect(data.contents).toEqual('ReplyText');
|
558
|
+
expect(data.creationDate).toEqual('D:20180523');
|
559
|
+
expect(data.modificationDate).toEqual('D:20190523');
|
560
|
+
expect(data.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
561
|
+
expect(data.hasPopup).toEqual(false);
|
562
|
+
done();
|
563
|
+
}, done.fail);
|
564
|
+
});
|
565
|
+
});
|
566
|
+
describe('TextAnnotation', function () {
|
567
|
+
it('should not parse state model and state when not defined', function (done) {
|
568
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
569
|
+
var annotationDict = new _primitives.Dict();
|
570
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
571
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
572
|
+
annotationDict.set('Contents', 'TestText');
|
573
|
+
var replyRef = new _primitives.Ref(820, 0);
|
574
|
+
var replyDict = new _primitives.Dict();
|
575
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
576
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
577
|
+
replyDict.set('IRT', annotationRef);
|
578
|
+
replyDict.set('RT', _primitives.Name.get('R'));
|
579
|
+
replyDict.set('Contents', 'ReplyText');
|
580
|
+
var xref = new _test_utils.XRefMock([{
|
581
|
+
ref: annotationRef,
|
582
|
+
data: annotationDict
|
583
|
+
}, {
|
584
|
+
ref: replyRef,
|
585
|
+
data: replyDict
|
586
|
+
}]);
|
587
|
+
annotationDict.assignXref(xref);
|
588
|
+
replyDict.assignXref(xref);
|
589
|
+
|
590
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
|
591
|
+
var data = _ref9.data;
|
592
|
+
expect(data.stateModel).toBeNull();
|
593
|
+
expect(data.state).toBeNull();
|
594
|
+
done();
|
595
|
+
}, done.fail);
|
596
|
+
});
|
597
|
+
it('should correctly parse state model and state when defined', function (done) {
|
598
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
599
|
+
var annotationDict = new _primitives.Dict();
|
600
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
601
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
602
|
+
var replyRef = new _primitives.Ref(820, 0);
|
603
|
+
var replyDict = new _primitives.Dict();
|
604
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
605
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
606
|
+
replyDict.set('IRT', annotationRef);
|
607
|
+
replyDict.set('RT', _primitives.Name.get('R'));
|
608
|
+
replyDict.set('StateModel', 'Review');
|
609
|
+
replyDict.set('State', 'Rejected');
|
610
|
+
var xref = new _test_utils.XRefMock([{
|
611
|
+
ref: annotationRef,
|
612
|
+
data: annotationDict
|
613
|
+
}, {
|
614
|
+
ref: replyRef,
|
615
|
+
data: replyDict
|
616
|
+
}]);
|
617
|
+
annotationDict.assignXref(xref);
|
618
|
+
replyDict.assignXref(xref);
|
619
|
+
|
620
|
+
_annotation.AnnotationFactory.create(xref, replyRef, pdfManagerMock, idFactoryMock).then(function (_ref10) {
|
621
|
+
var data = _ref10.data;
|
622
|
+
expect(data.stateModel).toEqual('Review');
|
623
|
+
expect(data.state).toEqual('Rejected');
|
624
|
+
done();
|
625
|
+
}, done.fail);
|
626
|
+
});
|
627
|
+
});
|
253
628
|
describe('LinkAnnotation', function () {
|
254
|
-
it('should correctly parse a URI action', function () {
|
629
|
+
it('should correctly parse a URI action', function (done) {
|
255
630
|
var actionDict = new _primitives.Dict();
|
256
631
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
257
632
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -260,19 +635,24 @@ describe('annotation', function () {
|
|
260
635
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
261
636
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
262
637
|
annotationDict.set('A', actionDict);
|
263
|
-
|
638
|
+
|
639
|
+
var annotationRef = _primitives.Ref.get(820, 0);
|
640
|
+
|
264
641
|
var xref = new _test_utils.XRefMock([{
|
265
642
|
ref: annotationRef,
|
266
643
|
data: annotationDict
|
267
644
|
}]);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
645
|
+
|
646
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
|
647
|
+
var data = _ref11.data;
|
648
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
649
|
+
expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
650
|
+
expect(data.unsafeUrl).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
651
|
+
expect(data.dest).toBeUndefined();
|
652
|
+
done();
|
653
|
+
}, done.fail);
|
654
|
+
});
|
655
|
+
it('should correctly parse a URI action, where the URI entry ' + 'is missing a protocol', function (done) {
|
276
656
|
var actionDict = new _primitives.Dict();
|
277
657
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
278
658
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -281,40 +661,52 @@ describe('annotation', function () {
|
|
281
661
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
282
662
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
283
663
|
annotationDict.set('A', actionDict);
|
284
|
-
|
664
|
+
|
665
|
+
var annotationRef = _primitives.Ref.get(353, 0);
|
666
|
+
|
285
667
|
var xref = new _test_utils.XRefMock([{
|
286
668
|
ref: annotationRef,
|
287
669
|
data: annotationDict
|
288
670
|
}]);
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
671
|
+
|
672
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
|
673
|
+
var data = _ref12.data;
|
674
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
675
|
+
expect(data.url).toEqual('http://www.hmrc.gov.uk/');
|
676
|
+
expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk');
|
677
|
+
expect(data.dest).toBeUndefined();
|
678
|
+
done();
|
679
|
+
}, done.fail);
|
680
|
+
});
|
681
|
+
it('should correctly parse a URI action, where the URI entry ' + 'has an incorrect encoding (bug 1122280)', function (done) {
|
297
682
|
var actionStream = new _stream.StringStream('<<\n' + '/Type /Action\n' + '/S /URI\n' + '/URI (http://www.example.com/\\303\\274\\303\\266\\303\\244)\n' + '>>\n');
|
298
|
-
var
|
299
|
-
|
683
|
+
var parser = new _parser.Parser({
|
684
|
+
lexer: new _parser.Lexer(actionStream),
|
685
|
+
xref: null
|
686
|
+
});
|
300
687
|
var actionDict = parser.getObj();
|
301
688
|
var annotationDict = new _primitives.Dict();
|
302
689
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
303
690
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
304
691
|
annotationDict.set('A', actionDict);
|
305
|
-
|
692
|
+
|
693
|
+
var annotationRef = _primitives.Ref.get(8, 0);
|
694
|
+
|
306
695
|
var xref = new _test_utils.XRefMock([{
|
307
696
|
ref: annotationRef,
|
308
697
|
data: annotationDict
|
309
698
|
}]);
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
699
|
+
|
700
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref13) {
|
701
|
+
var data = _ref13.data;
|
702
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
703
|
+
expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4')).href);
|
704
|
+
expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4'));
|
705
|
+
expect(data.dest).toBeUndefined();
|
706
|
+
done();
|
707
|
+
}, done.fail);
|
708
|
+
});
|
709
|
+
it('should correctly parse a GoTo action', function (done) {
|
318
710
|
var actionDict = new _primitives.Dict();
|
319
711
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
320
712
|
actionDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -323,19 +715,24 @@ describe('annotation', function () {
|
|
323
715
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
324
716
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
325
717
|
annotationDict.set('A', actionDict);
|
326
|
-
|
718
|
+
|
719
|
+
var annotationRef = _primitives.Ref.get(798, 0);
|
720
|
+
|
327
721
|
var xref = new _test_utils.XRefMock([{
|
328
722
|
ref: annotationRef,
|
329
723
|
data: annotationDict
|
330
724
|
}]);
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
725
|
+
|
726
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
|
727
|
+
var data = _ref14.data;
|
728
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
729
|
+
expect(data.url).toBeUndefined();
|
730
|
+
expect(data.unsafeUrl).toBeUndefined();
|
731
|
+
expect(data.dest).toEqual('page.157');
|
732
|
+
done();
|
733
|
+
}, done.fail);
|
734
|
+
});
|
735
|
+
it('should correctly parse a GoToR action, where the FileSpec entry ' + 'is a string containing a relative URL', function (done) {
|
339
736
|
var actionDict = new _primitives.Dict();
|
340
737
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
341
738
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -346,20 +743,25 @@ describe('annotation', function () {
|
|
346
743
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
347
744
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
348
745
|
annotationDict.set('A', actionDict);
|
349
|
-
|
746
|
+
|
747
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
748
|
+
|
350
749
|
var xref = new _test_utils.XRefMock([{
|
351
750
|
ref: annotationRef,
|
352
751
|
data: annotationDict
|
353
752
|
}]);
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
753
|
+
|
754
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
|
755
|
+
var data = _ref15.data;
|
756
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
757
|
+
expect(data.url).toBeUndefined();
|
758
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
759
|
+
expect(data.dest).toBeUndefined();
|
760
|
+
expect(data.newWindow).toEqual(true);
|
761
|
+
done();
|
762
|
+
}, done.fail);
|
763
|
+
});
|
764
|
+
it('should correctly parse a GoToR action, containing a relative URL, ' + 'with the "docBaseUrl" parameter specified', function (done) {
|
363
765
|
var actionDict = new _primitives.Dict();
|
364
766
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
365
767
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -369,20 +771,27 @@ describe('annotation', function () {
|
|
369
771
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
370
772
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
371
773
|
annotationDict.set('A', actionDict);
|
372
|
-
|
774
|
+
|
775
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
776
|
+
|
373
777
|
var xref = new _test_utils.XRefMock([{
|
374
778
|
ref: annotationRef,
|
375
779
|
data: annotationDict
|
376
780
|
}]);
|
377
|
-
var pdfManager = new PDFManagerMock({
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
781
|
+
var pdfManager = new PDFManagerMock({
|
782
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
783
|
+
});
|
784
|
+
|
785
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref16) {
|
786
|
+
var data = _ref16.data;
|
787
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
788
|
+
expect(data.url).toEqual('http://www.example.com/0013/001346/134685E.pdf#4.3');
|
789
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
790
|
+
expect(data.dest).toBeUndefined();
|
791
|
+
done();
|
792
|
+
}, done.fail);
|
793
|
+
});
|
794
|
+
it('should correctly parse a GoToR action, with named destination', function (done) {
|
386
795
|
var actionDict = new _primitives.Dict();
|
387
796
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
388
797
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -392,20 +801,25 @@ describe('annotation', function () {
|
|
392
801
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
393
802
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
394
803
|
annotationDict.set('A', actionDict);
|
395
|
-
|
804
|
+
|
805
|
+
var annotationRef = _primitives.Ref.get(495, 0);
|
806
|
+
|
396
807
|
var xref = new _test_utils.XRefMock([{
|
397
808
|
ref: annotationRef,
|
398
809
|
data: annotationDict
|
399
810
|
}]);
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
811
|
+
|
812
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
|
813
|
+
var data = _ref17.data;
|
814
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
815
|
+
expect(data.url).toEqual('http://www.example.com/test.pdf#15');
|
816
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#15');
|
817
|
+
expect(data.dest).toBeUndefined();
|
818
|
+
expect(data.newWindow).toBeFalsy();
|
819
|
+
done();
|
820
|
+
}, done.fail);
|
821
|
+
});
|
822
|
+
it('should correctly parse a GoToR action, with explicit destination array', function (done) {
|
409
823
|
var actionDict = new _primitives.Dict();
|
410
824
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
411
825
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -415,20 +829,25 @@ describe('annotation', function () {
|
|
415
829
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
416
830
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
417
831
|
annotationDict.set('A', actionDict);
|
418
|
-
|
832
|
+
|
833
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
834
|
+
|
419
835
|
var xref = new _test_utils.XRefMock([{
|
420
836
|
ref: annotationRef,
|
421
837
|
data: annotationDict
|
422
838
|
}]);
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
839
|
+
|
840
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
|
841
|
+
var data = _ref18.data;
|
842
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
843
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]').href);
|
844
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]');
|
845
|
+
expect(data.dest).toBeUndefined();
|
846
|
+
expect(data.newWindow).toBeFalsy();
|
847
|
+
done();
|
848
|
+
}, done.fail);
|
849
|
+
});
|
850
|
+
it('should correctly parse a Launch action, where the FileSpec dict ' + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
|
432
851
|
var fileSpecDict = new _primitives.Dict();
|
433
852
|
fileSpecDict.set('Type', _primitives.Name.get('FileSpec'));
|
434
853
|
fileSpecDict.set('F', 'Part II/Part II.pdf');
|
@@ -442,21 +861,28 @@ describe('annotation', function () {
|
|
442
861
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
443
862
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
444
863
|
annotationDict.set('A', actionDict);
|
445
|
-
|
864
|
+
|
865
|
+
var annotationRef = _primitives.Ref.get(88, 0);
|
866
|
+
|
446
867
|
var xref = new _test_utils.XRefMock([{
|
447
868
|
ref: annotationRef,
|
448
869
|
data: annotationDict
|
449
870
|
}]);
|
450
|
-
var pdfManager = new PDFManagerMock({
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
871
|
+
var pdfManager = new PDFManagerMock({
|
872
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
873
|
+
});
|
874
|
+
|
875
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref19) {
|
876
|
+
var data = _ref19.data;
|
877
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
878
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
|
879
|
+
expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
|
880
|
+
expect(data.dest).toBeUndefined();
|
881
|
+
expect(data.newWindow).toEqual(true);
|
882
|
+
done();
|
883
|
+
}, done.fail);
|
884
|
+
});
|
885
|
+
it('should recover valid URLs from JavaScript actions having certain ' + 'white-listed formats', function (done) {
|
460
886
|
function checkJsAction(params) {
|
461
887
|
var jsEntry = params.jsEntry;
|
462
888
|
var expectedUrl = params.expectedUrl;
|
@@ -470,39 +896,44 @@ describe('annotation', function () {
|
|
470
896
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
471
897
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
472
898
|
annotationDict.set('A', actionDict);
|
473
|
-
|
899
|
+
|
900
|
+
var annotationRef = _primitives.Ref.get(46, 0);
|
901
|
+
|
474
902
|
var xref = new _test_utils.XRefMock([{
|
475
903
|
ref: annotationRef,
|
476
904
|
data: annotationDict
|
477
905
|
}]);
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
906
|
+
return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
|
907
|
+
var data = _ref20.data;
|
908
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
909
|
+
expect(data.url).toEqual(expectedUrl);
|
910
|
+
expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
|
911
|
+
expect(data.dest).toBeUndefined();
|
912
|
+
expect(data.newWindow).toEqual(expectedNewWindow);
|
913
|
+
});
|
485
914
|
}
|
486
|
-
|
915
|
+
|
916
|
+
var annotation1 = checkJsAction({
|
487
917
|
jsEntry: 'function someFun() { return "qwerty"; } someFun();',
|
488
918
|
expectedUrl: undefined,
|
489
919
|
expectedUnsafeUrl: undefined,
|
490
920
|
expectedNewWindow: undefined
|
491
921
|
});
|
492
|
-
checkJsAction({
|
922
|
+
var annotation2 = checkJsAction({
|
493
923
|
jsEntry: 'window.open(\'http://www.example.com/test.pdf\')',
|
494
924
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
495
925
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
496
926
|
expectedNewWindow: undefined
|
497
927
|
});
|
498
|
-
checkJsAction({
|
928
|
+
var annotation3 = checkJsAction({
|
499
929
|
jsEntry: new _stream.StringStream('app.launchURL("http://www.example.com/test.pdf", true)'),
|
500
930
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
501
931
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
502
932
|
expectedNewWindow: true
|
503
933
|
});
|
934
|
+
Promise.all([annotation1, annotation2, annotation3]).then(done, done.fail);
|
504
935
|
});
|
505
|
-
it('should correctly parse a Named action', function () {
|
936
|
+
it('should correctly parse a Named action', function (done) {
|
506
937
|
var actionDict = new _primitives.Dict();
|
507
938
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
508
939
|
actionDict.set('S', _primitives.Name.get('Named'));
|
@@ -511,56 +942,73 @@ describe('annotation', function () {
|
|
511
942
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
512
943
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
513
944
|
annotationDict.set('A', actionDict);
|
514
|
-
|
945
|
+
|
946
|
+
var annotationRef = _primitives.Ref.get(12, 0);
|
947
|
+
|
515
948
|
var xref = new _test_utils.XRefMock([{
|
516
949
|
ref: annotationRef,
|
517
950
|
data: annotationDict
|
518
951
|
}]);
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
952
|
+
|
953
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
|
954
|
+
var data = _ref21.data;
|
955
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
956
|
+
expect(data.url).toBeUndefined();
|
957
|
+
expect(data.unsafeUrl).toBeUndefined();
|
958
|
+
expect(data.action).toEqual('GoToPage');
|
959
|
+
done();
|
960
|
+
}, done.fail);
|
961
|
+
});
|
962
|
+
it('should correctly parse a simple Dest', function (done) {
|
527
963
|
var annotationDict = new _primitives.Dict();
|
528
964
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
529
965
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
530
966
|
annotationDict.set('Dest', _primitives.Name.get('LI0'));
|
531
|
-
|
967
|
+
|
968
|
+
var annotationRef = _primitives.Ref.get(583, 0);
|
969
|
+
|
532
970
|
var xref = new _test_utils.XRefMock([{
|
533
971
|
ref: annotationRef,
|
534
972
|
data: annotationDict
|
535
973
|
}]);
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
974
|
+
|
975
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
|
976
|
+
var data = _ref22.data;
|
977
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
978
|
+
expect(data.url).toBeUndefined();
|
979
|
+
expect(data.unsafeUrl).toBeUndefined();
|
980
|
+
expect(data.dest).toEqual('LI0');
|
981
|
+
done();
|
982
|
+
}, done.fail);
|
983
|
+
});
|
984
|
+
it('should correctly parse a simple Dest, with explicit destination array', function (done) {
|
544
985
|
var annotationDict = new _primitives.Dict();
|
545
986
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
546
987
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
547
|
-
annotationDict.set('Dest', [
|
548
|
-
|
988
|
+
annotationDict.set('Dest', [_primitives.Ref.get(17, 0), _primitives.Name.get('XYZ'), 0, 841.89, null]);
|
989
|
+
|
990
|
+
var annotationRef = _primitives.Ref.get(10, 0);
|
991
|
+
|
549
992
|
var xref = new _test_utils.XRefMock([{
|
550
993
|
ref: annotationRef,
|
551
994
|
data: annotationDict
|
552
995
|
}]);
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
996
|
+
|
997
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
|
998
|
+
var data = _ref23.data;
|
999
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1000
|
+
expect(data.url).toBeUndefined();
|
1001
|
+
expect(data.unsafeUrl).toBeUndefined();
|
1002
|
+
expect(data.dest).toEqual([{
|
1003
|
+
num: 17,
|
1004
|
+
gen: 0
|
1005
|
+
}, {
|
1006
|
+
name: 'XYZ'
|
1007
|
+
}, 0, 841.89, null]);
|
1008
|
+
done();
|
1009
|
+
}, done.fail);
|
1010
|
+
});
|
1011
|
+
it('should correctly parse a Dest, which violates the specification ' + 'by containing a dictionary', function (done) {
|
564
1012
|
var destDict = new _primitives.Dict();
|
565
1013
|
destDict.set('Type', _primitives.Name.get('Action'));
|
566
1014
|
destDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -569,17 +1017,74 @@ describe('annotation', function () {
|
|
569
1017
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
570
1018
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
571
1019
|
annotationDict.set('Dest', destDict);
|
572
|
-
|
1020
|
+
|
1021
|
+
var annotationRef = _primitives.Ref.get(798, 0);
|
1022
|
+
|
573
1023
|
var xref = new _test_utils.XRefMock([{
|
574
1024
|
ref: annotationRef,
|
575
1025
|
data: annotationDict
|
576
1026
|
}]);
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
1027
|
+
|
1028
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
|
1029
|
+
var data = _ref24.data;
|
1030
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1031
|
+
expect(data.url).toBeUndefined();
|
1032
|
+
expect(data.unsafeUrl).toBeUndefined();
|
1033
|
+
expect(data.dest).toEqual('page.157');
|
1034
|
+
done();
|
1035
|
+
}, done.fail);
|
1036
|
+
});
|
1037
|
+
it('should not set quadpoints if not defined', function (done) {
|
1038
|
+
var annotationDict = new _primitives.Dict();
|
1039
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
1040
|
+
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
1041
|
+
|
1042
|
+
var annotationRef = _primitives.Ref.get(121, 0);
|
1043
|
+
|
1044
|
+
var xref = new _test_utils.XRefMock([{
|
1045
|
+
ref: annotationRef,
|
1046
|
+
data: annotationDict
|
1047
|
+
}]);
|
1048
|
+
|
1049
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
|
1050
|
+
var data = _ref25.data;
|
1051
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1052
|
+
expect(data.quadPoints).toBeUndefined();
|
1053
|
+
done();
|
1054
|
+
}, done.fail);
|
1055
|
+
});
|
1056
|
+
it('should set quadpoints if defined', function (done) {
|
1057
|
+
var annotationDict = new _primitives.Dict();
|
1058
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
1059
|
+
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
1060
|
+
annotationDict.set('Rect', [10, 10, 20, 20]);
|
1061
|
+
annotationDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
|
1062
|
+
|
1063
|
+
var annotationRef = _primitives.Ref.get(121, 0);
|
1064
|
+
|
1065
|
+
var xref = new _test_utils.XRefMock([{
|
1066
|
+
ref: annotationRef,
|
1067
|
+
data: annotationDict
|
1068
|
+
}]);
|
1069
|
+
|
1070
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
|
1071
|
+
var data = _ref26.data;
|
1072
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
1073
|
+
expect(data.quadPoints).toEqual([[{
|
1074
|
+
x: 11,
|
1075
|
+
y: 11
|
1076
|
+
}, {
|
1077
|
+
x: 12,
|
1078
|
+
y: 12
|
1079
|
+
}, {
|
1080
|
+
x: 13,
|
1081
|
+
y: 13
|
1082
|
+
}, {
|
1083
|
+
x: 14,
|
1084
|
+
y: 14
|
1085
|
+
}]]);
|
1086
|
+
done();
|
1087
|
+
}, done.fail);
|
583
1088
|
});
|
584
1089
|
});
|
585
1090
|
describe('WidgetAnnotation', function () {
|
@@ -593,30 +1098,39 @@ describe('annotation', function () {
|
|
593
1098
|
afterEach(function () {
|
594
1099
|
widgetDict = null;
|
595
1100
|
});
|
596
|
-
it('should handle unknown field names', function () {
|
597
|
-
var widgetRef =
|
1101
|
+
it('should handle unknown field names', function (done) {
|
1102
|
+
var widgetRef = _primitives.Ref.get(20, 0);
|
1103
|
+
|
598
1104
|
var xref = new _test_utils.XRefMock([{
|
599
1105
|
ref: widgetRef,
|
600
1106
|
data: widgetDict
|
601
1107
|
}]);
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
1108
|
+
|
1109
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
|
1110
|
+
var data = _ref27.data;
|
1111
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1112
|
+
expect(data.fieldName).toEqual('');
|
1113
|
+
done();
|
1114
|
+
}, done.fail);
|
606
1115
|
});
|
607
|
-
it('should construct the field name when there are no ancestors', function () {
|
1116
|
+
it('should construct the field name when there are no ancestors', function (done) {
|
608
1117
|
widgetDict.set('T', 'foo');
|
609
|
-
|
1118
|
+
|
1119
|
+
var widgetRef = _primitives.Ref.get(21, 0);
|
1120
|
+
|
610
1121
|
var xref = new _test_utils.XRefMock([{
|
611
1122
|
ref: widgetRef,
|
612
1123
|
data: widgetDict
|
613
1124
|
}]);
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
1125
|
+
|
1126
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
|
1127
|
+
var data = _ref28.data;
|
1128
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1129
|
+
expect(data.fieldName).toEqual('foo');
|
1130
|
+
done();
|
1131
|
+
}, done.fail);
|
618
1132
|
});
|
619
|
-
it('should construct the field name when there are ancestors', function () {
|
1133
|
+
it('should construct the field name when there are ancestors', function (done) {
|
620
1134
|
var firstParent = new _primitives.Dict();
|
621
1135
|
firstParent.set('T', 'foo');
|
622
1136
|
var secondParent = new _primitives.Dict();
|
@@ -624,31 +1138,41 @@ describe('annotation', function () {
|
|
624
1138
|
secondParent.set('T', 'bar');
|
625
1139
|
widgetDict.set('Parent', secondParent);
|
626
1140
|
widgetDict.set('T', 'baz');
|
627
|
-
|
1141
|
+
|
1142
|
+
var widgetRef = _primitives.Ref.get(22, 0);
|
1143
|
+
|
628
1144
|
var xref = new _test_utils.XRefMock([{
|
629
1145
|
ref: widgetRef,
|
630
1146
|
data: widgetDict
|
631
1147
|
}]);
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
1148
|
+
|
1149
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
|
1150
|
+
var data = _ref29.data;
|
1151
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1152
|
+
expect(data.fieldName).toEqual('foo.bar.baz');
|
1153
|
+
done();
|
1154
|
+
}, done.fail);
|
636
1155
|
});
|
637
|
-
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function () {
|
1156
|
+
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function (done) {
|
638
1157
|
var parentDict = new _primitives.Dict();
|
639
1158
|
parentDict.set('Parent', null);
|
640
1159
|
parentDict.set('T', 'foo');
|
641
1160
|
widgetDict.set('Parent', parentDict);
|
642
1161
|
widgetDict.set('T', 'bar');
|
643
|
-
|
1162
|
+
|
1163
|
+
var widgetRef = _primitives.Ref.get(22, 0);
|
1164
|
+
|
644
1165
|
var xref = new _test_utils.XRefMock([{
|
645
1166
|
ref: widgetRef,
|
646
1167
|
data: widgetDict
|
647
1168
|
}]);
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
1169
|
+
|
1170
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
|
1171
|
+
var data = _ref30.data;
|
1172
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1173
|
+
expect(data.fieldName).toEqual('foo.bar');
|
1174
|
+
done();
|
1175
|
+
}, done.fail);
|
652
1176
|
});
|
653
1177
|
});
|
654
1178
|
describe('TextWidgetAnnotation', function () {
|
@@ -663,101 +1187,135 @@ describe('annotation', function () {
|
|
663
1187
|
afterEach(function () {
|
664
1188
|
textWidgetDict = null;
|
665
1189
|
});
|
666
|
-
it('should handle unknown text alignment, maximum length and flags', function () {
|
667
|
-
var textWidgetRef =
|
1190
|
+
it('should handle unknown text alignment, maximum length and flags', function (done) {
|
1191
|
+
var textWidgetRef = _primitives.Ref.get(124, 0);
|
1192
|
+
|
668
1193
|
var xref = new _test_utils.XRefMock([{
|
669
1194
|
ref: textWidgetRef,
|
670
1195
|
data: textWidgetDict
|
671
1196
|
}]);
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
1197
|
+
|
1198
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
|
1199
|
+
var data = _ref31.data;
|
1200
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1201
|
+
expect(data.textAlignment).toEqual(null);
|
1202
|
+
expect(data.maxLen).toEqual(null);
|
1203
|
+
expect(data.readOnly).toEqual(false);
|
1204
|
+
expect(data.multiLine).toEqual(false);
|
1205
|
+
expect(data.comb).toEqual(false);
|
1206
|
+
done();
|
1207
|
+
}, done.fail);
|
1208
|
+
});
|
1209
|
+
it('should not set invalid text alignment, maximum length and flags', function (done) {
|
682
1210
|
textWidgetDict.set('Q', 'center');
|
683
1211
|
textWidgetDict.set('MaxLen', 'five');
|
684
1212
|
textWidgetDict.set('Ff', 'readonly');
|
685
|
-
|
1213
|
+
|
1214
|
+
var textWidgetRef = _primitives.Ref.get(43, 0);
|
1215
|
+
|
686
1216
|
var xref = new _test_utils.XRefMock([{
|
687
1217
|
ref: textWidgetRef,
|
688
1218
|
data: textWidgetDict
|
689
1219
|
}]);
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
1220
|
+
|
1221
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
|
1222
|
+
var data = _ref32.data;
|
1223
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1224
|
+
expect(data.textAlignment).toEqual(null);
|
1225
|
+
expect(data.maxLen).toEqual(null);
|
1226
|
+
expect(data.readOnly).toEqual(false);
|
1227
|
+
expect(data.multiLine).toEqual(false);
|
1228
|
+
expect(data.comb).toEqual(false);
|
1229
|
+
done();
|
1230
|
+
}, done.fail);
|
1231
|
+
});
|
1232
|
+
it('should set valid text alignment, maximum length and flags', function (done) {
|
700
1233
|
textWidgetDict.set('Q', 1);
|
701
1234
|
textWidgetDict.set('MaxLen', 20);
|
702
1235
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
|
703
|
-
|
1236
|
+
|
1237
|
+
var textWidgetRef = _primitives.Ref.get(84, 0);
|
1238
|
+
|
704
1239
|
var xref = new _test_utils.XRefMock([{
|
705
1240
|
ref: textWidgetRef,
|
706
1241
|
data: textWidgetDict
|
707
1242
|
}]);
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
1243
|
+
|
1244
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
|
1245
|
+
var data = _ref33.data;
|
1246
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1247
|
+
expect(data.textAlignment).toEqual(1);
|
1248
|
+
expect(data.maxLen).toEqual(20);
|
1249
|
+
expect(data.readOnly).toEqual(true);
|
1250
|
+
expect(data.multiLine).toEqual(true);
|
1251
|
+
done();
|
1252
|
+
}, done.fail);
|
1253
|
+
});
|
1254
|
+
it('should reject comb fields without a maximum length', function (done) {
|
717
1255
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
718
|
-
|
1256
|
+
|
1257
|
+
var textWidgetRef = _primitives.Ref.get(46, 0);
|
1258
|
+
|
719
1259
|
var xref = new _test_utils.XRefMock([{
|
720
1260
|
ref: textWidgetRef,
|
721
1261
|
data: textWidgetDict
|
722
1262
|
}]);
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
1263
|
+
|
1264
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
|
1265
|
+
var data = _ref34.data;
|
1266
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1267
|
+
expect(data.comb).toEqual(false);
|
1268
|
+
done();
|
1269
|
+
}, done.fail);
|
727
1270
|
});
|
728
|
-
it('should accept comb fields with a maximum length', function () {
|
1271
|
+
it('should accept comb fields with a maximum length', function (done) {
|
729
1272
|
textWidgetDict.set('MaxLen', 20);
|
730
1273
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
731
|
-
|
1274
|
+
|
1275
|
+
var textWidgetRef = _primitives.Ref.get(46, 0);
|
1276
|
+
|
732
1277
|
var xref = new _test_utils.XRefMock([{
|
733
1278
|
ref: textWidgetRef,
|
734
1279
|
data: textWidgetDict
|
735
1280
|
}]);
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
1281
|
+
|
1282
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
|
1283
|
+
var data = _ref35.data;
|
1284
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1285
|
+
expect(data.comb).toEqual(true);
|
1286
|
+
done();
|
1287
|
+
}, done.fail);
|
740
1288
|
});
|
741
|
-
it('should only accept comb fields when the flags are valid', function () {
|
1289
|
+
it('should only accept comb fields when the flags are valid', function (done) {
|
742
1290
|
var invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
|
743
1291
|
var flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
|
1292
|
+
var promise = Promise.resolve();
|
1293
|
+
|
744
1294
|
for (var i = 0, ii = invalidFieldFlags.length; i <= ii; i++) {
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
1295
|
+
promise = promise.then(function () {
|
1296
|
+
textWidgetDict.set('MaxLen', 20);
|
1297
|
+
textWidgetDict.set('Ff', flags);
|
1298
|
+
|
1299
|
+
var textWidgetRef = _primitives.Ref.get(93, 0);
|
1300
|
+
|
1301
|
+
var xref = new _test_utils.XRefMock([{
|
1302
|
+
ref: textWidgetRef,
|
1303
|
+
data: textWidgetDict
|
1304
|
+
}]);
|
1305
|
+
return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
|
1306
|
+
var data = _ref36.data;
|
1307
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1308
|
+
var valid = invalidFieldFlags.length === 0;
|
1309
|
+
expect(data.comb).toEqual(valid);
|
1310
|
+
|
1311
|
+
if (!valid) {
|
1312
|
+
flags -= invalidFieldFlags.pop();
|
1313
|
+
}
|
1314
|
+
});
|
1315
|
+
});
|
760
1316
|
}
|
1317
|
+
|
1318
|
+
promise.then(done, done.fail);
|
761
1319
|
});
|
762
1320
|
});
|
763
1321
|
describe('ButtonWidgetAnnotation', function () {
|
@@ -772,21 +1330,52 @@ describe('annotation', function () {
|
|
772
1330
|
afterEach(function () {
|
773
1331
|
buttonWidgetDict = null;
|
774
1332
|
});
|
775
|
-
it('should handle checkboxes', function () {
|
1333
|
+
it('should handle checkboxes with export value', function (done) {
|
1334
|
+
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
1335
|
+
var appearanceStatesDict = new _primitives.Dict();
|
1336
|
+
var exportValueOptionsDict = new _primitives.Dict();
|
1337
|
+
exportValueOptionsDict.set('Off', 0);
|
1338
|
+
exportValueOptionsDict.set('Checked', 1);
|
1339
|
+
appearanceStatesDict.set('D', exportValueOptionsDict);
|
1340
|
+
buttonWidgetDict.set('AP', appearanceStatesDict);
|
1341
|
+
|
1342
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1343
|
+
|
1344
|
+
var xref = new _test_utils.XRefMock([{
|
1345
|
+
ref: buttonWidgetRef,
|
1346
|
+
data: buttonWidgetDict
|
1347
|
+
}]);
|
1348
|
+
|
1349
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
|
1350
|
+
var data = _ref37.data;
|
1351
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1352
|
+
expect(data.checkBox).toEqual(true);
|
1353
|
+
expect(data.fieldValue).toEqual('1');
|
1354
|
+
expect(data.radioButton).toEqual(false);
|
1355
|
+
expect(data.exportValue).toEqual('Checked');
|
1356
|
+
done();
|
1357
|
+
}, done.fail);
|
1358
|
+
});
|
1359
|
+
it('should handle checkboxes without export value', function (done) {
|
776
1360
|
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
777
|
-
|
1361
|
+
|
1362
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1363
|
+
|
778
1364
|
var xref = new _test_utils.XRefMock([{
|
779
1365
|
ref: buttonWidgetRef,
|
780
1366
|
data: buttonWidgetDict
|
781
1367
|
}]);
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
1368
|
+
|
1369
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
|
1370
|
+
var data = _ref38.data;
|
1371
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1372
|
+
expect(data.checkBox).toEqual(true);
|
1373
|
+
expect(data.fieldValue).toEqual('1');
|
1374
|
+
expect(data.radioButton).toEqual(false);
|
1375
|
+
done();
|
1376
|
+
}, done.fail);
|
1377
|
+
});
|
1378
|
+
it('should handle radio buttons with a field value', function (done) {
|
790
1379
|
var parentDict = new _primitives.Dict();
|
791
1380
|
parentDict.set('V', _primitives.Name.get('1'));
|
792
1381
|
var normalAppearanceStateDict = new _primitives.Dict();
|
@@ -796,38 +1385,48 @@ describe('annotation', function () {
|
|
796
1385
|
buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
|
797
1386
|
buttonWidgetDict.set('Parent', parentDict);
|
798
1387
|
buttonWidgetDict.set('AP', appearanceStatesDict);
|
799
|
-
|
1388
|
+
|
1389
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1390
|
+
|
800
1391
|
var xref = new _test_utils.XRefMock([{
|
801
1392
|
ref: buttonWidgetRef,
|
802
1393
|
data: buttonWidgetDict
|
803
1394
|
}]);
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
1395
|
+
|
1396
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
|
1397
|
+
var data = _ref39.data;
|
1398
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1399
|
+
expect(data.checkBox).toEqual(false);
|
1400
|
+
expect(data.radioButton).toEqual(true);
|
1401
|
+
expect(data.fieldValue).toEqual('1');
|
1402
|
+
expect(data.buttonValue).toEqual('2');
|
1403
|
+
done();
|
1404
|
+
}, done.fail);
|
1405
|
+
});
|
1406
|
+
it('should handle radio buttons without a field value', function (done) {
|
813
1407
|
var normalAppearanceStateDict = new _primitives.Dict();
|
814
1408
|
normalAppearanceStateDict.set('2', null);
|
815
1409
|
var appearanceStatesDict = new _primitives.Dict();
|
816
1410
|
appearanceStatesDict.set('N', normalAppearanceStateDict);
|
817
1411
|
buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
|
818
1412
|
buttonWidgetDict.set('AP', appearanceStatesDict);
|
819
|
-
|
1413
|
+
|
1414
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1415
|
+
|
820
1416
|
var xref = new _test_utils.XRefMock([{
|
821
1417
|
ref: buttonWidgetRef,
|
822
1418
|
data: buttonWidgetDict
|
823
1419
|
}]);
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
1420
|
+
|
1421
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
|
1422
|
+
var data = _ref40.data;
|
1423
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1424
|
+
expect(data.checkBox).toEqual(false);
|
1425
|
+
expect(data.radioButton).toEqual(true);
|
1426
|
+
expect(data.fieldValue).toEqual(null);
|
1427
|
+
expect(data.buttonValue).toEqual('2');
|
1428
|
+
done();
|
1429
|
+
}, done.fail);
|
831
1430
|
});
|
832
1431
|
});
|
833
1432
|
describe('ChoiceWidgetAnnotation', function () {
|
@@ -842,21 +1441,28 @@ describe('annotation', function () {
|
|
842
1441
|
afterEach(function () {
|
843
1442
|
choiceWidgetDict = null;
|
844
1443
|
});
|
845
|
-
it('should handle missing option arrays', function () {
|
846
|
-
var choiceWidgetRef =
|
1444
|
+
it('should handle missing option arrays', function (done) {
|
1445
|
+
var choiceWidgetRef = _primitives.Ref.get(122, 0);
|
1446
|
+
|
847
1447
|
var xref = new _test_utils.XRefMock([{
|
848
1448
|
ref: choiceWidgetRef,
|
849
1449
|
data: choiceWidgetDict
|
850
1450
|
}]);
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
1451
|
+
|
1452
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
|
1453
|
+
var data = _ref41.data;
|
1454
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1455
|
+
expect(data.options).toEqual([]);
|
1456
|
+
done();
|
1457
|
+
}, done.fail);
|
855
1458
|
});
|
856
|
-
it('should handle option arrays with array elements', function () {
|
857
|
-
var optionBarRef =
|
1459
|
+
it('should handle option arrays with array elements', function (done) {
|
1460
|
+
var optionBarRef = _primitives.Ref.get(20, 0);
|
1461
|
+
|
858
1462
|
var optionBarStr = 'Bar';
|
859
|
-
|
1463
|
+
|
1464
|
+
var optionOneRef = _primitives.Ref.get(10, 0);
|
1465
|
+
|
860
1466
|
var optionOneArr = ['bar_export', optionBarRef];
|
861
1467
|
var options = [['foo_export', 'Foo'], optionOneRef];
|
862
1468
|
var expected = [{
|
@@ -867,7 +1473,9 @@ describe('annotation', function () {
|
|
867
1473
|
displayValue: 'Bar'
|
868
1474
|
}];
|
869
1475
|
choiceWidgetDict.set('Opt', options);
|
870
|
-
|
1476
|
+
|
1477
|
+
var choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1478
|
+
|
871
1479
|
var xref = new _test_utils.XRefMock([{
|
872
1480
|
ref: choiceWidgetRef,
|
873
1481
|
data: choiceWidgetDict
|
@@ -878,13 +1486,17 @@ describe('annotation', function () {
|
|
878
1486
|
ref: optionOneRef,
|
879
1487
|
data: optionOneArr
|
880
1488
|
}]);
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
1489
|
+
|
1490
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
|
1491
|
+
var data = _ref42.data;
|
1492
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1493
|
+
expect(data.options).toEqual(expected);
|
1494
|
+
done();
|
1495
|
+
}, done.fail);
|
885
1496
|
});
|
886
|
-
it('should handle option arrays with string elements', function () {
|
887
|
-
var optionBarRef =
|
1497
|
+
it('should handle option arrays with string elements', function (done) {
|
1498
|
+
var optionBarRef = _primitives.Ref.get(10, 0);
|
1499
|
+
|
888
1500
|
var optionBarStr = 'Bar';
|
889
1501
|
var options = ['Foo', optionBarRef];
|
890
1502
|
var expected = [{
|
@@ -895,7 +1507,9 @@ describe('annotation', function () {
|
|
895
1507
|
displayValue: 'Bar'
|
896
1508
|
}];
|
897
1509
|
choiceWidgetDict.set('Opt', options);
|
898
|
-
|
1510
|
+
|
1511
|
+
var choiceWidgetRef = _primitives.Ref.get(981, 0);
|
1512
|
+
|
899
1513
|
var xref = new _test_utils.XRefMock([{
|
900
1514
|
ref: choiceWidgetRef,
|
901
1515
|
data: choiceWidgetDict
|
@@ -903,12 +1517,15 @@ describe('annotation', function () {
|
|
903
1517
|
ref: optionBarRef,
|
904
1518
|
data: optionBarStr
|
905
1519
|
}]);
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
1520
|
+
|
1521
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
|
1522
|
+
var data = _ref43.data;
|
1523
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1524
|
+
expect(data.options).toEqual(expected);
|
1525
|
+
done();
|
1526
|
+
}, done.fail);
|
910
1527
|
});
|
911
|
-
it('should handle inherited option arrays (issue 8094)', function () {
|
1528
|
+
it('should handle inherited option arrays (issue 8094)', function (done) {
|
912
1529
|
var options = [['Value1', 'Description1'], ['Value2', 'Description2']];
|
913
1530
|
var expected = [{
|
914
1531
|
exportValue: 'Value1',
|
@@ -920,134 +1537,182 @@ describe('annotation', function () {
|
|
920
1537
|
var parentDict = new _primitives.Dict();
|
921
1538
|
parentDict.set('Opt', options);
|
922
1539
|
choiceWidgetDict.set('Parent', parentDict);
|
923
|
-
|
1540
|
+
|
1541
|
+
var choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1542
|
+
|
924
1543
|
var xref = new _test_utils.XRefMock([{
|
925
1544
|
ref: choiceWidgetRef,
|
926
1545
|
data: choiceWidgetDict
|
927
1546
|
}]);
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
1547
|
+
|
1548
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
|
1549
|
+
var data = _ref44.data;
|
1550
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1551
|
+
expect(data.options).toEqual(expected);
|
1552
|
+
done();
|
1553
|
+
}, done.fail);
|
932
1554
|
});
|
933
|
-
it('should sanitize display values in option arrays (issue 8947)', function () {
|
1555
|
+
it('should sanitize display values in option arrays (issue 8947)', function (done) {
|
934
1556
|
var options = ['\xFE\xFF\x00F\x00o\x00o'];
|
935
1557
|
var expected = [{
|
936
1558
|
exportValue: '\xFE\xFF\x00F\x00o\x00o',
|
937
1559
|
displayValue: 'Foo'
|
938
1560
|
}];
|
939
1561
|
choiceWidgetDict.set('Opt', options);
|
940
|
-
|
1562
|
+
|
1563
|
+
var choiceWidgetRef = _primitives.Ref.get(984, 0);
|
1564
|
+
|
941
1565
|
var xref = new _test_utils.XRefMock([{
|
942
1566
|
ref: choiceWidgetRef,
|
943
1567
|
data: choiceWidgetDict
|
944
1568
|
}]);
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
1569
|
+
|
1570
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
|
1571
|
+
var data = _ref45.data;
|
1572
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1573
|
+
expect(data.options).toEqual(expected);
|
1574
|
+
done();
|
1575
|
+
}, done.fail);
|
949
1576
|
});
|
950
|
-
it('should handle array field values', function () {
|
1577
|
+
it('should handle array field values', function (done) {
|
951
1578
|
var fieldValue = ['Foo', 'Bar'];
|
952
1579
|
choiceWidgetDict.set('V', fieldValue);
|
953
|
-
|
1580
|
+
|
1581
|
+
var choiceWidgetRef = _primitives.Ref.get(968, 0);
|
1582
|
+
|
954
1583
|
var xref = new _test_utils.XRefMock([{
|
955
1584
|
ref: choiceWidgetRef,
|
956
1585
|
data: choiceWidgetDict
|
957
1586
|
}]);
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
1587
|
+
|
1588
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
|
1589
|
+
var data = _ref46.data;
|
1590
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1591
|
+
expect(data.fieldValue).toEqual(fieldValue);
|
1592
|
+
done();
|
1593
|
+
}, done.fail);
|
962
1594
|
});
|
963
|
-
it('should handle string field values', function () {
|
1595
|
+
it('should handle string field values', function (done) {
|
964
1596
|
var fieldValue = 'Foo';
|
965
1597
|
choiceWidgetDict.set('V', fieldValue);
|
966
|
-
|
1598
|
+
|
1599
|
+
var choiceWidgetRef = _primitives.Ref.get(978, 0);
|
1600
|
+
|
967
1601
|
var xref = new _test_utils.XRefMock([{
|
968
1602
|
ref: choiceWidgetRef,
|
969
1603
|
data: choiceWidgetDict
|
970
1604
|
}]);
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1605
|
+
|
1606
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
|
1607
|
+
var data = _ref47.data;
|
1608
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1609
|
+
expect(data.fieldValue).toEqual([fieldValue]);
|
1610
|
+
done();
|
1611
|
+
}, done.fail);
|
975
1612
|
});
|
976
|
-
it('should handle unknown flags', function () {
|
977
|
-
var choiceWidgetRef =
|
1613
|
+
it('should handle unknown flags', function (done) {
|
1614
|
+
var choiceWidgetRef = _primitives.Ref.get(166, 0);
|
1615
|
+
|
978
1616
|
var xref = new _test_utils.XRefMock([{
|
979
1617
|
ref: choiceWidgetRef,
|
980
1618
|
data: choiceWidgetDict
|
981
1619
|
}]);
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
1620
|
+
|
1621
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref48) {
|
1622
|
+
var data = _ref48.data;
|
1623
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1624
|
+
expect(data.readOnly).toEqual(false);
|
1625
|
+
expect(data.combo).toEqual(false);
|
1626
|
+
expect(data.multiSelect).toEqual(false);
|
1627
|
+
done();
|
1628
|
+
}, done.fail);
|
1629
|
+
});
|
1630
|
+
it('should not set invalid flags', function (done) {
|
990
1631
|
choiceWidgetDict.set('Ff', 'readonly');
|
991
|
-
|
1632
|
+
|
1633
|
+
var choiceWidgetRef = _primitives.Ref.get(165, 0);
|
1634
|
+
|
992
1635
|
var xref = new _test_utils.XRefMock([{
|
993
1636
|
ref: choiceWidgetRef,
|
994
1637
|
data: choiceWidgetDict
|
995
1638
|
}]);
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1639
|
+
|
1640
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref49) {
|
1641
|
+
var data = _ref49.data;
|
1642
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1643
|
+
expect(data.readOnly).toEqual(false);
|
1644
|
+
expect(data.combo).toEqual(false);
|
1645
|
+
expect(data.multiSelect).toEqual(false);
|
1646
|
+
done();
|
1647
|
+
}, done.fail);
|
1648
|
+
});
|
1649
|
+
it('should set valid flags', function (done) {
|
1004
1650
|
choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
|
1005
|
-
|
1651
|
+
|
1652
|
+
var choiceWidgetRef = _primitives.Ref.get(512, 0);
|
1653
|
+
|
1006
1654
|
var xref = new _test_utils.XRefMock([{
|
1007
1655
|
ref: choiceWidgetRef,
|
1008
1656
|
data: choiceWidgetDict
|
1009
1657
|
}]);
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1658
|
+
|
1659
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref50) {
|
1660
|
+
var data = _ref50.data;
|
1661
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1662
|
+
expect(data.readOnly).toEqual(true);
|
1663
|
+
expect(data.combo).toEqual(true);
|
1664
|
+
expect(data.multiSelect).toEqual(true);
|
1665
|
+
done();
|
1666
|
+
}, done.fail);
|
1016
1667
|
});
|
1017
1668
|
});
|
1018
1669
|
describe('LineAnnotation', function () {
|
1019
|
-
it('should set the line coordinates', function () {
|
1670
|
+
it('should set the line coordinates', function (done) {
|
1020
1671
|
var lineDict = new _primitives.Dict();
|
1021
1672
|
lineDict.set('Type', _primitives.Name.get('Annot'));
|
1022
1673
|
lineDict.set('Subtype', _primitives.Name.get('Line'));
|
1023
1674
|
lineDict.set('L', [1, 2, 3, 4]);
|
1024
|
-
|
1675
|
+
|
1676
|
+
var lineRef = _primitives.Ref.get(122, 0);
|
1677
|
+
|
1025
1678
|
var xref = new _test_utils.XRefMock([{
|
1026
1679
|
ref: lineRef,
|
1027
1680
|
data: lineDict
|
1028
1681
|
}]);
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1682
|
+
|
1683
|
+
_annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref51) {
|
1684
|
+
var data = _ref51.data;
|
1685
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
|
1686
|
+
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
1687
|
+
done();
|
1688
|
+
}, done.fail);
|
1033
1689
|
});
|
1034
1690
|
});
|
1035
1691
|
describe('FileAttachmentAnnotation', function () {
|
1036
|
-
it('should correctly parse a file attachment', function () {
|
1692
|
+
it('should correctly parse a file attachment', function (done) {
|
1037
1693
|
var fileStream = new _stream.StringStream('<<\n' + '/Type /EmbeddedFile\n' + '/Subtype /text#2Fplain\n' + '>>\n' + 'stream\n' + 'Test attachment' + 'endstream\n');
|
1038
|
-
var
|
1039
|
-
|
1040
|
-
|
1694
|
+
var parser = new _parser.Parser({
|
1695
|
+
lexer: new _parser.Lexer(fileStream),
|
1696
|
+
xref: null,
|
1697
|
+
allowStreams: true
|
1698
|
+
});
|
1699
|
+
|
1700
|
+
var fileStreamRef = _primitives.Ref.get(18, 0);
|
1701
|
+
|
1041
1702
|
var fileStreamDict = parser.getObj();
|
1042
1703
|
var embeddedFileDict = new _primitives.Dict();
|
1043
1704
|
embeddedFileDict.set('F', fileStreamRef);
|
1044
|
-
|
1705
|
+
|
1706
|
+
var fileSpecRef = _primitives.Ref.get(19, 0);
|
1707
|
+
|
1045
1708
|
var fileSpecDict = new _primitives.Dict();
|
1046
1709
|
fileSpecDict.set('Type', _primitives.Name.get('Filespec'));
|
1047
1710
|
fileSpecDict.set('Desc', '');
|
1048
1711
|
fileSpecDict.set('EF', embeddedFileDict);
|
1049
1712
|
fileSpecDict.set('UF', 'Test.txt');
|
1050
|
-
|
1713
|
+
|
1714
|
+
var fileAttachmentRef = _primitives.Ref.get(20, 0);
|
1715
|
+
|
1051
1716
|
var fileAttachmentDict = new _primitives.Dict();
|
1052
1717
|
fileAttachmentDict.set('Type', _primitives.Name.get('Annot'));
|
1053
1718
|
fileAttachmentDict.set('Subtype', _primitives.Name.get('FileAttachment'));
|
@@ -1067,15 +1732,70 @@ describe('annotation', function () {
|
|
1067
1732
|
embeddedFileDict.assignXref(xref);
|
1068
1733
|
fileSpecDict.assignXref(xref);
|
1069
1734
|
fileAttachmentDict.assignXref(xref);
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1735
|
+
|
1736
|
+
_annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref52) {
|
1737
|
+
var data = _ref52.data;
|
1738
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
|
1739
|
+
expect(data.file.filename).toEqual('Test.txt');
|
1740
|
+
expect(data.file.content).toEqual((0, _util.stringToBytes)('Test attachment'));
|
1741
|
+
done();
|
1742
|
+
}, done.fail);
|
1075
1743
|
});
|
1076
1744
|
});
|
1077
1745
|
describe('PopupAnnotation', function () {
|
1078
|
-
it('should inherit
|
1746
|
+
it('should inherit properties from its parent', function (done) {
|
1747
|
+
var parentDict = new _primitives.Dict();
|
1748
|
+
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1749
|
+
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
1750
|
+
parentDict.set('M', 'D:20190423');
|
1751
|
+
parentDict.set('C', [0, 0, 1]);
|
1752
|
+
var popupDict = new _primitives.Dict();
|
1753
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
1754
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1755
|
+
popupDict.set('Parent', parentDict);
|
1756
|
+
|
1757
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1758
|
+
|
1759
|
+
var xref = new _test_utils.XRefMock([{
|
1760
|
+
ref: popupRef,
|
1761
|
+
data: popupDict
|
1762
|
+
}]);
|
1763
|
+
|
1764
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref53) {
|
1765
|
+
var data = _ref53.data,
|
1766
|
+
viewable = _ref53.viewable;
|
1767
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1768
|
+
expect(data.modificationDate).toEqual('D:20190423');
|
1769
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
1770
|
+
done();
|
1771
|
+
}, done.fail);
|
1772
|
+
});
|
1773
|
+
it('should handle missing parent properties', function (done) {
|
1774
|
+
var parentDict = new _primitives.Dict();
|
1775
|
+
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1776
|
+
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
1777
|
+
var popupDict = new _primitives.Dict();
|
1778
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
1779
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1780
|
+
popupDict.set('Parent', parentDict);
|
1781
|
+
|
1782
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1783
|
+
|
1784
|
+
var xref = new _test_utils.XRefMock([{
|
1785
|
+
ref: popupRef,
|
1786
|
+
data: popupDict
|
1787
|
+
}]);
|
1788
|
+
|
1789
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref54) {
|
1790
|
+
var data = _ref54.data,
|
1791
|
+
viewable = _ref54.viewable;
|
1792
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1793
|
+
expect(data.modificationDate).toEqual(null);
|
1794
|
+
expect(data.color).toEqual(null);
|
1795
|
+
done();
|
1796
|
+
}, done.fail);
|
1797
|
+
});
|
1798
|
+
it('should inherit the parent flags when the Popup is not viewable, ' + 'but the parent is (PR 7352)', function (done) {
|
1079
1799
|
var parentDict = new _primitives.Dict();
|
1080
1800
|
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1081
1801
|
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
@@ -1085,16 +1805,359 @@ describe('annotation', function () {
|
|
1085
1805
|
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1086
1806
|
popupDict.set('F', 25);
|
1087
1807
|
popupDict.set('Parent', parentDict);
|
1088
|
-
|
1808
|
+
|
1809
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1810
|
+
|
1089
1811
|
var xref = new _test_utils.XRefMock([{
|
1090
1812
|
ref: popupRef,
|
1091
1813
|
data: popupDict
|
1092
1814
|
}]);
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1815
|
+
|
1816
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref55) {
|
1817
|
+
var data = _ref55.data,
|
1818
|
+
viewable = _ref55.viewable;
|
1819
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1820
|
+
expect(data.annotationFlags).toEqual(25);
|
1821
|
+
expect(viewable).toEqual(true);
|
1822
|
+
done();
|
1823
|
+
}, done.fail);
|
1824
|
+
});
|
1825
|
+
it('should correctly inherit Contents from group-master annotation ' + 'if parent has ReplyType == Group', function (done) {
|
1826
|
+
var annotationRef = new _primitives.Ref(819, 0);
|
1827
|
+
var annotationDict = new _primitives.Dict();
|
1828
|
+
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
1829
|
+
annotationDict.set('Subtype', _primitives.Name.get('Text'));
|
1830
|
+
annotationDict.set('T', 'Correct Title');
|
1831
|
+
annotationDict.set('Contents', 'Correct Text');
|
1832
|
+
annotationDict.set('M', 'D:20190423');
|
1833
|
+
annotationDict.set('C', [0, 0, 1]);
|
1834
|
+
var replyRef = new _primitives.Ref(820, 0);
|
1835
|
+
var replyDict = new _primitives.Dict();
|
1836
|
+
replyDict.set('Type', _primitives.Name.get('Annot'));
|
1837
|
+
replyDict.set('Subtype', _primitives.Name.get('Text'));
|
1838
|
+
replyDict.set('IRT', annotationRef);
|
1839
|
+
replyDict.set('RT', _primitives.Name.get('Group'));
|
1840
|
+
replyDict.set('T', 'Reply Title');
|
1841
|
+
replyDict.set('Contents', 'Reply Text');
|
1842
|
+
replyDict.set('M', 'D:20190523');
|
1843
|
+
replyDict.set('C', [0.4]);
|
1844
|
+
var popupRef = new _primitives.Ref(821, 0);
|
1845
|
+
var popupDict = new _primitives.Dict();
|
1846
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
1847
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1848
|
+
popupDict.set('T', 'Wrong Title');
|
1849
|
+
popupDict.set('Contents', 'Wrong Text');
|
1850
|
+
popupDict.set('Parent', replyRef);
|
1851
|
+
popupDict.set('M', 'D:20190623');
|
1852
|
+
popupDict.set('C', [0.8]);
|
1853
|
+
replyDict.set('Popup', popupRef);
|
1854
|
+
var xref = new _test_utils.XRefMock([{
|
1855
|
+
ref: annotationRef,
|
1856
|
+
data: annotationDict
|
1857
|
+
}, {
|
1858
|
+
ref: replyRef,
|
1859
|
+
data: replyDict
|
1860
|
+
}, {
|
1861
|
+
ref: popupRef,
|
1862
|
+
data: popupDict
|
1863
|
+
}]);
|
1864
|
+
annotationDict.assignXref(xref);
|
1865
|
+
popupDict.assignXref(xref);
|
1866
|
+
replyDict.assignXref(xref);
|
1867
|
+
|
1868
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref56) {
|
1869
|
+
var data = _ref56.data;
|
1870
|
+
expect(data.title).toEqual('Correct Title');
|
1871
|
+
expect(data.contents).toEqual('Correct Text');
|
1872
|
+
expect(data.modificationDate).toEqual('D:20190423');
|
1873
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
1874
|
+
done();
|
1875
|
+
}, done.fail);
|
1876
|
+
});
|
1877
|
+
});
|
1878
|
+
describe('InkAnnotation', function () {
|
1879
|
+
it('should handle a single ink list', function (done) {
|
1880
|
+
var inkDict = new _primitives.Dict();
|
1881
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1882
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1883
|
+
inkDict.set('InkList', [[1, 1, 1, 2, 2, 2, 3, 3]]);
|
1884
|
+
|
1885
|
+
var inkRef = _primitives.Ref.get(142, 0);
|
1886
|
+
|
1887
|
+
var xref = new _test_utils.XRefMock([{
|
1888
|
+
ref: inkRef,
|
1889
|
+
data: inkDict
|
1890
|
+
}]);
|
1891
|
+
|
1892
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref57) {
|
1893
|
+
var data = _ref57.data;
|
1894
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1895
|
+
expect(data.inkLists.length).toEqual(1);
|
1896
|
+
expect(data.inkLists[0]).toEqual([{
|
1897
|
+
x: 1,
|
1898
|
+
y: 1
|
1899
|
+
}, {
|
1900
|
+
x: 1,
|
1901
|
+
y: 2
|
1902
|
+
}, {
|
1903
|
+
x: 2,
|
1904
|
+
y: 2
|
1905
|
+
}, {
|
1906
|
+
x: 3,
|
1907
|
+
y: 3
|
1908
|
+
}]);
|
1909
|
+
done();
|
1910
|
+
}, done.fail);
|
1911
|
+
});
|
1912
|
+
it('should handle multiple ink lists', function (done) {
|
1913
|
+
var inkDict = new _primitives.Dict();
|
1914
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1915
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1916
|
+
inkDict.set('InkList', [[1, 1, 1, 2], [3, 3, 4, 5]]);
|
1917
|
+
|
1918
|
+
var inkRef = _primitives.Ref.get(143, 0);
|
1919
|
+
|
1920
|
+
var xref = new _test_utils.XRefMock([{
|
1921
|
+
ref: inkRef,
|
1922
|
+
data: inkDict
|
1923
|
+
}]);
|
1924
|
+
|
1925
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref58) {
|
1926
|
+
var data = _ref58.data;
|
1927
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1928
|
+
expect(data.inkLists.length).toEqual(2);
|
1929
|
+
expect(data.inkLists[0]).toEqual([{
|
1930
|
+
x: 1,
|
1931
|
+
y: 1
|
1932
|
+
}, {
|
1933
|
+
x: 1,
|
1934
|
+
y: 2
|
1935
|
+
}]);
|
1936
|
+
expect(data.inkLists[1]).toEqual([{
|
1937
|
+
x: 3,
|
1938
|
+
y: 3
|
1939
|
+
}, {
|
1940
|
+
x: 4,
|
1941
|
+
y: 5
|
1942
|
+
}]);
|
1943
|
+
done();
|
1944
|
+
}, done.fail);
|
1945
|
+
});
|
1946
|
+
});
|
1947
|
+
describe('HightlightAnnotation', function () {
|
1948
|
+
it('should not set quadpoints if not defined', function (done) {
|
1949
|
+
var highlightDict = new _primitives.Dict();
|
1950
|
+
highlightDict.set('Type', _primitives.Name.get('Annot'));
|
1951
|
+
highlightDict.set('Subtype', _primitives.Name.get('Highlight'));
|
1952
|
+
|
1953
|
+
var highlightRef = _primitives.Ref.get(121, 0);
|
1954
|
+
|
1955
|
+
var xref = new _test_utils.XRefMock([{
|
1956
|
+
ref: highlightRef,
|
1957
|
+
data: highlightDict
|
1958
|
+
}]);
|
1959
|
+
|
1960
|
+
_annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(function (_ref59) {
|
1961
|
+
var data = _ref59.data;
|
1962
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
|
1963
|
+
expect(data.quadPoints).toBeUndefined();
|
1964
|
+
done();
|
1965
|
+
}, done.fail);
|
1966
|
+
});
|
1967
|
+
it('should set quadpoints if defined', function (done) {
|
1968
|
+
var highlightDict = new _primitives.Dict();
|
1969
|
+
highlightDict.set('Type', _primitives.Name.get('Annot'));
|
1970
|
+
highlightDict.set('Subtype', _primitives.Name.get('Highlight'));
|
1971
|
+
highlightDict.set('Rect', [10, 10, 20, 20]);
|
1972
|
+
highlightDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
|
1973
|
+
|
1974
|
+
var highlightRef = _primitives.Ref.get(121, 0);
|
1975
|
+
|
1976
|
+
var xref = new _test_utils.XRefMock([{
|
1977
|
+
ref: highlightRef,
|
1978
|
+
data: highlightDict
|
1979
|
+
}]);
|
1980
|
+
|
1981
|
+
_annotation.AnnotationFactory.create(xref, highlightRef, pdfManagerMock, idFactoryMock).then(function (_ref60) {
|
1982
|
+
var data = _ref60.data;
|
1983
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.HIGHLIGHT);
|
1984
|
+
expect(data.quadPoints).toEqual([[{
|
1985
|
+
x: 11,
|
1986
|
+
y: 11
|
1987
|
+
}, {
|
1988
|
+
x: 12,
|
1989
|
+
y: 12
|
1990
|
+
}, {
|
1991
|
+
x: 13,
|
1992
|
+
y: 13
|
1993
|
+
}, {
|
1994
|
+
x: 14,
|
1995
|
+
y: 14
|
1996
|
+
}]]);
|
1997
|
+
done();
|
1998
|
+
}, done.fail);
|
1999
|
+
});
|
2000
|
+
});
|
2001
|
+
describe('UnderlineAnnotation', function () {
|
2002
|
+
it('should not set quadpoints if not defined', function (done) {
|
2003
|
+
var underlineDict = new _primitives.Dict();
|
2004
|
+
underlineDict.set('Type', _primitives.Name.get('Annot'));
|
2005
|
+
underlineDict.set('Subtype', _primitives.Name.get('Underline'));
|
2006
|
+
|
2007
|
+
var underlineRef = _primitives.Ref.get(121, 0);
|
2008
|
+
|
2009
|
+
var xref = new _test_utils.XRefMock([{
|
2010
|
+
ref: underlineRef,
|
2011
|
+
data: underlineDict
|
2012
|
+
}]);
|
2013
|
+
|
2014
|
+
_annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(function (_ref61) {
|
2015
|
+
var data = _ref61.data;
|
2016
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
|
2017
|
+
expect(data.quadPoints).toBeUndefined();
|
2018
|
+
done();
|
2019
|
+
}, done.fail);
|
2020
|
+
});
|
2021
|
+
it('should set quadpoints if defined', function (done) {
|
2022
|
+
var underlineDict = new _primitives.Dict();
|
2023
|
+
underlineDict.set('Type', _primitives.Name.get('Annot'));
|
2024
|
+
underlineDict.set('Subtype', _primitives.Name.get('Underline'));
|
2025
|
+
underlineDict.set('Rect', [10, 10, 20, 20]);
|
2026
|
+
underlineDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
|
2027
|
+
|
2028
|
+
var underlineRef = _primitives.Ref.get(121, 0);
|
2029
|
+
|
2030
|
+
var xref = new _test_utils.XRefMock([{
|
2031
|
+
ref: underlineRef,
|
2032
|
+
data: underlineDict
|
2033
|
+
}]);
|
2034
|
+
|
2035
|
+
_annotation.AnnotationFactory.create(xref, underlineRef, pdfManagerMock, idFactoryMock).then(function (_ref62) {
|
2036
|
+
var data = _ref62.data;
|
2037
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.UNDERLINE);
|
2038
|
+
expect(data.quadPoints).toEqual([[{
|
2039
|
+
x: 11,
|
2040
|
+
y: 11
|
2041
|
+
}, {
|
2042
|
+
x: 12,
|
2043
|
+
y: 12
|
2044
|
+
}, {
|
2045
|
+
x: 13,
|
2046
|
+
y: 13
|
2047
|
+
}, {
|
2048
|
+
x: 14,
|
2049
|
+
y: 14
|
2050
|
+
}]]);
|
2051
|
+
done();
|
2052
|
+
}, done.fail);
|
2053
|
+
});
|
2054
|
+
});
|
2055
|
+
describe('SquigglyAnnotation', function () {
|
2056
|
+
it('should not set quadpoints if not defined', function (done) {
|
2057
|
+
var squigglyDict = new _primitives.Dict();
|
2058
|
+
squigglyDict.set('Type', _primitives.Name.get('Annot'));
|
2059
|
+
squigglyDict.set('Subtype', _primitives.Name.get('Squiggly'));
|
2060
|
+
|
2061
|
+
var squigglyRef = _primitives.Ref.get(121, 0);
|
2062
|
+
|
2063
|
+
var xref = new _test_utils.XRefMock([{
|
2064
|
+
ref: squigglyRef,
|
2065
|
+
data: squigglyDict
|
2066
|
+
}]);
|
2067
|
+
|
2068
|
+
_annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(function (_ref63) {
|
2069
|
+
var data = _ref63.data;
|
2070
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
|
2071
|
+
expect(data.quadPoints).toBeUndefined();
|
2072
|
+
done();
|
2073
|
+
}, done.fail);
|
2074
|
+
});
|
2075
|
+
it('should set quadpoints if defined', function (done) {
|
2076
|
+
var squigglyDict = new _primitives.Dict();
|
2077
|
+
squigglyDict.set('Type', _primitives.Name.get('Annot'));
|
2078
|
+
squigglyDict.set('Subtype', _primitives.Name.get('Squiggly'));
|
2079
|
+
squigglyDict.set('Rect', [10, 10, 20, 20]);
|
2080
|
+
squigglyDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
|
2081
|
+
|
2082
|
+
var squigglyRef = _primitives.Ref.get(121, 0);
|
2083
|
+
|
2084
|
+
var xref = new _test_utils.XRefMock([{
|
2085
|
+
ref: squigglyRef,
|
2086
|
+
data: squigglyDict
|
2087
|
+
}]);
|
2088
|
+
|
2089
|
+
_annotation.AnnotationFactory.create(xref, squigglyRef, pdfManagerMock, idFactoryMock).then(function (_ref64) {
|
2090
|
+
var data = _ref64.data;
|
2091
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.SQUIGGLY);
|
2092
|
+
expect(data.quadPoints).toEqual([[{
|
2093
|
+
x: 11,
|
2094
|
+
y: 11
|
2095
|
+
}, {
|
2096
|
+
x: 12,
|
2097
|
+
y: 12
|
2098
|
+
}, {
|
2099
|
+
x: 13,
|
2100
|
+
y: 13
|
2101
|
+
}, {
|
2102
|
+
x: 14,
|
2103
|
+
y: 14
|
2104
|
+
}]]);
|
2105
|
+
done();
|
2106
|
+
}, done.fail);
|
2107
|
+
});
|
2108
|
+
});
|
2109
|
+
describe('StrikeOutAnnotation', function () {
|
2110
|
+
it('should not set quadpoints if not defined', function (done) {
|
2111
|
+
var strikeOutDict = new _primitives.Dict();
|
2112
|
+
strikeOutDict.set('Type', _primitives.Name.get('Annot'));
|
2113
|
+
strikeOutDict.set('Subtype', _primitives.Name.get('StrikeOut'));
|
2114
|
+
|
2115
|
+
var strikeOutRef = _primitives.Ref.get(121, 0);
|
2116
|
+
|
2117
|
+
var xref = new _test_utils.XRefMock([{
|
2118
|
+
ref: strikeOutRef,
|
2119
|
+
data: strikeOutDict
|
2120
|
+
}]);
|
2121
|
+
|
2122
|
+
_annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(function (_ref65) {
|
2123
|
+
var data = _ref65.data;
|
2124
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
|
2125
|
+
expect(data.quadPoints).toBeUndefined();
|
2126
|
+
done();
|
2127
|
+
}, done.fail);
|
2128
|
+
});
|
2129
|
+
it('should set quadpoints if defined', function (done) {
|
2130
|
+
var strikeOutDict = new _primitives.Dict();
|
2131
|
+
strikeOutDict.set('Type', _primitives.Name.get('Annot'));
|
2132
|
+
strikeOutDict.set('Subtype', _primitives.Name.get('StrikeOut'));
|
2133
|
+
strikeOutDict.set('Rect', [10, 10, 20, 20]);
|
2134
|
+
strikeOutDict.set('QuadPoints', [11, 11, 12, 12, 13, 13, 14, 14]);
|
2135
|
+
|
2136
|
+
var strikeOutRef = _primitives.Ref.get(121, 0);
|
2137
|
+
|
2138
|
+
var xref = new _test_utils.XRefMock([{
|
2139
|
+
ref: strikeOutRef,
|
2140
|
+
data: strikeOutDict
|
2141
|
+
}]);
|
2142
|
+
|
2143
|
+
_annotation.AnnotationFactory.create(xref, strikeOutRef, pdfManagerMock, idFactoryMock).then(function (_ref66) {
|
2144
|
+
var data = _ref66.data;
|
2145
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.STRIKEOUT);
|
2146
|
+
expect(data.quadPoints).toEqual([[{
|
2147
|
+
x: 11,
|
2148
|
+
y: 11
|
2149
|
+
}, {
|
2150
|
+
x: 12,
|
2151
|
+
y: 12
|
2152
|
+
}, {
|
2153
|
+
x: 13,
|
2154
|
+
y: 13
|
2155
|
+
}, {
|
2156
|
+
x: 14,
|
2157
|
+
y: 14
|
2158
|
+
}]]);
|
2159
|
+
done();
|
2160
|
+
}, done.fail);
|
1098
2161
|
});
|
1099
2162
|
});
|
1100
2163
|
});
|