pdfjs-dist 2.0.489 → 2.2.228
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 +18515 -11402
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +48266 -37137
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11350 -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 +587 -242
- 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 +400 -152
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +560 -268
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1005 -360
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +812 -195
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +4 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +253 -29
- package/lib/core/jpx.js +396 -6
- 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 +1354 -488
- package/lib/core/operator_list.js +144 -31
- package/lib/core/parser.js +539 -191
- package/lib/core/pattern.js +148 -14
- package/lib/core/pdf_manager.js +323 -133
- package/lib/core/primitives.js +111 -24
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +217 -190
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +450 -133
- package/lib/display/api.js +1597 -784
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +360 -44
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +221 -90
- 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 +32 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +81 -31
- package/lib/display/svg.js +1235 -519
- package/lib/display/text_layer.js +153 -29
- 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 +36 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +243 -710
- package/lib/test/unit/annotation_spec.js +870 -401
- package/lib/test/unit/api_spec.js +657 -345
- 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 +10 -8
- 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 +38 -15
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- 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 +19 -54
- package/lib/test/unit/network_utils_spec.js +91 -14
- package/lib/test/unit/node_stream_spec.js +56 -32
- 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 +53 -20
- 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 +8 -6
- package/lib/test/unit/ui_utils_spec.js +454 -16
- 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 +1290 -588
- package/lib/web/app_options.js +100 -62
- package/lib/web/base_viewer.js +511 -182
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +32 -13
- package/lib/web/firefox_print_service.js +20 -10
- package/lib/web/firefoxcom.js +315 -80
- 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 +170 -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 +138 -77
- package/lib/web/pdf_outline_viewer.js +122 -46
- package/lib/web/pdf_page_view.js +191 -67
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +61 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +141 -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 +91 -52
- package/lib/web/preferences.js +284 -89
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +79 -11
- package/web/pdf_viewer.js +6107 -3748
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -309
- 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,106 @@ 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);
|
105
139
|
});
|
106
140
|
});
|
107
141
|
describe('Annotation', function () {
|
108
142
|
var dict, ref;
|
109
143
|
beforeAll(function (done) {
|
110
144
|
dict = new _primitives.Dict();
|
111
|
-
ref =
|
145
|
+
ref = _primitives.Ref.get(1, 0);
|
112
146
|
done();
|
113
147
|
});
|
114
148
|
afterAll(function () {
|
115
149
|
dict = ref = null;
|
116
150
|
});
|
151
|
+
it('should set and get valid contents', function () {
|
152
|
+
var annotation = new _annotation.Annotation({
|
153
|
+
dict: dict,
|
154
|
+
ref: ref
|
155
|
+
});
|
156
|
+
annotation.setContents('Foo bar baz');
|
157
|
+
expect(annotation.contents).toEqual('Foo bar baz');
|
158
|
+
});
|
159
|
+
it('should not set and get invalid contents', function () {
|
160
|
+
var annotation = new _annotation.Annotation({
|
161
|
+
dict: dict,
|
162
|
+
ref: ref
|
163
|
+
});
|
164
|
+
annotation.setContents(undefined);
|
165
|
+
expect(annotation.contents).toEqual('');
|
166
|
+
});
|
167
|
+
it('should set and get a valid modification date', function () {
|
168
|
+
var annotation = new _annotation.Annotation({
|
169
|
+
dict: dict,
|
170
|
+
ref: ref
|
171
|
+
});
|
172
|
+
annotation.setModificationDate('D:20190422');
|
173
|
+
expect(annotation.modificationDate).toEqual('D:20190422');
|
174
|
+
});
|
175
|
+
it('should not set and get an invalid modification date', function () {
|
176
|
+
var annotation = new _annotation.Annotation({
|
177
|
+
dict: dict,
|
178
|
+
ref: ref
|
179
|
+
});
|
180
|
+
annotation.setModificationDate(undefined);
|
181
|
+
expect(annotation.modificationDate).toEqual(null);
|
182
|
+
});
|
117
183
|
it('should set and get flags', function () {
|
118
184
|
var annotation = new _annotation.Annotation({
|
119
185
|
dict: dict,
|
@@ -155,7 +221,7 @@ describe('annotation', function () {
|
|
155
221
|
ref: ref
|
156
222
|
});
|
157
223
|
annotation.setColor('red');
|
158
|
-
expect(annotation.color).toEqual(new
|
224
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
159
225
|
});
|
160
226
|
it('should set and get a transparent color', function () {
|
161
227
|
var annotation = new _annotation.Annotation({
|
@@ -171,7 +237,7 @@ describe('annotation', function () {
|
|
171
237
|
ref: ref
|
172
238
|
});
|
173
239
|
annotation.setColor([0.4]);
|
174
|
-
expect(annotation.color).toEqual(new
|
240
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
175
241
|
});
|
176
242
|
it('should set and get an RGB color', function () {
|
177
243
|
var annotation = new _annotation.Annotation({
|
@@ -179,7 +245,7 @@ describe('annotation', function () {
|
|
179
245
|
ref: ref
|
180
246
|
});
|
181
247
|
annotation.setColor([0, 0, 1]);
|
182
|
-
expect(annotation.color).toEqual(new
|
248
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
183
249
|
});
|
184
250
|
it('should set and get a CMYK color', function () {
|
185
251
|
var annotation = new _annotation.Annotation({
|
@@ -187,7 +253,7 @@ describe('annotation', function () {
|
|
187
253
|
ref: ref
|
188
254
|
});
|
189
255
|
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
190
|
-
expect(annotation.color).toEqual(new
|
256
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
191
257
|
});
|
192
258
|
it('should not set and get an invalid color', function () {
|
193
259
|
var annotation = new _annotation.Annotation({
|
@@ -195,7 +261,7 @@ describe('annotation', function () {
|
|
195
261
|
ref: ref
|
196
262
|
});
|
197
263
|
annotation.setColor([0.4, 0.6]);
|
198
|
-
expect(annotation.color).toEqual(new
|
264
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
199
265
|
});
|
200
266
|
});
|
201
267
|
describe('AnnotationBorderStyle', function () {
|
@@ -209,6 +275,14 @@ describe('annotation', function () {
|
|
209
275
|
borderStyle.setWidth('three');
|
210
276
|
expect(borderStyle.width).toEqual(1);
|
211
277
|
});
|
278
|
+
it('should set the width to zero, when the input is a `Name` (issue 10385)', function () {
|
279
|
+
var borderStyleZero = new _annotation.AnnotationBorderStyle();
|
280
|
+
borderStyleZero.setWidth(_primitives.Name.get('0'));
|
281
|
+
var borderStyleFive = new _annotation.AnnotationBorderStyle();
|
282
|
+
borderStyleFive.setWidth(_primitives.Name.get('5'));
|
283
|
+
expect(borderStyleZero.width).toEqual(0);
|
284
|
+
expect(borderStyleFive.width).toEqual(0);
|
285
|
+
});
|
212
286
|
it('should set and get a valid style', function () {
|
213
287
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
214
288
|
borderStyle.setStyle(_primitives.Name.get('D'));
|
@@ -244,14 +318,41 @@ describe('annotation', function () {
|
|
244
318
|
borderStyle.setVerticalCornerRadius(3);
|
245
319
|
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
246
320
|
});
|
247
|
-
it('should not set and get an invalid
|
321
|
+
it('should not set and get an invalid vertical corner radius', function () {
|
248
322
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
249
323
|
borderStyle.setVerticalCornerRadius('three');
|
250
324
|
expect(borderStyle.verticalCornerRadius).toEqual(0);
|
251
325
|
});
|
252
326
|
});
|
327
|
+
describe('MarkupAnnotation', function () {
|
328
|
+
var dict, ref;
|
329
|
+
beforeAll(function (done) {
|
330
|
+
dict = new _primitives.Dict();
|
331
|
+
ref = _primitives.Ref.get(1, 0);
|
332
|
+
done();
|
333
|
+
});
|
334
|
+
afterAll(function () {
|
335
|
+
dict = ref = null;
|
336
|
+
});
|
337
|
+
it('should set and get a valid creation date', function () {
|
338
|
+
var markupAnnotation = new _annotation.MarkupAnnotation({
|
339
|
+
dict: dict,
|
340
|
+
ref: ref
|
341
|
+
});
|
342
|
+
markupAnnotation.setCreationDate('D:20190422');
|
343
|
+
expect(markupAnnotation.creationDate).toEqual('D:20190422');
|
344
|
+
});
|
345
|
+
it('should not set and get an invalid creation date', function () {
|
346
|
+
var markupAnnotation = new _annotation.MarkupAnnotation({
|
347
|
+
dict: dict,
|
348
|
+
ref: ref
|
349
|
+
});
|
350
|
+
markupAnnotation.setCreationDate(undefined);
|
351
|
+
expect(markupAnnotation.creationDate).toEqual(null);
|
352
|
+
});
|
353
|
+
});
|
253
354
|
describe('LinkAnnotation', function () {
|
254
|
-
it('should correctly parse a URI action', function () {
|
355
|
+
it('should correctly parse a URI action', function (done) {
|
255
356
|
var actionDict = new _primitives.Dict();
|
256
357
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
257
358
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -260,19 +361,24 @@ describe('annotation', function () {
|
|
260
361
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
261
362
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
262
363
|
annotationDict.set('A', actionDict);
|
263
|
-
|
364
|
+
|
365
|
+
var annotationRef = _primitives.Ref.get(820, 0);
|
366
|
+
|
264
367
|
var xref = new _test_utils.XRefMock([{
|
265
368
|
ref: annotationRef,
|
266
369
|
data: annotationDict
|
267
370
|
}]);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
371
|
+
|
372
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref5) {
|
373
|
+
var data = _ref5.data;
|
374
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
375
|
+
expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
376
|
+
expect(data.unsafeUrl).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
377
|
+
expect(data.dest).toBeUndefined();
|
378
|
+
done();
|
379
|
+
}, done.fail);
|
380
|
+
});
|
381
|
+
it('should correctly parse a URI action, where the URI entry ' + 'is missing a protocol', function (done) {
|
276
382
|
var actionDict = new _primitives.Dict();
|
277
383
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
278
384
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -281,40 +387,52 @@ describe('annotation', function () {
|
|
281
387
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
282
388
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
283
389
|
annotationDict.set('A', actionDict);
|
284
|
-
|
390
|
+
|
391
|
+
var annotationRef = _primitives.Ref.get(353, 0);
|
392
|
+
|
285
393
|
var xref = new _test_utils.XRefMock([{
|
286
394
|
ref: annotationRef,
|
287
395
|
data: annotationDict
|
288
396
|
}]);
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
397
|
+
|
398
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
|
399
|
+
var data = _ref6.data;
|
400
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
401
|
+
expect(data.url).toEqual('http://www.hmrc.gov.uk/');
|
402
|
+
expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk');
|
403
|
+
expect(data.dest).toBeUndefined();
|
404
|
+
done();
|
405
|
+
}, done.fail);
|
406
|
+
});
|
407
|
+
it('should correctly parse a URI action, where the URI entry ' + 'has an incorrect encoding (bug 1122280)', function (done) {
|
297
408
|
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
|
-
|
409
|
+
var parser = new _parser.Parser({
|
410
|
+
lexer: new _parser.Lexer(actionStream),
|
411
|
+
xref: null
|
412
|
+
});
|
300
413
|
var actionDict = parser.getObj();
|
301
414
|
var annotationDict = new _primitives.Dict();
|
302
415
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
303
416
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
304
417
|
annotationDict.set('A', actionDict);
|
305
|
-
|
418
|
+
|
419
|
+
var annotationRef = _primitives.Ref.get(8, 0);
|
420
|
+
|
306
421
|
var xref = new _test_utils.XRefMock([{
|
307
422
|
ref: annotationRef,
|
308
423
|
data: annotationDict
|
309
424
|
}]);
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
425
|
+
|
426
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
|
427
|
+
var data = _ref7.data;
|
428
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
429
|
+
expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4')).href);
|
430
|
+
expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4'));
|
431
|
+
expect(data.dest).toBeUndefined();
|
432
|
+
done();
|
433
|
+
}, done.fail);
|
434
|
+
});
|
435
|
+
it('should correctly parse a GoTo action', function (done) {
|
318
436
|
var actionDict = new _primitives.Dict();
|
319
437
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
320
438
|
actionDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -323,19 +441,24 @@ describe('annotation', function () {
|
|
323
441
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
324
442
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
325
443
|
annotationDict.set('A', actionDict);
|
326
|
-
|
444
|
+
|
445
|
+
var annotationRef = _primitives.Ref.get(798, 0);
|
446
|
+
|
327
447
|
var xref = new _test_utils.XRefMock([{
|
328
448
|
ref: annotationRef,
|
329
449
|
data: annotationDict
|
330
450
|
}]);
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
451
|
+
|
452
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
|
453
|
+
var data = _ref8.data;
|
454
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
455
|
+
expect(data.url).toBeUndefined();
|
456
|
+
expect(data.unsafeUrl).toBeUndefined();
|
457
|
+
expect(data.dest).toEqual('page.157');
|
458
|
+
done();
|
459
|
+
}, done.fail);
|
460
|
+
});
|
461
|
+
it('should correctly parse a GoToR action, where the FileSpec entry ' + 'is a string containing a relative URL', function (done) {
|
339
462
|
var actionDict = new _primitives.Dict();
|
340
463
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
341
464
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -346,20 +469,25 @@ describe('annotation', function () {
|
|
346
469
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
347
470
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
348
471
|
annotationDict.set('A', actionDict);
|
349
|
-
|
472
|
+
|
473
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
474
|
+
|
350
475
|
var xref = new _test_utils.XRefMock([{
|
351
476
|
ref: annotationRef,
|
352
477
|
data: annotationDict
|
353
478
|
}]);
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
479
|
+
|
480
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
|
481
|
+
var data = _ref9.data;
|
482
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
483
|
+
expect(data.url).toBeUndefined();
|
484
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
485
|
+
expect(data.dest).toBeUndefined();
|
486
|
+
expect(data.newWindow).toEqual(true);
|
487
|
+
done();
|
488
|
+
}, done.fail);
|
489
|
+
});
|
490
|
+
it('should correctly parse a GoToR action, containing a relative URL, ' + 'with the "docBaseUrl" parameter specified', function (done) {
|
363
491
|
var actionDict = new _primitives.Dict();
|
364
492
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
365
493
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -369,20 +497,27 @@ describe('annotation', function () {
|
|
369
497
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
370
498
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
371
499
|
annotationDict.set('A', actionDict);
|
372
|
-
|
500
|
+
|
501
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
502
|
+
|
373
503
|
var xref = new _test_utils.XRefMock([{
|
374
504
|
ref: annotationRef,
|
375
505
|
data: annotationDict
|
376
506
|
}]);
|
377
|
-
var pdfManager = new PDFManagerMock({
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
507
|
+
var pdfManager = new PDFManagerMock({
|
508
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
509
|
+
});
|
510
|
+
|
511
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref10) {
|
512
|
+
var data = _ref10.data;
|
513
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
514
|
+
expect(data.url).toEqual('http://www.example.com/0013/001346/134685E.pdf#4.3');
|
515
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
516
|
+
expect(data.dest).toBeUndefined();
|
517
|
+
done();
|
518
|
+
}, done.fail);
|
519
|
+
});
|
520
|
+
it('should correctly parse a GoToR action, with named destination', function (done) {
|
386
521
|
var actionDict = new _primitives.Dict();
|
387
522
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
388
523
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -392,20 +527,25 @@ describe('annotation', function () {
|
|
392
527
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
393
528
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
394
529
|
annotationDict.set('A', actionDict);
|
395
|
-
|
530
|
+
|
531
|
+
var annotationRef = _primitives.Ref.get(495, 0);
|
532
|
+
|
396
533
|
var xref = new _test_utils.XRefMock([{
|
397
534
|
ref: annotationRef,
|
398
535
|
data: annotationDict
|
399
536
|
}]);
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
537
|
+
|
538
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
|
539
|
+
var data = _ref11.data;
|
540
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
541
|
+
expect(data.url).toEqual('http://www.example.com/test.pdf#15');
|
542
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#15');
|
543
|
+
expect(data.dest).toBeUndefined();
|
544
|
+
expect(data.newWindow).toBeFalsy();
|
545
|
+
done();
|
546
|
+
}, done.fail);
|
547
|
+
});
|
548
|
+
it('should correctly parse a GoToR action, with explicit destination array', function (done) {
|
409
549
|
var actionDict = new _primitives.Dict();
|
410
550
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
411
551
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -415,20 +555,25 @@ describe('annotation', function () {
|
|
415
555
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
416
556
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
417
557
|
annotationDict.set('A', actionDict);
|
418
|
-
|
558
|
+
|
559
|
+
var annotationRef = _primitives.Ref.get(489, 0);
|
560
|
+
|
419
561
|
var xref = new _test_utils.XRefMock([{
|
420
562
|
ref: annotationRef,
|
421
563
|
data: annotationDict
|
422
564
|
}]);
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
565
|
+
|
566
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
|
567
|
+
var data = _ref12.data;
|
568
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
569
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]').href);
|
570
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]');
|
571
|
+
expect(data.dest).toBeUndefined();
|
572
|
+
expect(data.newWindow).toBeFalsy();
|
573
|
+
done();
|
574
|
+
}, done.fail);
|
575
|
+
});
|
576
|
+
it('should correctly parse a Launch action, where the FileSpec dict ' + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
|
432
577
|
var fileSpecDict = new _primitives.Dict();
|
433
578
|
fileSpecDict.set('Type', _primitives.Name.get('FileSpec'));
|
434
579
|
fileSpecDict.set('F', 'Part II/Part II.pdf');
|
@@ -442,21 +587,28 @@ describe('annotation', function () {
|
|
442
587
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
443
588
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
444
589
|
annotationDict.set('A', actionDict);
|
445
|
-
|
590
|
+
|
591
|
+
var annotationRef = _primitives.Ref.get(88, 0);
|
592
|
+
|
446
593
|
var xref = new _test_utils.XRefMock([{
|
447
594
|
ref: annotationRef,
|
448
595
|
data: annotationDict
|
449
596
|
}]);
|
450
|
-
var pdfManager = new PDFManagerMock({
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
597
|
+
var pdfManager = new PDFManagerMock({
|
598
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
599
|
+
});
|
600
|
+
|
601
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref13) {
|
602
|
+
var data = _ref13.data;
|
603
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
604
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
|
605
|
+
expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
|
606
|
+
expect(data.dest).toBeUndefined();
|
607
|
+
expect(data.newWindow).toEqual(true);
|
608
|
+
done();
|
609
|
+
}, done.fail);
|
610
|
+
});
|
611
|
+
it('should recover valid URLs from JavaScript actions having certain ' + 'white-listed formats', function (done) {
|
460
612
|
function checkJsAction(params) {
|
461
613
|
var jsEntry = params.jsEntry;
|
462
614
|
var expectedUrl = params.expectedUrl;
|
@@ -470,39 +622,44 @@ describe('annotation', function () {
|
|
470
622
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
471
623
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
472
624
|
annotationDict.set('A', actionDict);
|
473
|
-
|
625
|
+
|
626
|
+
var annotationRef = _primitives.Ref.get(46, 0);
|
627
|
+
|
474
628
|
var xref = new _test_utils.XRefMock([{
|
475
629
|
ref: annotationRef,
|
476
630
|
data: annotationDict
|
477
631
|
}]);
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
632
|
+
return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
|
633
|
+
var data = _ref14.data;
|
634
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
635
|
+
expect(data.url).toEqual(expectedUrl);
|
636
|
+
expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
|
637
|
+
expect(data.dest).toBeUndefined();
|
638
|
+
expect(data.newWindow).toEqual(expectedNewWindow);
|
639
|
+
});
|
485
640
|
}
|
486
|
-
|
641
|
+
|
642
|
+
var annotation1 = checkJsAction({
|
487
643
|
jsEntry: 'function someFun() { return "qwerty"; } someFun();',
|
488
644
|
expectedUrl: undefined,
|
489
645
|
expectedUnsafeUrl: undefined,
|
490
646
|
expectedNewWindow: undefined
|
491
647
|
});
|
492
|
-
checkJsAction({
|
648
|
+
var annotation2 = checkJsAction({
|
493
649
|
jsEntry: 'window.open(\'http://www.example.com/test.pdf\')',
|
494
650
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
495
651
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
496
652
|
expectedNewWindow: undefined
|
497
653
|
});
|
498
|
-
checkJsAction({
|
654
|
+
var annotation3 = checkJsAction({
|
499
655
|
jsEntry: new _stream.StringStream('app.launchURL("http://www.example.com/test.pdf", true)'),
|
500
656
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
501
657
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
502
658
|
expectedNewWindow: true
|
503
659
|
});
|
660
|
+
Promise.all([annotation1, annotation2, annotation3]).then(done, done.fail);
|
504
661
|
});
|
505
|
-
it('should correctly parse a Named action', function () {
|
662
|
+
it('should correctly parse a Named action', function (done) {
|
506
663
|
var actionDict = new _primitives.Dict();
|
507
664
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
508
665
|
actionDict.set('S', _primitives.Name.get('Named'));
|
@@ -511,56 +668,73 @@ describe('annotation', function () {
|
|
511
668
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
512
669
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
513
670
|
annotationDict.set('A', actionDict);
|
514
|
-
|
671
|
+
|
672
|
+
var annotationRef = _primitives.Ref.get(12, 0);
|
673
|
+
|
515
674
|
var xref = new _test_utils.XRefMock([{
|
516
675
|
ref: annotationRef,
|
517
676
|
data: annotationDict
|
518
677
|
}]);
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
678
|
+
|
679
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
|
680
|
+
var data = _ref15.data;
|
681
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
682
|
+
expect(data.url).toBeUndefined();
|
683
|
+
expect(data.unsafeUrl).toBeUndefined();
|
684
|
+
expect(data.action).toEqual('GoToPage');
|
685
|
+
done();
|
686
|
+
}, done.fail);
|
687
|
+
});
|
688
|
+
it('should correctly parse a simple Dest', function (done) {
|
527
689
|
var annotationDict = new _primitives.Dict();
|
528
690
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
529
691
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
530
692
|
annotationDict.set('Dest', _primitives.Name.get('LI0'));
|
531
|
-
|
693
|
+
|
694
|
+
var annotationRef = _primitives.Ref.get(583, 0);
|
695
|
+
|
532
696
|
var xref = new _test_utils.XRefMock([{
|
533
697
|
ref: annotationRef,
|
534
698
|
data: annotationDict
|
535
699
|
}]);
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
700
|
+
|
701
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref16) {
|
702
|
+
var data = _ref16.data;
|
703
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
704
|
+
expect(data.url).toBeUndefined();
|
705
|
+
expect(data.unsafeUrl).toBeUndefined();
|
706
|
+
expect(data.dest).toEqual('LI0');
|
707
|
+
done();
|
708
|
+
}, done.fail);
|
709
|
+
});
|
710
|
+
it('should correctly parse a simple Dest, with explicit destination array', function (done) {
|
544
711
|
var annotationDict = new _primitives.Dict();
|
545
712
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
546
713
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
547
|
-
annotationDict.set('Dest', [
|
548
|
-
|
714
|
+
annotationDict.set('Dest', [_primitives.Ref.get(17, 0), _primitives.Name.get('XYZ'), 0, 841.89, null]);
|
715
|
+
|
716
|
+
var annotationRef = _primitives.Ref.get(10, 0);
|
717
|
+
|
549
718
|
var xref = new _test_utils.XRefMock([{
|
550
719
|
ref: annotationRef,
|
551
720
|
data: annotationDict
|
552
721
|
}]);
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
722
|
+
|
723
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
|
724
|
+
var data = _ref17.data;
|
725
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
726
|
+
expect(data.url).toBeUndefined();
|
727
|
+
expect(data.unsafeUrl).toBeUndefined();
|
728
|
+
expect(data.dest).toEqual([{
|
729
|
+
num: 17,
|
730
|
+
gen: 0
|
731
|
+
}, {
|
732
|
+
name: 'XYZ'
|
733
|
+
}, 0, 841.89, null]);
|
734
|
+
done();
|
735
|
+
}, done.fail);
|
736
|
+
});
|
737
|
+
it('should correctly parse a Dest, which violates the specification ' + 'by containing a dictionary', function (done) {
|
564
738
|
var destDict = new _primitives.Dict();
|
565
739
|
destDict.set('Type', _primitives.Name.get('Action'));
|
566
740
|
destDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -569,17 +743,22 @@ describe('annotation', function () {
|
|
569
743
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
570
744
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
571
745
|
annotationDict.set('Dest', destDict);
|
572
|
-
|
746
|
+
|
747
|
+
var annotationRef = _primitives.Ref.get(798, 0);
|
748
|
+
|
573
749
|
var xref = new _test_utils.XRefMock([{
|
574
750
|
ref: annotationRef,
|
575
751
|
data: annotationDict
|
576
752
|
}]);
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
753
|
+
|
754
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
|
755
|
+
var data = _ref18.data;
|
756
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
757
|
+
expect(data.url).toBeUndefined();
|
758
|
+
expect(data.unsafeUrl).toBeUndefined();
|
759
|
+
expect(data.dest).toEqual('page.157');
|
760
|
+
done();
|
761
|
+
}, done.fail);
|
583
762
|
});
|
584
763
|
});
|
585
764
|
describe('WidgetAnnotation', function () {
|
@@ -593,30 +772,39 @@ describe('annotation', function () {
|
|
593
772
|
afterEach(function () {
|
594
773
|
widgetDict = null;
|
595
774
|
});
|
596
|
-
it('should handle unknown field names', function () {
|
597
|
-
var widgetRef =
|
775
|
+
it('should handle unknown field names', function (done) {
|
776
|
+
var widgetRef = _primitives.Ref.get(20, 0);
|
777
|
+
|
598
778
|
var xref = new _test_utils.XRefMock([{
|
599
779
|
ref: widgetRef,
|
600
780
|
data: widgetDict
|
601
781
|
}]);
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
782
|
+
|
783
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref19) {
|
784
|
+
var data = _ref19.data;
|
785
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
786
|
+
expect(data.fieldName).toEqual('');
|
787
|
+
done();
|
788
|
+
}, done.fail);
|
606
789
|
});
|
607
|
-
it('should construct the field name when there are no ancestors', function () {
|
790
|
+
it('should construct the field name when there are no ancestors', function (done) {
|
608
791
|
widgetDict.set('T', 'foo');
|
609
|
-
|
792
|
+
|
793
|
+
var widgetRef = _primitives.Ref.get(21, 0);
|
794
|
+
|
610
795
|
var xref = new _test_utils.XRefMock([{
|
611
796
|
ref: widgetRef,
|
612
797
|
data: widgetDict
|
613
798
|
}]);
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
799
|
+
|
800
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
|
801
|
+
var data = _ref20.data;
|
802
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
803
|
+
expect(data.fieldName).toEqual('foo');
|
804
|
+
done();
|
805
|
+
}, done.fail);
|
618
806
|
});
|
619
|
-
it('should construct the field name when there are ancestors', function () {
|
807
|
+
it('should construct the field name when there are ancestors', function (done) {
|
620
808
|
var firstParent = new _primitives.Dict();
|
621
809
|
firstParent.set('T', 'foo');
|
622
810
|
var secondParent = new _primitives.Dict();
|
@@ -624,31 +812,41 @@ describe('annotation', function () {
|
|
624
812
|
secondParent.set('T', 'bar');
|
625
813
|
widgetDict.set('Parent', secondParent);
|
626
814
|
widgetDict.set('T', 'baz');
|
627
|
-
|
815
|
+
|
816
|
+
var widgetRef = _primitives.Ref.get(22, 0);
|
817
|
+
|
628
818
|
var xref = new _test_utils.XRefMock([{
|
629
819
|
ref: widgetRef,
|
630
820
|
data: widgetDict
|
631
821
|
}]);
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
822
|
+
|
823
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
|
824
|
+
var data = _ref21.data;
|
825
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
826
|
+
expect(data.fieldName).toEqual('foo.bar.baz');
|
827
|
+
done();
|
828
|
+
}, done.fail);
|
636
829
|
});
|
637
|
-
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function () {
|
830
|
+
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function (done) {
|
638
831
|
var parentDict = new _primitives.Dict();
|
639
832
|
parentDict.set('Parent', null);
|
640
833
|
parentDict.set('T', 'foo');
|
641
834
|
widgetDict.set('Parent', parentDict);
|
642
835
|
widgetDict.set('T', 'bar');
|
643
|
-
|
836
|
+
|
837
|
+
var widgetRef = _primitives.Ref.get(22, 0);
|
838
|
+
|
644
839
|
var xref = new _test_utils.XRefMock([{
|
645
840
|
ref: widgetRef,
|
646
841
|
data: widgetDict
|
647
842
|
}]);
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
843
|
+
|
844
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
|
845
|
+
var data = _ref22.data;
|
846
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
847
|
+
expect(data.fieldName).toEqual('foo.bar');
|
848
|
+
done();
|
849
|
+
}, done.fail);
|
652
850
|
});
|
653
851
|
});
|
654
852
|
describe('TextWidgetAnnotation', function () {
|
@@ -663,101 +861,135 @@ describe('annotation', function () {
|
|
663
861
|
afterEach(function () {
|
664
862
|
textWidgetDict = null;
|
665
863
|
});
|
666
|
-
it('should handle unknown text alignment, maximum length and flags', function () {
|
667
|
-
var textWidgetRef =
|
864
|
+
it('should handle unknown text alignment, maximum length and flags', function (done) {
|
865
|
+
var textWidgetRef = _primitives.Ref.get(124, 0);
|
866
|
+
|
668
867
|
var xref = new _test_utils.XRefMock([{
|
669
868
|
ref: textWidgetRef,
|
670
869
|
data: textWidgetDict
|
671
870
|
}]);
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
871
|
+
|
872
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
|
873
|
+
var data = _ref23.data;
|
874
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
875
|
+
expect(data.textAlignment).toEqual(null);
|
876
|
+
expect(data.maxLen).toEqual(null);
|
877
|
+
expect(data.readOnly).toEqual(false);
|
878
|
+
expect(data.multiLine).toEqual(false);
|
879
|
+
expect(data.comb).toEqual(false);
|
880
|
+
done();
|
881
|
+
}, done.fail);
|
882
|
+
});
|
883
|
+
it('should not set invalid text alignment, maximum length and flags', function (done) {
|
682
884
|
textWidgetDict.set('Q', 'center');
|
683
885
|
textWidgetDict.set('MaxLen', 'five');
|
684
886
|
textWidgetDict.set('Ff', 'readonly');
|
685
|
-
|
887
|
+
|
888
|
+
var textWidgetRef = _primitives.Ref.get(43, 0);
|
889
|
+
|
686
890
|
var xref = new _test_utils.XRefMock([{
|
687
891
|
ref: textWidgetRef,
|
688
892
|
data: textWidgetDict
|
689
893
|
}]);
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
894
|
+
|
895
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
|
896
|
+
var data = _ref24.data;
|
897
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
898
|
+
expect(data.textAlignment).toEqual(null);
|
899
|
+
expect(data.maxLen).toEqual(null);
|
900
|
+
expect(data.readOnly).toEqual(false);
|
901
|
+
expect(data.multiLine).toEqual(false);
|
902
|
+
expect(data.comb).toEqual(false);
|
903
|
+
done();
|
904
|
+
}, done.fail);
|
905
|
+
});
|
906
|
+
it('should set valid text alignment, maximum length and flags', function (done) {
|
700
907
|
textWidgetDict.set('Q', 1);
|
701
908
|
textWidgetDict.set('MaxLen', 20);
|
702
909
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
|
703
|
-
|
910
|
+
|
911
|
+
var textWidgetRef = _primitives.Ref.get(84, 0);
|
912
|
+
|
704
913
|
var xref = new _test_utils.XRefMock([{
|
705
914
|
ref: textWidgetRef,
|
706
915
|
data: textWidgetDict
|
707
916
|
}]);
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
917
|
+
|
918
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
|
919
|
+
var data = _ref25.data;
|
920
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
921
|
+
expect(data.textAlignment).toEqual(1);
|
922
|
+
expect(data.maxLen).toEqual(20);
|
923
|
+
expect(data.readOnly).toEqual(true);
|
924
|
+
expect(data.multiLine).toEqual(true);
|
925
|
+
done();
|
926
|
+
}, done.fail);
|
927
|
+
});
|
928
|
+
it('should reject comb fields without a maximum length', function (done) {
|
717
929
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
718
|
-
|
930
|
+
|
931
|
+
var textWidgetRef = _primitives.Ref.get(46, 0);
|
932
|
+
|
719
933
|
var xref = new _test_utils.XRefMock([{
|
720
934
|
ref: textWidgetRef,
|
721
935
|
data: textWidgetDict
|
722
936
|
}]);
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
937
|
+
|
938
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
|
939
|
+
var data = _ref26.data;
|
940
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
941
|
+
expect(data.comb).toEqual(false);
|
942
|
+
done();
|
943
|
+
}, done.fail);
|
727
944
|
});
|
728
|
-
it('should accept comb fields with a maximum length', function () {
|
945
|
+
it('should accept comb fields with a maximum length', function (done) {
|
729
946
|
textWidgetDict.set('MaxLen', 20);
|
730
947
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
731
|
-
|
948
|
+
|
949
|
+
var textWidgetRef = _primitives.Ref.get(46, 0);
|
950
|
+
|
732
951
|
var xref = new _test_utils.XRefMock([{
|
733
952
|
ref: textWidgetRef,
|
734
953
|
data: textWidgetDict
|
735
954
|
}]);
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
955
|
+
|
956
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
|
957
|
+
var data = _ref27.data;
|
958
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
959
|
+
expect(data.comb).toEqual(true);
|
960
|
+
done();
|
961
|
+
}, done.fail);
|
740
962
|
});
|
741
|
-
it('should only accept comb fields when the flags are valid', function () {
|
963
|
+
it('should only accept comb fields when the flags are valid', function (done) {
|
742
964
|
var invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
|
743
965
|
var flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
|
966
|
+
var promise = Promise.resolve();
|
967
|
+
|
744
968
|
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
|
-
|
969
|
+
promise = promise.then(function () {
|
970
|
+
textWidgetDict.set('MaxLen', 20);
|
971
|
+
textWidgetDict.set('Ff', flags);
|
972
|
+
|
973
|
+
var textWidgetRef = _primitives.Ref.get(93, 0);
|
974
|
+
|
975
|
+
var xref = new _test_utils.XRefMock([{
|
976
|
+
ref: textWidgetRef,
|
977
|
+
data: textWidgetDict
|
978
|
+
}]);
|
979
|
+
return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
|
980
|
+
var data = _ref28.data;
|
981
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
982
|
+
var valid = invalidFieldFlags.length === 0;
|
983
|
+
expect(data.comb).toEqual(valid);
|
984
|
+
|
985
|
+
if (!valid) {
|
986
|
+
flags -= invalidFieldFlags.pop();
|
987
|
+
}
|
988
|
+
});
|
989
|
+
});
|
760
990
|
}
|
991
|
+
|
992
|
+
promise.then(done, done.fail);
|
761
993
|
});
|
762
994
|
});
|
763
995
|
describe('ButtonWidgetAnnotation', function () {
|
@@ -772,21 +1004,52 @@ describe('annotation', function () {
|
|
772
1004
|
afterEach(function () {
|
773
1005
|
buttonWidgetDict = null;
|
774
1006
|
});
|
775
|
-
it('should handle checkboxes', function () {
|
1007
|
+
it('should handle checkboxes with export value', function (done) {
|
776
1008
|
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
777
|
-
var
|
1009
|
+
var appearanceStatesDict = new _primitives.Dict();
|
1010
|
+
var exportValueOptionsDict = new _primitives.Dict();
|
1011
|
+
exportValueOptionsDict.set('Off', 0);
|
1012
|
+
exportValueOptionsDict.set('Checked', 1);
|
1013
|
+
appearanceStatesDict.set('D', exportValueOptionsDict);
|
1014
|
+
buttonWidgetDict.set('AP', appearanceStatesDict);
|
1015
|
+
|
1016
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1017
|
+
|
778
1018
|
var xref = new _test_utils.XRefMock([{
|
779
1019
|
ref: buttonWidgetRef,
|
780
1020
|
data: buttonWidgetDict
|
781
1021
|
}]);
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
1022
|
+
|
1023
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
|
1024
|
+
var data = _ref29.data;
|
1025
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1026
|
+
expect(data.checkBox).toEqual(true);
|
1027
|
+
expect(data.fieldValue).toEqual('1');
|
1028
|
+
expect(data.radioButton).toEqual(false);
|
1029
|
+
expect(data.exportValue).toEqual('Checked');
|
1030
|
+
done();
|
1031
|
+
}, done.fail);
|
1032
|
+
});
|
1033
|
+
it('should handle checkboxes without export value', function (done) {
|
1034
|
+
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
1035
|
+
|
1036
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1037
|
+
|
1038
|
+
var xref = new _test_utils.XRefMock([{
|
1039
|
+
ref: buttonWidgetRef,
|
1040
|
+
data: buttonWidgetDict
|
1041
|
+
}]);
|
1042
|
+
|
1043
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
|
1044
|
+
var data = _ref30.data;
|
1045
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1046
|
+
expect(data.checkBox).toEqual(true);
|
1047
|
+
expect(data.fieldValue).toEqual('1');
|
1048
|
+
expect(data.radioButton).toEqual(false);
|
1049
|
+
done();
|
1050
|
+
}, done.fail);
|
1051
|
+
});
|
1052
|
+
it('should handle radio buttons with a field value', function (done) {
|
790
1053
|
var parentDict = new _primitives.Dict();
|
791
1054
|
parentDict.set('V', _primitives.Name.get('1'));
|
792
1055
|
var normalAppearanceStateDict = new _primitives.Dict();
|
@@ -796,38 +1059,48 @@ describe('annotation', function () {
|
|
796
1059
|
buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
|
797
1060
|
buttonWidgetDict.set('Parent', parentDict);
|
798
1061
|
buttonWidgetDict.set('AP', appearanceStatesDict);
|
799
|
-
|
1062
|
+
|
1063
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1064
|
+
|
800
1065
|
var xref = new _test_utils.XRefMock([{
|
801
1066
|
ref: buttonWidgetRef,
|
802
1067
|
data: buttonWidgetDict
|
803
1068
|
}]);
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
1069
|
+
|
1070
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
|
1071
|
+
var data = _ref31.data;
|
1072
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1073
|
+
expect(data.checkBox).toEqual(false);
|
1074
|
+
expect(data.radioButton).toEqual(true);
|
1075
|
+
expect(data.fieldValue).toEqual('1');
|
1076
|
+
expect(data.buttonValue).toEqual('2');
|
1077
|
+
done();
|
1078
|
+
}, done.fail);
|
1079
|
+
});
|
1080
|
+
it('should handle radio buttons without a field value', function (done) {
|
813
1081
|
var normalAppearanceStateDict = new _primitives.Dict();
|
814
1082
|
normalAppearanceStateDict.set('2', null);
|
815
1083
|
var appearanceStatesDict = new _primitives.Dict();
|
816
1084
|
appearanceStatesDict.set('N', normalAppearanceStateDict);
|
817
1085
|
buttonWidgetDict.set('Ff', _util.AnnotationFieldFlag.RADIO);
|
818
1086
|
buttonWidgetDict.set('AP', appearanceStatesDict);
|
819
|
-
|
1087
|
+
|
1088
|
+
var buttonWidgetRef = _primitives.Ref.get(124, 0);
|
1089
|
+
|
820
1090
|
var xref = new _test_utils.XRefMock([{
|
821
1091
|
ref: buttonWidgetRef,
|
822
1092
|
data: buttonWidgetDict
|
823
1093
|
}]);
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
1094
|
+
|
1095
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
|
1096
|
+
var data = _ref32.data;
|
1097
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1098
|
+
expect(data.checkBox).toEqual(false);
|
1099
|
+
expect(data.radioButton).toEqual(true);
|
1100
|
+
expect(data.fieldValue).toEqual(null);
|
1101
|
+
expect(data.buttonValue).toEqual('2');
|
1102
|
+
done();
|
1103
|
+
}, done.fail);
|
831
1104
|
});
|
832
1105
|
});
|
833
1106
|
describe('ChoiceWidgetAnnotation', function () {
|
@@ -842,21 +1115,28 @@ describe('annotation', function () {
|
|
842
1115
|
afterEach(function () {
|
843
1116
|
choiceWidgetDict = null;
|
844
1117
|
});
|
845
|
-
it('should handle missing option arrays', function () {
|
846
|
-
var choiceWidgetRef =
|
1118
|
+
it('should handle missing option arrays', function (done) {
|
1119
|
+
var choiceWidgetRef = _primitives.Ref.get(122, 0);
|
1120
|
+
|
847
1121
|
var xref = new _test_utils.XRefMock([{
|
848
1122
|
ref: choiceWidgetRef,
|
849
1123
|
data: choiceWidgetDict
|
850
1124
|
}]);
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
1125
|
+
|
1126
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
|
1127
|
+
var data = _ref33.data;
|
1128
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1129
|
+
expect(data.options).toEqual([]);
|
1130
|
+
done();
|
1131
|
+
}, done.fail);
|
855
1132
|
});
|
856
|
-
it('should handle option arrays with array elements', function () {
|
857
|
-
var optionBarRef =
|
1133
|
+
it('should handle option arrays with array elements', function (done) {
|
1134
|
+
var optionBarRef = _primitives.Ref.get(20, 0);
|
1135
|
+
|
858
1136
|
var optionBarStr = 'Bar';
|
859
|
-
|
1137
|
+
|
1138
|
+
var optionOneRef = _primitives.Ref.get(10, 0);
|
1139
|
+
|
860
1140
|
var optionOneArr = ['bar_export', optionBarRef];
|
861
1141
|
var options = [['foo_export', 'Foo'], optionOneRef];
|
862
1142
|
var expected = [{
|
@@ -867,7 +1147,9 @@ describe('annotation', function () {
|
|
867
1147
|
displayValue: 'Bar'
|
868
1148
|
}];
|
869
1149
|
choiceWidgetDict.set('Opt', options);
|
870
|
-
|
1150
|
+
|
1151
|
+
var choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1152
|
+
|
871
1153
|
var xref = new _test_utils.XRefMock([{
|
872
1154
|
ref: choiceWidgetRef,
|
873
1155
|
data: choiceWidgetDict
|
@@ -878,13 +1160,17 @@ describe('annotation', function () {
|
|
878
1160
|
ref: optionOneRef,
|
879
1161
|
data: optionOneArr
|
880
1162
|
}]);
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
1163
|
+
|
1164
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
|
1165
|
+
var data = _ref34.data;
|
1166
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1167
|
+
expect(data.options).toEqual(expected);
|
1168
|
+
done();
|
1169
|
+
}, done.fail);
|
885
1170
|
});
|
886
|
-
it('should handle option arrays with string elements', function () {
|
887
|
-
var optionBarRef =
|
1171
|
+
it('should handle option arrays with string elements', function (done) {
|
1172
|
+
var optionBarRef = _primitives.Ref.get(10, 0);
|
1173
|
+
|
888
1174
|
var optionBarStr = 'Bar';
|
889
1175
|
var options = ['Foo', optionBarRef];
|
890
1176
|
var expected = [{
|
@@ -895,7 +1181,9 @@ describe('annotation', function () {
|
|
895
1181
|
displayValue: 'Bar'
|
896
1182
|
}];
|
897
1183
|
choiceWidgetDict.set('Opt', options);
|
898
|
-
|
1184
|
+
|
1185
|
+
var choiceWidgetRef = _primitives.Ref.get(981, 0);
|
1186
|
+
|
899
1187
|
var xref = new _test_utils.XRefMock([{
|
900
1188
|
ref: choiceWidgetRef,
|
901
1189
|
data: choiceWidgetDict
|
@@ -903,12 +1191,15 @@ describe('annotation', function () {
|
|
903
1191
|
ref: optionBarRef,
|
904
1192
|
data: optionBarStr
|
905
1193
|
}]);
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
1194
|
+
|
1195
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
|
1196
|
+
var data = _ref35.data;
|
1197
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1198
|
+
expect(data.options).toEqual(expected);
|
1199
|
+
done();
|
1200
|
+
}, done.fail);
|
910
1201
|
});
|
911
|
-
it('should handle inherited option arrays (issue 8094)', function () {
|
1202
|
+
it('should handle inherited option arrays (issue 8094)', function (done) {
|
912
1203
|
var options = [['Value1', 'Description1'], ['Value2', 'Description2']];
|
913
1204
|
var expected = [{
|
914
1205
|
exportValue: 'Value1',
|
@@ -920,134 +1211,182 @@ describe('annotation', function () {
|
|
920
1211
|
var parentDict = new _primitives.Dict();
|
921
1212
|
parentDict.set('Opt', options);
|
922
1213
|
choiceWidgetDict.set('Parent', parentDict);
|
923
|
-
|
1214
|
+
|
1215
|
+
var choiceWidgetRef = _primitives.Ref.get(123, 0);
|
1216
|
+
|
924
1217
|
var xref = new _test_utils.XRefMock([{
|
925
1218
|
ref: choiceWidgetRef,
|
926
1219
|
data: choiceWidgetDict
|
927
1220
|
}]);
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
1221
|
+
|
1222
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
|
1223
|
+
var data = _ref36.data;
|
1224
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1225
|
+
expect(data.options).toEqual(expected);
|
1226
|
+
done();
|
1227
|
+
}, done.fail);
|
932
1228
|
});
|
933
|
-
it('should sanitize display values in option arrays (issue 8947)', function () {
|
1229
|
+
it('should sanitize display values in option arrays (issue 8947)', function (done) {
|
934
1230
|
var options = ['\xFE\xFF\x00F\x00o\x00o'];
|
935
1231
|
var expected = [{
|
936
1232
|
exportValue: '\xFE\xFF\x00F\x00o\x00o',
|
937
1233
|
displayValue: 'Foo'
|
938
1234
|
}];
|
939
1235
|
choiceWidgetDict.set('Opt', options);
|
940
|
-
|
1236
|
+
|
1237
|
+
var choiceWidgetRef = _primitives.Ref.get(984, 0);
|
1238
|
+
|
941
1239
|
var xref = new _test_utils.XRefMock([{
|
942
1240
|
ref: choiceWidgetRef,
|
943
1241
|
data: choiceWidgetDict
|
944
1242
|
}]);
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
1243
|
+
|
1244
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
|
1245
|
+
var data = _ref37.data;
|
1246
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1247
|
+
expect(data.options).toEqual(expected);
|
1248
|
+
done();
|
1249
|
+
}, done.fail);
|
949
1250
|
});
|
950
|
-
it('should handle array field values', function () {
|
1251
|
+
it('should handle array field values', function (done) {
|
951
1252
|
var fieldValue = ['Foo', 'Bar'];
|
952
1253
|
choiceWidgetDict.set('V', fieldValue);
|
953
|
-
|
1254
|
+
|
1255
|
+
var choiceWidgetRef = _primitives.Ref.get(968, 0);
|
1256
|
+
|
954
1257
|
var xref = new _test_utils.XRefMock([{
|
955
1258
|
ref: choiceWidgetRef,
|
956
1259
|
data: choiceWidgetDict
|
957
1260
|
}]);
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
1261
|
+
|
1262
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
|
1263
|
+
var data = _ref38.data;
|
1264
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1265
|
+
expect(data.fieldValue).toEqual(fieldValue);
|
1266
|
+
done();
|
1267
|
+
}, done.fail);
|
962
1268
|
});
|
963
|
-
it('should handle string field values', function () {
|
1269
|
+
it('should handle string field values', function (done) {
|
964
1270
|
var fieldValue = 'Foo';
|
965
1271
|
choiceWidgetDict.set('V', fieldValue);
|
966
|
-
|
1272
|
+
|
1273
|
+
var choiceWidgetRef = _primitives.Ref.get(978, 0);
|
1274
|
+
|
967
1275
|
var xref = new _test_utils.XRefMock([{
|
968
1276
|
ref: choiceWidgetRef,
|
969
1277
|
data: choiceWidgetDict
|
970
1278
|
}]);
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1279
|
+
|
1280
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
|
1281
|
+
var data = _ref39.data;
|
1282
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1283
|
+
expect(data.fieldValue).toEqual([fieldValue]);
|
1284
|
+
done();
|
1285
|
+
}, done.fail);
|
975
1286
|
});
|
976
|
-
it('should handle unknown flags', function () {
|
977
|
-
var choiceWidgetRef =
|
1287
|
+
it('should handle unknown flags', function (done) {
|
1288
|
+
var choiceWidgetRef = _primitives.Ref.get(166, 0);
|
1289
|
+
|
978
1290
|
var xref = new _test_utils.XRefMock([{
|
979
1291
|
ref: choiceWidgetRef,
|
980
1292
|
data: choiceWidgetDict
|
981
1293
|
}]);
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
1294
|
+
|
1295
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
|
1296
|
+
var data = _ref40.data;
|
1297
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1298
|
+
expect(data.readOnly).toEqual(false);
|
1299
|
+
expect(data.combo).toEqual(false);
|
1300
|
+
expect(data.multiSelect).toEqual(false);
|
1301
|
+
done();
|
1302
|
+
}, done.fail);
|
1303
|
+
});
|
1304
|
+
it('should not set invalid flags', function (done) {
|
990
1305
|
choiceWidgetDict.set('Ff', 'readonly');
|
991
|
-
|
1306
|
+
|
1307
|
+
var choiceWidgetRef = _primitives.Ref.get(165, 0);
|
1308
|
+
|
992
1309
|
var xref = new _test_utils.XRefMock([{
|
993
1310
|
ref: choiceWidgetRef,
|
994
1311
|
data: choiceWidgetDict
|
995
1312
|
}]);
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1313
|
+
|
1314
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
|
1315
|
+
var data = _ref41.data;
|
1316
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1317
|
+
expect(data.readOnly).toEqual(false);
|
1318
|
+
expect(data.combo).toEqual(false);
|
1319
|
+
expect(data.multiSelect).toEqual(false);
|
1320
|
+
done();
|
1321
|
+
}, done.fail);
|
1322
|
+
});
|
1323
|
+
it('should set valid flags', function (done) {
|
1004
1324
|
choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
|
1005
|
-
|
1325
|
+
|
1326
|
+
var choiceWidgetRef = _primitives.Ref.get(512, 0);
|
1327
|
+
|
1006
1328
|
var xref = new _test_utils.XRefMock([{
|
1007
1329
|
ref: choiceWidgetRef,
|
1008
1330
|
data: choiceWidgetDict
|
1009
1331
|
}]);
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1332
|
+
|
1333
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
|
1334
|
+
var data = _ref42.data;
|
1335
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1336
|
+
expect(data.readOnly).toEqual(true);
|
1337
|
+
expect(data.combo).toEqual(true);
|
1338
|
+
expect(data.multiSelect).toEqual(true);
|
1339
|
+
done();
|
1340
|
+
}, done.fail);
|
1016
1341
|
});
|
1017
1342
|
});
|
1018
1343
|
describe('LineAnnotation', function () {
|
1019
|
-
it('should set the line coordinates', function () {
|
1344
|
+
it('should set the line coordinates', function (done) {
|
1020
1345
|
var lineDict = new _primitives.Dict();
|
1021
1346
|
lineDict.set('Type', _primitives.Name.get('Annot'));
|
1022
1347
|
lineDict.set('Subtype', _primitives.Name.get('Line'));
|
1023
1348
|
lineDict.set('L', [1, 2, 3, 4]);
|
1024
|
-
|
1349
|
+
|
1350
|
+
var lineRef = _primitives.Ref.get(122, 0);
|
1351
|
+
|
1025
1352
|
var xref = new _test_utils.XRefMock([{
|
1026
1353
|
ref: lineRef,
|
1027
1354
|
data: lineDict
|
1028
1355
|
}]);
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1356
|
+
|
1357
|
+
_annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
|
1358
|
+
var data = _ref43.data;
|
1359
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
|
1360
|
+
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
1361
|
+
done();
|
1362
|
+
}, done.fail);
|
1033
1363
|
});
|
1034
1364
|
});
|
1035
1365
|
describe('FileAttachmentAnnotation', function () {
|
1036
|
-
it('should correctly parse a file attachment', function () {
|
1366
|
+
it('should correctly parse a file attachment', function (done) {
|
1037
1367
|
var fileStream = new _stream.StringStream('<<\n' + '/Type /EmbeddedFile\n' + '/Subtype /text#2Fplain\n' + '>>\n' + 'stream\n' + 'Test attachment' + 'endstream\n');
|
1038
|
-
var
|
1039
|
-
|
1040
|
-
|
1368
|
+
var parser = new _parser.Parser({
|
1369
|
+
lexer: new _parser.Lexer(fileStream),
|
1370
|
+
xref: null,
|
1371
|
+
allowStreams: true
|
1372
|
+
});
|
1373
|
+
|
1374
|
+
var fileStreamRef = _primitives.Ref.get(18, 0);
|
1375
|
+
|
1041
1376
|
var fileStreamDict = parser.getObj();
|
1042
1377
|
var embeddedFileDict = new _primitives.Dict();
|
1043
1378
|
embeddedFileDict.set('F', fileStreamRef);
|
1044
|
-
|
1379
|
+
|
1380
|
+
var fileSpecRef = _primitives.Ref.get(19, 0);
|
1381
|
+
|
1045
1382
|
var fileSpecDict = new _primitives.Dict();
|
1046
1383
|
fileSpecDict.set('Type', _primitives.Name.get('Filespec'));
|
1047
1384
|
fileSpecDict.set('Desc', '');
|
1048
1385
|
fileSpecDict.set('EF', embeddedFileDict);
|
1049
1386
|
fileSpecDict.set('UF', 'Test.txt');
|
1050
|
-
|
1387
|
+
|
1388
|
+
var fileAttachmentRef = _primitives.Ref.get(20, 0);
|
1389
|
+
|
1051
1390
|
var fileAttachmentDict = new _primitives.Dict();
|
1052
1391
|
fileAttachmentDict.set('Type', _primitives.Name.get('Annot'));
|
1053
1392
|
fileAttachmentDict.set('Subtype', _primitives.Name.get('FileAttachment'));
|
@@ -1067,15 +1406,70 @@ describe('annotation', function () {
|
|
1067
1406
|
embeddedFileDict.assignXref(xref);
|
1068
1407
|
fileSpecDict.assignXref(xref);
|
1069
1408
|
fileAttachmentDict.assignXref(xref);
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1409
|
+
|
1410
|
+
_annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
|
1411
|
+
var data = _ref44.data;
|
1412
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
|
1413
|
+
expect(data.file.filename).toEqual('Test.txt');
|
1414
|
+
expect(data.file.content).toEqual((0, _util.stringToBytes)('Test attachment'));
|
1415
|
+
done();
|
1416
|
+
}, done.fail);
|
1075
1417
|
});
|
1076
1418
|
});
|
1077
1419
|
describe('PopupAnnotation', function () {
|
1078
|
-
it('should inherit
|
1420
|
+
it('should inherit properties from its parent', function (done) {
|
1421
|
+
var parentDict = new _primitives.Dict();
|
1422
|
+
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1423
|
+
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
1424
|
+
parentDict.set('M', 'D:20190423');
|
1425
|
+
parentDict.set('C', [0, 0, 1]);
|
1426
|
+
var popupDict = new _primitives.Dict();
|
1427
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
1428
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1429
|
+
popupDict.set('Parent', parentDict);
|
1430
|
+
|
1431
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1432
|
+
|
1433
|
+
var xref = new _test_utils.XRefMock([{
|
1434
|
+
ref: popupRef,
|
1435
|
+
data: popupDict
|
1436
|
+
}]);
|
1437
|
+
|
1438
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
|
1439
|
+
var data = _ref45.data,
|
1440
|
+
viewable = _ref45.viewable;
|
1441
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1442
|
+
expect(data.modificationDate).toEqual('D:20190423');
|
1443
|
+
expect(data.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
1444
|
+
done();
|
1445
|
+
}, done.fail);
|
1446
|
+
});
|
1447
|
+
it('should handle missing parent properties', function (done) {
|
1448
|
+
var parentDict = new _primitives.Dict();
|
1449
|
+
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1450
|
+
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
1451
|
+
var popupDict = new _primitives.Dict();
|
1452
|
+
popupDict.set('Type', _primitives.Name.get('Annot'));
|
1453
|
+
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1454
|
+
popupDict.set('Parent', parentDict);
|
1455
|
+
|
1456
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1457
|
+
|
1458
|
+
var xref = new _test_utils.XRefMock([{
|
1459
|
+
ref: popupRef,
|
1460
|
+
data: popupDict
|
1461
|
+
}]);
|
1462
|
+
|
1463
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
|
1464
|
+
var data = _ref46.data,
|
1465
|
+
viewable = _ref46.viewable;
|
1466
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1467
|
+
expect(data.modificationDate).toEqual(null);
|
1468
|
+
expect(data.color).toEqual(null);
|
1469
|
+
done();
|
1470
|
+
}, done.fail);
|
1471
|
+
});
|
1472
|
+
it('should inherit the parent flags when the Popup is not viewable, ' + 'but the parent is (PR 7352)', function (done) {
|
1079
1473
|
var parentDict = new _primitives.Dict();
|
1080
1474
|
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1081
1475
|
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
@@ -1085,16 +1479,91 @@ describe('annotation', function () {
|
|
1085
1479
|
popupDict.set('Subtype', _primitives.Name.get('Popup'));
|
1086
1480
|
popupDict.set('F', 25);
|
1087
1481
|
popupDict.set('Parent', parentDict);
|
1088
|
-
|
1482
|
+
|
1483
|
+
var popupRef = _primitives.Ref.get(13, 0);
|
1484
|
+
|
1089
1485
|
var xref = new _test_utils.XRefMock([{
|
1090
1486
|
ref: popupRef,
|
1091
1487
|
data: popupDict
|
1092
1488
|
}]);
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1489
|
+
|
1490
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
|
1491
|
+
var data = _ref47.data,
|
1492
|
+
viewable = _ref47.viewable;
|
1493
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1494
|
+
expect(data.annotationFlags).toEqual(25);
|
1495
|
+
expect(viewable).toEqual(true);
|
1496
|
+
done();
|
1497
|
+
}, done.fail);
|
1498
|
+
});
|
1499
|
+
});
|
1500
|
+
describe('InkAnnotation', function () {
|
1501
|
+
it('should handle a single ink list', function (done) {
|
1502
|
+
var inkDict = new _primitives.Dict();
|
1503
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1504
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1505
|
+
inkDict.set('InkList', [[1, 1, 1, 2, 2, 2, 3, 3]]);
|
1506
|
+
|
1507
|
+
var inkRef = _primitives.Ref.get(142, 0);
|
1508
|
+
|
1509
|
+
var xref = new _test_utils.XRefMock([{
|
1510
|
+
ref: inkRef,
|
1511
|
+
data: inkDict
|
1512
|
+
}]);
|
1513
|
+
|
1514
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref48) {
|
1515
|
+
var data = _ref48.data;
|
1516
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1517
|
+
expect(data.inkLists.length).toEqual(1);
|
1518
|
+
expect(data.inkLists[0]).toEqual([{
|
1519
|
+
x: 1,
|
1520
|
+
y: 1
|
1521
|
+
}, {
|
1522
|
+
x: 1,
|
1523
|
+
y: 2
|
1524
|
+
}, {
|
1525
|
+
x: 2,
|
1526
|
+
y: 2
|
1527
|
+
}, {
|
1528
|
+
x: 3,
|
1529
|
+
y: 3
|
1530
|
+
}]);
|
1531
|
+
done();
|
1532
|
+
}, done.fail);
|
1533
|
+
});
|
1534
|
+
it('should handle multiple ink lists', function (done) {
|
1535
|
+
var inkDict = new _primitives.Dict();
|
1536
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1537
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1538
|
+
inkDict.set('InkList', [[1, 1, 1, 2], [3, 3, 4, 5]]);
|
1539
|
+
|
1540
|
+
var inkRef = _primitives.Ref.get(143, 0);
|
1541
|
+
|
1542
|
+
var xref = new _test_utils.XRefMock([{
|
1543
|
+
ref: inkRef,
|
1544
|
+
data: inkDict
|
1545
|
+
}]);
|
1546
|
+
|
1547
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref49) {
|
1548
|
+
var data = _ref49.data;
|
1549
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1550
|
+
expect(data.inkLists.length).toEqual(2);
|
1551
|
+
expect(data.inkLists[0]).toEqual([{
|
1552
|
+
x: 1,
|
1553
|
+
y: 1
|
1554
|
+
}, {
|
1555
|
+
x: 1,
|
1556
|
+
y: 2
|
1557
|
+
}]);
|
1558
|
+
expect(data.inkLists[1]).toEqual([{
|
1559
|
+
x: 3,
|
1560
|
+
y: 3
|
1561
|
+
}, {
|
1562
|
+
x: 4,
|
1563
|
+
y: 5
|
1564
|
+
}]);
|
1565
|
+
done();
|
1566
|
+
}, done.fail);
|
1098
1567
|
});
|
1099
1568
|
});
|
1100
1569
|
});
|