pdfjs-dist 2.0.487 → 2.1.266
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/bower.json +1 -1
- package/build/pdf.js +15564 -9476
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +46644 -36309
- 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 +11430 -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 +406 -131
- 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 +376 -53
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +387 -149
- package/lib/core/cmap.js +310 -75
- package/lib/core/colorspace.js +874 -594
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +545 -260
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +725 -147
- package/lib/core/font_renderer.js +360 -91
- package/lib/core/fonts.js +791 -186
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +3 -2
- package/lib/core/image.js +168 -61
- 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 +252 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +4 -4
- package/lib/core/murmurhash3.js +24 -6
- package/lib/core/obj.js +1137 -475
- package/lib/core/operator_list.js +108 -6
- package/lib/core/parser.js +321 -68
- package/lib/core/pattern.js +145 -13
- package/lib/core/pdf_manager.js +321 -133
- package/lib/core/primitives.js +75 -22
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +10 -10
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +31 -4
- package/lib/core/worker.js +210 -66
- package/lib/display/annotation_layer.js +361 -123
- package/lib/display/api.js +1454 -729
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +324 -29
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/dom_utils.js +226 -41
- package/lib/display/fetch_stream.js +208 -84
- package/lib/display/font_loader.js +465 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +216 -51
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +352 -169
- package/lib/display/pattern_helper.js +58 -7
- package/lib/display/svg.js +242 -29
- package/lib/display/text_layer.js +132 -18
- package/lib/display/transport_stream.js +171 -42
- 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 +57 -4
- package/lib/pdf.js +21 -4
- 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 +295 -650
- package/lib/test/unit/annotation_spec.js +629 -345
- package/lib/test/unit/api_spec.js +555 -253
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +40 -11
- package/lib/test/unit/clitests_helper.js +9 -7
- package/lib/test/unit/cmap_spec.js +80 -26
- package/lib/test/unit/colorspace_spec.js +99 -52
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +41 -53
- package/lib/test/unit/display_svg_spec.js +33 -17
- package/lib/test/unit/document_spec.js +3 -3
- package/lib/test/unit/dom_utils_spec.js +9 -9
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +34 -9
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +31 -18
- 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 +20 -5
- package/lib/test/unit/network_utils_spec.js +41 -14
- package/lib/test/unit/node_stream_spec.js +51 -27
- package/lib/test/unit/parser_spec.js +35 -8
- 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 +24 -4
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +90 -27
- 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 +452 -14
- package/lib/test/unit/unicode_spec.js +14 -11
- package/lib/test/unit/util_spec.js +131 -9
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1240 -582
- package/lib/web/app_options.js +71 -41
- package/lib/web/base_viewer.js +508 -179
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +31 -13
- package/lib/web/firefox_print_service.js +17 -9
- package/lib/web/firefoxcom.js +283 -79
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +26 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +21 -13
- 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 +80 -30
- 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 +137 -76
- package/lib/web/pdf_outline_viewer.js +73 -22
- package/lib/web/pdf_page_view.js +196 -63
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +57 -11
- package/lib/web/pdf_rendering_queue.js +27 -5
- package/lib/web/pdf_sidebar.js +120 -67
- 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 +103 -32
- package/lib/web/pdf_thumbnail_viewer.js +64 -24
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +275 -80
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +162 -65
- 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 +58 -1
- package/web/pdf_viewer.js +6346 -3919
- package/web/pdf_viewer.js.map +1 -1
- 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 2018 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,38 +19,81 @@
|
|
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 _primitives = require(
|
28
|
+
var _primitives = require("../../core/primitives");
|
29
29
|
|
30
|
-
var _parser = require(
|
30
|
+
var _parser = require("../../core/parser");
|
31
31
|
|
32
|
-
var _stream = require(
|
32
|
+
var _stream = require("../../core/stream");
|
33
33
|
|
34
|
-
var _test_utils = require(
|
34
|
+
var _test_utils = require("./test_utils");
|
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
|
+
});
|
64
|
+
}
|
65
|
+
}]);
|
66
|
+
|
67
|
+
return PDFManagerMock;
|
68
|
+
}();
|
69
|
+
|
70
|
+
var IdFactoryMock =
|
71
|
+
/*#__PURE__*/
|
72
|
+
function () {
|
73
|
+
function IdFactoryMock(params) {
|
74
|
+
_classCallCheck(this, IdFactoryMock);
|
75
|
+
|
76
|
+
this.uniquePrefix = params.prefix || 'p0_';
|
77
|
+
this.idCounters = {
|
78
|
+
obj: params.startObjId || 0
|
79
|
+
};
|
80
|
+
}
|
81
|
+
|
82
|
+
_createClass(IdFactoryMock, [{
|
83
|
+
key: "createObjId",
|
84
|
+
value: function createObjId() {
|
85
|
+
return this.uniquePrefix + ++this.idCounters.obj;
|
47
86
|
}
|
48
|
-
};
|
49
|
-
|
50
|
-
|
87
|
+
}]);
|
88
|
+
|
89
|
+
return IdFactoryMock;
|
90
|
+
}();
|
91
|
+
|
51
92
|
var pdfManagerMock, idFactoryMock;
|
52
93
|
beforeAll(function (done) {
|
53
|
-
pdfManagerMock = new PDFManagerMock({
|
94
|
+
pdfManagerMock = new PDFManagerMock({
|
95
|
+
docBaseUrl: null
|
96
|
+
});
|
54
97
|
idFactoryMock = new IdFactoryMock({});
|
55
98
|
done();
|
56
99
|
});
|
@@ -59,7 +102,7 @@ describe('annotation', function () {
|
|
59
102
|
idFactoryMock = null;
|
60
103
|
});
|
61
104
|
describe('AnnotationFactory', function () {
|
62
|
-
it('should get id for annotation', function () {
|
105
|
+
it('should get id for annotation', function (done) {
|
63
106
|
var annotationDict = new _primitives.Dict();
|
64
107
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
65
108
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
@@ -68,12 +111,15 @@ describe('annotation', function () {
|
|
68
111
|
ref: annotationRef,
|
69
112
|
data: annotationDict
|
70
113
|
}]);
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
114
|
+
|
115
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref) {
|
116
|
+
var data = _ref.data;
|
117
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
118
|
+
expect(data.id).toEqual('10R');
|
119
|
+
done();
|
120
|
+
}, done.fail);
|
75
121
|
});
|
76
|
-
it('should handle, and get fallback
|
122
|
+
it('should handle, and get fallback IDs for, annotations that are not ' + 'indirect objects (issue 7569)', function (done) {
|
77
123
|
var annotationDict = new _primitives.Dict();
|
78
124
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
79
125
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
@@ -82,16 +128,22 @@ describe('annotation', function () {
|
|
82
128
|
prefix: 'p0_',
|
83
129
|
startObjId: 0
|
84
130
|
});
|
85
|
-
|
86
|
-
var
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
131
|
+
|
132
|
+
var annotation1 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref2) {
|
133
|
+
var data = _ref2.data;
|
134
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
135
|
+
expect(data.id).toEqual('annot_p0_1');
|
136
|
+
});
|
137
|
+
|
138
|
+
var annotation2 = _annotation.AnnotationFactory.create(xref, annotationDict, pdfManagerMock, idFactory).then(function (_ref3) {
|
139
|
+
var data = _ref3.data;
|
140
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
141
|
+
expect(data.id).toEqual('annot_p0_2');
|
142
|
+
});
|
143
|
+
|
144
|
+
Promise.all([annotation1, annotation2]).then(done, done.fail);
|
145
|
+
});
|
146
|
+
it('should handle missing /Subtype', function (done) {
|
95
147
|
var annotationDict = new _primitives.Dict();
|
96
148
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
97
149
|
var annotationRef = new _primitives.Ref(1, 0);
|
@@ -99,9 +151,12 @@ describe('annotation', function () {
|
|
99
151
|
ref: annotationRef,
|
100
152
|
data: annotationDict
|
101
153
|
}]);
|
102
|
-
|
103
|
-
|
104
|
-
|
154
|
+
|
155
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref4) {
|
156
|
+
var data = _ref4.data;
|
157
|
+
expect(data.annotationType).toBeUndefined();
|
158
|
+
done();
|
159
|
+
}, done.fail);
|
105
160
|
});
|
106
161
|
});
|
107
162
|
describe('Annotation', function () {
|
@@ -155,7 +210,7 @@ describe('annotation', function () {
|
|
155
210
|
ref: ref
|
156
211
|
});
|
157
212
|
annotation.setColor('red');
|
158
|
-
expect(annotation.color).toEqual(new
|
213
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
159
214
|
});
|
160
215
|
it('should set and get a transparent color', function () {
|
161
216
|
var annotation = new _annotation.Annotation({
|
@@ -171,7 +226,7 @@ describe('annotation', function () {
|
|
171
226
|
ref: ref
|
172
227
|
});
|
173
228
|
annotation.setColor([0.4]);
|
174
|
-
expect(annotation.color).toEqual(new
|
229
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([102, 102, 102]));
|
175
230
|
});
|
176
231
|
it('should set and get an RGB color', function () {
|
177
232
|
var annotation = new _annotation.Annotation({
|
@@ -179,7 +234,7 @@ describe('annotation', function () {
|
|
179
234
|
ref: ref
|
180
235
|
});
|
181
236
|
annotation.setColor([0, 0, 1]);
|
182
|
-
expect(annotation.color).toEqual(new
|
237
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 255]));
|
183
238
|
});
|
184
239
|
it('should set and get a CMYK color', function () {
|
185
240
|
var annotation = new _annotation.Annotation({
|
@@ -187,7 +242,7 @@ describe('annotation', function () {
|
|
187
242
|
ref: ref
|
188
243
|
});
|
189
244
|
annotation.setColor([0.1, 0.92, 0.84, 0.02]);
|
190
|
-
expect(annotation.color).toEqual(new
|
245
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([234, 59, 48]));
|
191
246
|
});
|
192
247
|
it('should not set and get an invalid color', function () {
|
193
248
|
var annotation = new _annotation.Annotation({
|
@@ -195,7 +250,7 @@ describe('annotation', function () {
|
|
195
250
|
ref: ref
|
196
251
|
});
|
197
252
|
annotation.setColor([0.4, 0.6]);
|
198
|
-
expect(annotation.color).toEqual(new
|
253
|
+
expect(annotation.color).toEqual(new Uint8ClampedArray([0, 0, 0]));
|
199
254
|
});
|
200
255
|
});
|
201
256
|
describe('AnnotationBorderStyle', function () {
|
@@ -209,6 +264,14 @@ describe('annotation', function () {
|
|
209
264
|
borderStyle.setWidth('three');
|
210
265
|
expect(borderStyle.width).toEqual(1);
|
211
266
|
});
|
267
|
+
it('should set the width to zero, when the input is a `Name` (issue 10385)', function () {
|
268
|
+
var borderStyleZero = new _annotation.AnnotationBorderStyle();
|
269
|
+
borderStyleZero.setWidth(_primitives.Name.get('0'));
|
270
|
+
var borderStyleFive = new _annotation.AnnotationBorderStyle();
|
271
|
+
borderStyleFive.setWidth(_primitives.Name.get('5'));
|
272
|
+
expect(borderStyleZero.width).toEqual(0);
|
273
|
+
expect(borderStyleFive.width).toEqual(0);
|
274
|
+
});
|
212
275
|
it('should set and get a valid style', function () {
|
213
276
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
214
277
|
borderStyle.setStyle(_primitives.Name.get('D'));
|
@@ -244,14 +307,14 @@ describe('annotation', function () {
|
|
244
307
|
borderStyle.setVerticalCornerRadius(3);
|
245
308
|
expect(borderStyle.verticalCornerRadius).toEqual(3);
|
246
309
|
});
|
247
|
-
it('should not set and get an invalid
|
310
|
+
it('should not set and get an invalid vertical corner radius', function () {
|
248
311
|
var borderStyle = new _annotation.AnnotationBorderStyle();
|
249
312
|
borderStyle.setVerticalCornerRadius('three');
|
250
313
|
expect(borderStyle.verticalCornerRadius).toEqual(0);
|
251
314
|
});
|
252
315
|
});
|
253
316
|
describe('LinkAnnotation', function () {
|
254
|
-
it('should correctly parse a URI action', function () {
|
317
|
+
it('should correctly parse a URI action', function (done) {
|
255
318
|
var actionDict = new _primitives.Dict();
|
256
319
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
257
320
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -265,14 +328,17 @@ describe('annotation', function () {
|
|
265
328
|
ref: annotationRef,
|
266
329
|
data: annotationDict
|
267
330
|
}]);
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
331
|
+
|
332
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref5) {
|
333
|
+
var data = _ref5.data;
|
334
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
335
|
+
expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
336
|
+
expect(data.unsafeUrl).toEqual('http://www.ctan.org/tex-archive/info/lshort');
|
337
|
+
expect(data.dest).toBeUndefined();
|
338
|
+
done();
|
339
|
+
}, done.fail);
|
340
|
+
});
|
341
|
+
it('should correctly parse a URI action, where the URI entry ' + 'is missing a protocol', function (done) {
|
276
342
|
var actionDict = new _primitives.Dict();
|
277
343
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
278
344
|
actionDict.set('S', _primitives.Name.get('URI'));
|
@@ -286,14 +352,17 @@ describe('annotation', function () {
|
|
286
352
|
ref: annotationRef,
|
287
353
|
data: annotationDict
|
288
354
|
}]);
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
355
|
+
|
356
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref6) {
|
357
|
+
var data = _ref6.data;
|
358
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
359
|
+
expect(data.url).toEqual('http://www.hmrc.gov.uk/');
|
360
|
+
expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk');
|
361
|
+
expect(data.dest).toBeUndefined();
|
362
|
+
done();
|
363
|
+
}, done.fail);
|
364
|
+
});
|
365
|
+
it('should correctly parse a URI action, where the URI entry ' + 'has an incorrect encoding (bug 1122280)', function (done) {
|
297
366
|
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
367
|
var lexer = new _parser.Lexer(actionStream);
|
299
368
|
var parser = new _parser.Parser(lexer);
|
@@ -307,14 +376,17 @@ describe('annotation', function () {
|
|
307
376
|
ref: annotationRef,
|
308
377
|
data: annotationDict
|
309
378
|
}]);
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
379
|
+
|
380
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref7) {
|
381
|
+
var data = _ref7.data;
|
382
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
383
|
+
expect(data.url).toEqual(new URL((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4')).href);
|
384
|
+
expect(data.unsafeUrl).toEqual((0, _util.stringToUTF8String)('http://www.example.com/\xC3\xBC\xC3\xB6\xC3\xA4'));
|
385
|
+
expect(data.dest).toBeUndefined();
|
386
|
+
done();
|
387
|
+
}, done.fail);
|
388
|
+
});
|
389
|
+
it('should correctly parse a GoTo action', function (done) {
|
318
390
|
var actionDict = new _primitives.Dict();
|
319
391
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
320
392
|
actionDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -328,14 +400,17 @@ describe('annotation', function () {
|
|
328
400
|
ref: annotationRef,
|
329
401
|
data: annotationDict
|
330
402
|
}]);
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
403
|
+
|
404
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref8) {
|
405
|
+
var data = _ref8.data;
|
406
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
407
|
+
expect(data.url).toBeUndefined();
|
408
|
+
expect(data.unsafeUrl).toBeUndefined();
|
409
|
+
expect(data.dest).toEqual('page.157');
|
410
|
+
done();
|
411
|
+
}, done.fail);
|
412
|
+
});
|
413
|
+
it('should correctly parse a GoToR action, where the FileSpec entry ' + 'is a string containing a relative URL', function (done) {
|
339
414
|
var actionDict = new _primitives.Dict();
|
340
415
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
341
416
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -351,15 +426,18 @@ describe('annotation', function () {
|
|
351
426
|
ref: annotationRef,
|
352
427
|
data: annotationDict
|
353
428
|
}]);
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
429
|
+
|
430
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref9) {
|
431
|
+
var data = _ref9.data;
|
432
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
433
|
+
expect(data.url).toBeUndefined();
|
434
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
435
|
+
expect(data.dest).toBeUndefined();
|
436
|
+
expect(data.newWindow).toEqual(true);
|
437
|
+
done();
|
438
|
+
}, done.fail);
|
439
|
+
});
|
440
|
+
it('should correctly parse a GoToR action, containing a relative URL, ' + 'with the "docBaseUrl" parameter specified', function (done) {
|
363
441
|
var actionDict = new _primitives.Dict();
|
364
442
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
365
443
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -374,15 +452,20 @@ describe('annotation', function () {
|
|
374
452
|
ref: annotationRef,
|
375
453
|
data: annotationDict
|
376
454
|
}]);
|
377
|
-
var pdfManager = new PDFManagerMock({
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
455
|
+
var pdfManager = new PDFManagerMock({
|
456
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
457
|
+
});
|
458
|
+
|
459
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref10) {
|
460
|
+
var data = _ref10.data;
|
461
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
462
|
+
expect(data.url).toEqual('http://www.example.com/0013/001346/134685E.pdf#4.3');
|
463
|
+
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3');
|
464
|
+
expect(data.dest).toBeUndefined();
|
465
|
+
done();
|
466
|
+
}, done.fail);
|
467
|
+
});
|
468
|
+
it('should correctly parse a GoToR action, with named destination', function (done) {
|
386
469
|
var actionDict = new _primitives.Dict();
|
387
470
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
388
471
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -397,15 +480,18 @@ describe('annotation', function () {
|
|
397
480
|
ref: annotationRef,
|
398
481
|
data: annotationDict
|
399
482
|
}]);
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
483
|
+
|
484
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref11) {
|
485
|
+
var data = _ref11.data;
|
486
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
487
|
+
expect(data.url).toEqual('http://www.example.com/test.pdf#15');
|
488
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#15');
|
489
|
+
expect(data.dest).toBeUndefined();
|
490
|
+
expect(data.newWindow).toBeFalsy();
|
491
|
+
done();
|
492
|
+
}, done.fail);
|
493
|
+
});
|
494
|
+
it('should correctly parse a GoToR action, with explicit destination array', function (done) {
|
409
495
|
var actionDict = new _primitives.Dict();
|
410
496
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
411
497
|
actionDict.set('S', _primitives.Name.get('GoToR'));
|
@@ -420,15 +506,18 @@ describe('annotation', function () {
|
|
420
506
|
ref: annotationRef,
|
421
507
|
data: annotationDict
|
422
508
|
}]);
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
509
|
+
|
510
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref12) {
|
511
|
+
var data = _ref12.data;
|
512
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
513
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]').href);
|
514
|
+
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + '[14,{"name":"XYZ"},null,298.043,null]');
|
515
|
+
expect(data.dest).toBeUndefined();
|
516
|
+
expect(data.newWindow).toBeFalsy();
|
517
|
+
done();
|
518
|
+
}, done.fail);
|
519
|
+
});
|
520
|
+
it('should correctly parse a Launch action, where the FileSpec dict ' + 'contains a relative URL, with the "docBaseUrl" parameter specified', function (done) {
|
432
521
|
var fileSpecDict = new _primitives.Dict();
|
433
522
|
fileSpecDict.set('Type', _primitives.Name.get('FileSpec'));
|
434
523
|
fileSpecDict.set('F', 'Part II/Part II.pdf');
|
@@ -447,16 +536,21 @@ describe('annotation', function () {
|
|
447
536
|
ref: annotationRef,
|
448
537
|
data: annotationDict
|
449
538
|
}]);
|
450
|
-
var pdfManager = new PDFManagerMock({
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
539
|
+
var pdfManager = new PDFManagerMock({
|
540
|
+
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
541
|
+
});
|
542
|
+
|
543
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManager, idFactoryMock).then(function (_ref13) {
|
544
|
+
var data = _ref13.data;
|
545
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
546
|
+
expect(data.url).toEqual(new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
|
547
|
+
expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
|
548
|
+
expect(data.dest).toBeUndefined();
|
549
|
+
expect(data.newWindow).toEqual(true);
|
550
|
+
done();
|
551
|
+
}, done.fail);
|
552
|
+
});
|
553
|
+
it('should recover valid URLs from JavaScript actions having certain ' + 'white-listed formats', function (done) {
|
460
554
|
function checkJsAction(params) {
|
461
555
|
var jsEntry = params.jsEntry;
|
462
556
|
var expectedUrl = params.expectedUrl;
|
@@ -475,34 +569,37 @@ describe('annotation', function () {
|
|
475
569
|
ref: annotationRef,
|
476
570
|
data: annotationDict
|
477
571
|
}]);
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
572
|
+
return _annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref14) {
|
573
|
+
var data = _ref14.data;
|
574
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
575
|
+
expect(data.url).toEqual(expectedUrl);
|
576
|
+
expect(data.unsafeUrl).toEqual(expectedUnsafeUrl);
|
577
|
+
expect(data.dest).toBeUndefined();
|
578
|
+
expect(data.newWindow).toEqual(expectedNewWindow);
|
579
|
+
});
|
485
580
|
}
|
486
|
-
|
581
|
+
|
582
|
+
var annotation1 = checkJsAction({
|
487
583
|
jsEntry: 'function someFun() { return "qwerty"; } someFun();',
|
488
584
|
expectedUrl: undefined,
|
489
585
|
expectedUnsafeUrl: undefined,
|
490
586
|
expectedNewWindow: undefined
|
491
587
|
});
|
492
|
-
checkJsAction({
|
588
|
+
var annotation2 = checkJsAction({
|
493
589
|
jsEntry: 'window.open(\'http://www.example.com/test.pdf\')',
|
494
590
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
495
591
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
496
592
|
expectedNewWindow: undefined
|
497
593
|
});
|
498
|
-
checkJsAction({
|
594
|
+
var annotation3 = checkJsAction({
|
499
595
|
jsEntry: new _stream.StringStream('app.launchURL("http://www.example.com/test.pdf", true)'),
|
500
596
|
expectedUrl: new URL('http://www.example.com/test.pdf').href,
|
501
597
|
expectedUnsafeUrl: 'http://www.example.com/test.pdf',
|
502
598
|
expectedNewWindow: true
|
503
599
|
});
|
600
|
+
Promise.all([annotation1, annotation2, annotation3]).then(done, done.fail);
|
504
601
|
});
|
505
|
-
it('should correctly parse a Named action', function () {
|
602
|
+
it('should correctly parse a Named action', function (done) {
|
506
603
|
var actionDict = new _primitives.Dict();
|
507
604
|
actionDict.set('Type', _primitives.Name.get('Action'));
|
508
605
|
actionDict.set('S', _primitives.Name.get('Named'));
|
@@ -516,14 +613,17 @@ describe('annotation', function () {
|
|
516
613
|
ref: annotationRef,
|
517
614
|
data: annotationDict
|
518
615
|
}]);
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
616
|
+
|
617
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref15) {
|
618
|
+
var data = _ref15.data;
|
619
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
620
|
+
expect(data.url).toBeUndefined();
|
621
|
+
expect(data.unsafeUrl).toBeUndefined();
|
622
|
+
expect(data.action).toEqual('GoToPage');
|
623
|
+
done();
|
624
|
+
}, done.fail);
|
625
|
+
});
|
626
|
+
it('should correctly parse a simple Dest', function (done) {
|
527
627
|
var annotationDict = new _primitives.Dict();
|
528
628
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
529
629
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
@@ -533,14 +633,17 @@ describe('annotation', function () {
|
|
533
633
|
ref: annotationRef,
|
534
634
|
data: annotationDict
|
535
635
|
}]);
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
636
|
+
|
637
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref16) {
|
638
|
+
var data = _ref16.data;
|
639
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
640
|
+
expect(data.url).toBeUndefined();
|
641
|
+
expect(data.unsafeUrl).toBeUndefined();
|
642
|
+
expect(data.dest).toEqual('LI0');
|
643
|
+
done();
|
644
|
+
}, done.fail);
|
645
|
+
});
|
646
|
+
it('should correctly parse a simple Dest, with explicit destination array', function (done) {
|
544
647
|
var annotationDict = new _primitives.Dict();
|
545
648
|
annotationDict.set('Type', _primitives.Name.get('Annot'));
|
546
649
|
annotationDict.set('Subtype', _primitives.Name.get('Link'));
|
@@ -550,17 +653,22 @@ describe('annotation', function () {
|
|
550
653
|
ref: annotationRef,
|
551
654
|
data: annotationDict
|
552
655
|
}]);
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
656
|
+
|
657
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref17) {
|
658
|
+
var data = _ref17.data;
|
659
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
660
|
+
expect(data.url).toBeUndefined();
|
661
|
+
expect(data.unsafeUrl).toBeUndefined();
|
662
|
+
expect(data.dest).toEqual([{
|
663
|
+
num: 17,
|
664
|
+
gen: 0
|
665
|
+
}, {
|
666
|
+
name: 'XYZ'
|
667
|
+
}, 0, 841.89, null]);
|
668
|
+
done();
|
669
|
+
}, done.fail);
|
670
|
+
});
|
671
|
+
it('should correctly parse a Dest, which violates the specification ' + 'by containing a dictionary', function (done) {
|
564
672
|
var destDict = new _primitives.Dict();
|
565
673
|
destDict.set('Type', _primitives.Name.get('Action'));
|
566
674
|
destDict.set('S', _primitives.Name.get('GoTo'));
|
@@ -574,12 +682,15 @@ describe('annotation', function () {
|
|
574
682
|
ref: annotationRef,
|
575
683
|
data: annotationDict
|
576
684
|
}]);
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
685
|
+
|
686
|
+
_annotation.AnnotationFactory.create(xref, annotationRef, pdfManagerMock, idFactoryMock).then(function (_ref18) {
|
687
|
+
var data = _ref18.data;
|
688
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINK);
|
689
|
+
expect(data.url).toBeUndefined();
|
690
|
+
expect(data.unsafeUrl).toBeUndefined();
|
691
|
+
expect(data.dest).toEqual('page.157');
|
692
|
+
done();
|
693
|
+
}, done.fail);
|
583
694
|
});
|
584
695
|
});
|
585
696
|
describe('WidgetAnnotation', function () {
|
@@ -593,30 +704,36 @@ describe('annotation', function () {
|
|
593
704
|
afterEach(function () {
|
594
705
|
widgetDict = null;
|
595
706
|
});
|
596
|
-
it('should handle unknown field names', function () {
|
707
|
+
it('should handle unknown field names', function (done) {
|
597
708
|
var widgetRef = new _primitives.Ref(20, 0);
|
598
709
|
var xref = new _test_utils.XRefMock([{
|
599
710
|
ref: widgetRef,
|
600
711
|
data: widgetDict
|
601
712
|
}]);
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
713
|
+
|
714
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref19) {
|
715
|
+
var data = _ref19.data;
|
716
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
717
|
+
expect(data.fieldName).toEqual('');
|
718
|
+
done();
|
719
|
+
}, done.fail);
|
606
720
|
});
|
607
|
-
it('should construct the field name when there are no ancestors', function () {
|
721
|
+
it('should construct the field name when there are no ancestors', function (done) {
|
608
722
|
widgetDict.set('T', 'foo');
|
609
723
|
var widgetRef = new _primitives.Ref(21, 0);
|
610
724
|
var xref = new _test_utils.XRefMock([{
|
611
725
|
ref: widgetRef,
|
612
726
|
data: widgetDict
|
613
727
|
}]);
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
728
|
+
|
729
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref20) {
|
730
|
+
var data = _ref20.data;
|
731
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
732
|
+
expect(data.fieldName).toEqual('foo');
|
733
|
+
done();
|
734
|
+
}, done.fail);
|
618
735
|
});
|
619
|
-
it('should construct the field name when there are ancestors', function () {
|
736
|
+
it('should construct the field name when there are ancestors', function (done) {
|
620
737
|
var firstParent = new _primitives.Dict();
|
621
738
|
firstParent.set('T', 'foo');
|
622
739
|
var secondParent = new _primitives.Dict();
|
@@ -629,12 +746,15 @@ describe('annotation', function () {
|
|
629
746
|
ref: widgetRef,
|
630
747
|
data: widgetDict
|
631
748
|
}]);
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
749
|
+
|
750
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref21) {
|
751
|
+
var data = _ref21.data;
|
752
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
753
|
+
expect(data.fieldName).toEqual('foo.bar.baz');
|
754
|
+
done();
|
755
|
+
}, done.fail);
|
636
756
|
});
|
637
|
-
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function () {
|
757
|
+
it('should construct the field name if a parent is not a dictionary ' + '(issue 8143)', function (done) {
|
638
758
|
var parentDict = new _primitives.Dict();
|
639
759
|
parentDict.set('Parent', null);
|
640
760
|
parentDict.set('T', 'foo');
|
@@ -645,10 +765,13 @@ describe('annotation', function () {
|
|
645
765
|
ref: widgetRef,
|
646
766
|
data: widgetDict
|
647
767
|
}]);
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
768
|
+
|
769
|
+
_annotation.AnnotationFactory.create(xref, widgetRef, pdfManagerMock, idFactoryMock).then(function (_ref22) {
|
770
|
+
var data = _ref22.data;
|
771
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
772
|
+
expect(data.fieldName).toEqual('foo.bar');
|
773
|
+
done();
|
774
|
+
}, done.fail);
|
652
775
|
});
|
653
776
|
});
|
654
777
|
describe('TextWidgetAnnotation', function () {
|
@@ -663,22 +786,25 @@ describe('annotation', function () {
|
|
663
786
|
afterEach(function () {
|
664
787
|
textWidgetDict = null;
|
665
788
|
});
|
666
|
-
it('should handle unknown text alignment, maximum length and flags', function () {
|
789
|
+
it('should handle unknown text alignment, maximum length and flags', function (done) {
|
667
790
|
var textWidgetRef = new _primitives.Ref(124, 0);
|
668
791
|
var xref = new _test_utils.XRefMock([{
|
669
792
|
ref: textWidgetRef,
|
670
793
|
data: textWidgetDict
|
671
794
|
}]);
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
795
|
+
|
796
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref23) {
|
797
|
+
var data = _ref23.data;
|
798
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
799
|
+
expect(data.textAlignment).toEqual(null);
|
800
|
+
expect(data.maxLen).toEqual(null);
|
801
|
+
expect(data.readOnly).toEqual(false);
|
802
|
+
expect(data.multiLine).toEqual(false);
|
803
|
+
expect(data.comb).toEqual(false);
|
804
|
+
done();
|
805
|
+
}, done.fail);
|
806
|
+
});
|
807
|
+
it('should not set invalid text alignment, maximum length and flags', function (done) {
|
682
808
|
textWidgetDict.set('Q', 'center');
|
683
809
|
textWidgetDict.set('MaxLen', 'five');
|
684
810
|
textWidgetDict.set('Ff', 'readonly');
|
@@ -687,16 +813,19 @@ describe('annotation', function () {
|
|
687
813
|
ref: textWidgetRef,
|
688
814
|
data: textWidgetDict
|
689
815
|
}]);
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
816
|
+
|
817
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref24) {
|
818
|
+
var data = _ref24.data;
|
819
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
820
|
+
expect(data.textAlignment).toEqual(null);
|
821
|
+
expect(data.maxLen).toEqual(null);
|
822
|
+
expect(data.readOnly).toEqual(false);
|
823
|
+
expect(data.multiLine).toEqual(false);
|
824
|
+
expect(data.comb).toEqual(false);
|
825
|
+
done();
|
826
|
+
}, done.fail);
|
827
|
+
});
|
828
|
+
it('should set valid text alignment, maximum length and flags', function (done) {
|
700
829
|
textWidgetDict.set('Q', 1);
|
701
830
|
textWidgetDict.set('MaxLen', 20);
|
702
831
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.MULTILINE);
|
@@ -705,27 +834,33 @@ describe('annotation', function () {
|
|
705
834
|
ref: textWidgetRef,
|
706
835
|
data: textWidgetDict
|
707
836
|
}]);
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
837
|
+
|
838
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref25) {
|
839
|
+
var data = _ref25.data;
|
840
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
841
|
+
expect(data.textAlignment).toEqual(1);
|
842
|
+
expect(data.maxLen).toEqual(20);
|
843
|
+
expect(data.readOnly).toEqual(true);
|
844
|
+
expect(data.multiLine).toEqual(true);
|
845
|
+
done();
|
846
|
+
}, done.fail);
|
847
|
+
});
|
848
|
+
it('should reject comb fields without a maximum length', function (done) {
|
717
849
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
718
850
|
var textWidgetRef = new _primitives.Ref(46, 0);
|
719
851
|
var xref = new _test_utils.XRefMock([{
|
720
852
|
ref: textWidgetRef,
|
721
853
|
data: textWidgetDict
|
722
854
|
}]);
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
855
|
+
|
856
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref26) {
|
857
|
+
var data = _ref26.data;
|
858
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
859
|
+
expect(data.comb).toEqual(false);
|
860
|
+
done();
|
861
|
+
}, done.fail);
|
727
862
|
});
|
728
|
-
it('should accept comb fields with a maximum length', function () {
|
863
|
+
it('should accept comb fields with a maximum length', function (done) {
|
729
864
|
textWidgetDict.set('MaxLen', 20);
|
730
865
|
textWidgetDict.set('Ff', _util.AnnotationFieldFlag.COMB);
|
731
866
|
var textWidgetRef = new _primitives.Ref(46, 0);
|
@@ -733,31 +868,42 @@ describe('annotation', function () {
|
|
733
868
|
ref: textWidgetRef,
|
734
869
|
data: textWidgetDict
|
735
870
|
}]);
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
871
|
+
|
872
|
+
_annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref27) {
|
873
|
+
var data = _ref27.data;
|
874
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
875
|
+
expect(data.comb).toEqual(true);
|
876
|
+
done();
|
877
|
+
}, done.fail);
|
740
878
|
});
|
741
|
-
it('should only accept comb fields when the flags are valid', function () {
|
879
|
+
it('should only accept comb fields when the flags are valid', function (done) {
|
742
880
|
var invalidFieldFlags = [_util.AnnotationFieldFlag.MULTILINE, _util.AnnotationFieldFlag.PASSWORD, _util.AnnotationFieldFlag.FILESELECT];
|
743
881
|
var flags = _util.AnnotationFieldFlag.COMB + _util.AnnotationFieldFlag.MULTILINE + _util.AnnotationFieldFlag.PASSWORD + _util.AnnotationFieldFlag.FILESELECT;
|
882
|
+
var promise = Promise.resolve();
|
883
|
+
|
744
884
|
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
|
-
|
885
|
+
promise = promise.then(function () {
|
886
|
+
textWidgetDict.set('MaxLen', 20);
|
887
|
+
textWidgetDict.set('Ff', flags);
|
888
|
+
var textWidgetRef = new _primitives.Ref(93, 0);
|
889
|
+
var xref = new _test_utils.XRefMock([{
|
890
|
+
ref: textWidgetRef,
|
891
|
+
data: textWidgetDict
|
892
|
+
}]);
|
893
|
+
return _annotation.AnnotationFactory.create(xref, textWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref28) {
|
894
|
+
var data = _ref28.data;
|
895
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
896
|
+
var valid = invalidFieldFlags.length === 0;
|
897
|
+
expect(data.comb).toEqual(valid);
|
898
|
+
|
899
|
+
if (!valid) {
|
900
|
+
flags -= invalidFieldFlags.pop();
|
901
|
+
}
|
902
|
+
});
|
903
|
+
});
|
760
904
|
}
|
905
|
+
|
906
|
+
promise.then(done, done.fail);
|
761
907
|
});
|
762
908
|
});
|
763
909
|
describe('ButtonWidgetAnnotation', function () {
|
@@ -772,21 +918,48 @@ describe('annotation', function () {
|
|
772
918
|
afterEach(function () {
|
773
919
|
buttonWidgetDict = null;
|
774
920
|
});
|
775
|
-
it('should handle checkboxes', function () {
|
921
|
+
it('should handle checkboxes with export value', function (done) {
|
776
922
|
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
923
|
+
var appearanceStatesDict = new _primitives.Dict();
|
924
|
+
var exportValueOptionsDict = new _primitives.Dict();
|
925
|
+
exportValueOptionsDict.set('Off', 0);
|
926
|
+
exportValueOptionsDict.set('Checked', 1);
|
927
|
+
appearanceStatesDict.set('D', exportValueOptionsDict);
|
928
|
+
buttonWidgetDict.set('AP', appearanceStatesDict);
|
777
929
|
var buttonWidgetRef = new _primitives.Ref(124, 0);
|
778
930
|
var xref = new _test_utils.XRefMock([{
|
779
931
|
ref: buttonWidgetRef,
|
780
932
|
data: buttonWidgetDict
|
781
933
|
}]);
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
934
|
+
|
935
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref29) {
|
936
|
+
var data = _ref29.data;
|
937
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
938
|
+
expect(data.checkBox).toEqual(true);
|
939
|
+
expect(data.fieldValue).toEqual('1');
|
940
|
+
expect(data.radioButton).toEqual(false);
|
941
|
+
expect(data.exportValue).toEqual('Checked');
|
942
|
+
done();
|
943
|
+
}, done.fail);
|
944
|
+
});
|
945
|
+
it('should handle checkboxes without export value', function (done) {
|
946
|
+
buttonWidgetDict.set('V', _primitives.Name.get('1'));
|
947
|
+
var buttonWidgetRef = new _primitives.Ref(124, 0);
|
948
|
+
var xref = new _test_utils.XRefMock([{
|
949
|
+
ref: buttonWidgetRef,
|
950
|
+
data: buttonWidgetDict
|
951
|
+
}]);
|
952
|
+
|
953
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref30) {
|
954
|
+
var data = _ref30.data;
|
955
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
956
|
+
expect(data.checkBox).toEqual(true);
|
957
|
+
expect(data.fieldValue).toEqual('1');
|
958
|
+
expect(data.radioButton).toEqual(false);
|
959
|
+
done();
|
960
|
+
}, done.fail);
|
961
|
+
});
|
962
|
+
it('should handle radio buttons with a field value', function (done) {
|
790
963
|
var parentDict = new _primitives.Dict();
|
791
964
|
parentDict.set('V', _primitives.Name.get('1'));
|
792
965
|
var normalAppearanceStateDict = new _primitives.Dict();
|
@@ -801,15 +974,18 @@ describe('annotation', function () {
|
|
801
974
|
ref: buttonWidgetRef,
|
802
975
|
data: buttonWidgetDict
|
803
976
|
}]);
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
977
|
+
|
978
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref31) {
|
979
|
+
var data = _ref31.data;
|
980
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
981
|
+
expect(data.checkBox).toEqual(false);
|
982
|
+
expect(data.radioButton).toEqual(true);
|
983
|
+
expect(data.fieldValue).toEqual('1');
|
984
|
+
expect(data.buttonValue).toEqual('2');
|
985
|
+
done();
|
986
|
+
}, done.fail);
|
987
|
+
});
|
988
|
+
it('should handle radio buttons without a field value', function (done) {
|
813
989
|
var normalAppearanceStateDict = new _primitives.Dict();
|
814
990
|
normalAppearanceStateDict.set('2', null);
|
815
991
|
var appearanceStatesDict = new _primitives.Dict();
|
@@ -821,13 +997,16 @@ describe('annotation', function () {
|
|
821
997
|
ref: buttonWidgetRef,
|
822
998
|
data: buttonWidgetDict
|
823
999
|
}]);
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
1000
|
+
|
1001
|
+
_annotation.AnnotationFactory.create(xref, buttonWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref32) {
|
1002
|
+
var data = _ref32.data;
|
1003
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1004
|
+
expect(data.checkBox).toEqual(false);
|
1005
|
+
expect(data.radioButton).toEqual(true);
|
1006
|
+
expect(data.fieldValue).toEqual(null);
|
1007
|
+
expect(data.buttonValue).toEqual('2');
|
1008
|
+
done();
|
1009
|
+
}, done.fail);
|
831
1010
|
});
|
832
1011
|
});
|
833
1012
|
describe('ChoiceWidgetAnnotation', function () {
|
@@ -842,18 +1021,21 @@ describe('annotation', function () {
|
|
842
1021
|
afterEach(function () {
|
843
1022
|
choiceWidgetDict = null;
|
844
1023
|
});
|
845
|
-
it('should handle missing option arrays', function () {
|
1024
|
+
it('should handle missing option arrays', function (done) {
|
846
1025
|
var choiceWidgetRef = new _primitives.Ref(122, 0);
|
847
1026
|
var xref = new _test_utils.XRefMock([{
|
848
1027
|
ref: choiceWidgetRef,
|
849
1028
|
data: choiceWidgetDict
|
850
1029
|
}]);
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
1030
|
+
|
1031
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref33) {
|
1032
|
+
var data = _ref33.data;
|
1033
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1034
|
+
expect(data.options).toEqual([]);
|
1035
|
+
done();
|
1036
|
+
}, done.fail);
|
855
1037
|
});
|
856
|
-
it('should handle option arrays with array elements', function () {
|
1038
|
+
it('should handle option arrays with array elements', function (done) {
|
857
1039
|
var optionBarRef = new _primitives.Ref(20, 0);
|
858
1040
|
var optionBarStr = 'Bar';
|
859
1041
|
var optionOneRef = new _primitives.Ref(10, 0);
|
@@ -878,12 +1060,15 @@ describe('annotation', function () {
|
|
878
1060
|
ref: optionOneRef,
|
879
1061
|
data: optionOneArr
|
880
1062
|
}]);
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
1063
|
+
|
1064
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref34) {
|
1065
|
+
var data = _ref34.data;
|
1066
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1067
|
+
expect(data.options).toEqual(expected);
|
1068
|
+
done();
|
1069
|
+
}, done.fail);
|
885
1070
|
});
|
886
|
-
it('should handle option arrays with string elements', function () {
|
1071
|
+
it('should handle option arrays with string elements', function (done) {
|
887
1072
|
var optionBarRef = new _primitives.Ref(10, 0);
|
888
1073
|
var optionBarStr = 'Bar';
|
889
1074
|
var options = ['Foo', optionBarRef];
|
@@ -903,12 +1088,15 @@ describe('annotation', function () {
|
|
903
1088
|
ref: optionBarRef,
|
904
1089
|
data: optionBarStr
|
905
1090
|
}]);
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
1091
|
+
|
1092
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref35) {
|
1093
|
+
var data = _ref35.data;
|
1094
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1095
|
+
expect(data.options).toEqual(expected);
|
1096
|
+
done();
|
1097
|
+
}, done.fail);
|
910
1098
|
});
|
911
|
-
it('should handle inherited option arrays (issue 8094)', function () {
|
1099
|
+
it('should handle inherited option arrays (issue 8094)', function (done) {
|
912
1100
|
var options = [['Value1', 'Description1'], ['Value2', 'Description2']];
|
913
1101
|
var expected = [{
|
914
1102
|
exportValue: 'Value1',
|
@@ -925,12 +1113,15 @@ describe('annotation', function () {
|
|
925
1113
|
ref: choiceWidgetRef,
|
926
1114
|
data: choiceWidgetDict
|
927
1115
|
}]);
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
1116
|
+
|
1117
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref36) {
|
1118
|
+
var data = _ref36.data;
|
1119
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1120
|
+
expect(data.options).toEqual(expected);
|
1121
|
+
done();
|
1122
|
+
}, done.fail);
|
932
1123
|
});
|
933
|
-
it('should sanitize display values in option arrays (issue 8947)', function () {
|
1124
|
+
it('should sanitize display values in option arrays (issue 8947)', function (done) {
|
934
1125
|
var options = ['\xFE\xFF\x00F\x00o\x00o'];
|
935
1126
|
var expected = [{
|
936
1127
|
exportValue: '\xFE\xFF\x00F\x00o\x00o',
|
@@ -942,12 +1133,15 @@ describe('annotation', function () {
|
|
942
1133
|
ref: choiceWidgetRef,
|
943
1134
|
data: choiceWidgetDict
|
944
1135
|
}]);
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
1136
|
+
|
1137
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref37) {
|
1138
|
+
var data = _ref37.data;
|
1139
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1140
|
+
expect(data.options).toEqual(expected);
|
1141
|
+
done();
|
1142
|
+
}, done.fail);
|
949
1143
|
});
|
950
|
-
it('should handle array field values', function () {
|
1144
|
+
it('should handle array field values', function (done) {
|
951
1145
|
var fieldValue = ['Foo', 'Bar'];
|
952
1146
|
choiceWidgetDict.set('V', fieldValue);
|
953
1147
|
var choiceWidgetRef = new _primitives.Ref(968, 0);
|
@@ -955,12 +1149,15 @@ describe('annotation', function () {
|
|
955
1149
|
ref: choiceWidgetRef,
|
956
1150
|
data: choiceWidgetDict
|
957
1151
|
}]);
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
1152
|
+
|
1153
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref38) {
|
1154
|
+
var data = _ref38.data;
|
1155
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1156
|
+
expect(data.fieldValue).toEqual(fieldValue);
|
1157
|
+
done();
|
1158
|
+
}, done.fail);
|
962
1159
|
});
|
963
|
-
it('should handle string field values', function () {
|
1160
|
+
it('should handle string field values', function (done) {
|
964
1161
|
var fieldValue = 'Foo';
|
965
1162
|
choiceWidgetDict.set('V', fieldValue);
|
966
1163
|
var choiceWidgetRef = new _primitives.Ref(978, 0);
|
@@ -968,55 +1165,67 @@ describe('annotation', function () {
|
|
968
1165
|
ref: choiceWidgetRef,
|
969
1166
|
data: choiceWidgetDict
|
970
1167
|
}]);
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
1168
|
+
|
1169
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref39) {
|
1170
|
+
var data = _ref39.data;
|
1171
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1172
|
+
expect(data.fieldValue).toEqual([fieldValue]);
|
1173
|
+
done();
|
1174
|
+
}, done.fail);
|
975
1175
|
});
|
976
|
-
it('should handle unknown flags', function () {
|
1176
|
+
it('should handle unknown flags', function (done) {
|
977
1177
|
var choiceWidgetRef = new _primitives.Ref(166, 0);
|
978
1178
|
var xref = new _test_utils.XRefMock([{
|
979
1179
|
ref: choiceWidgetRef,
|
980
1180
|
data: choiceWidgetDict
|
981
1181
|
}]);
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
1182
|
+
|
1183
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref40) {
|
1184
|
+
var data = _ref40.data;
|
1185
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1186
|
+
expect(data.readOnly).toEqual(false);
|
1187
|
+
expect(data.combo).toEqual(false);
|
1188
|
+
expect(data.multiSelect).toEqual(false);
|
1189
|
+
done();
|
1190
|
+
}, done.fail);
|
1191
|
+
});
|
1192
|
+
it('should not set invalid flags', function (done) {
|
990
1193
|
choiceWidgetDict.set('Ff', 'readonly');
|
991
1194
|
var choiceWidgetRef = new _primitives.Ref(165, 0);
|
992
1195
|
var xref = new _test_utils.XRefMock([{
|
993
1196
|
ref: choiceWidgetRef,
|
994
1197
|
data: choiceWidgetDict
|
995
1198
|
}]);
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1199
|
+
|
1200
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref41) {
|
1201
|
+
var data = _ref41.data;
|
1202
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1203
|
+
expect(data.readOnly).toEqual(false);
|
1204
|
+
expect(data.combo).toEqual(false);
|
1205
|
+
expect(data.multiSelect).toEqual(false);
|
1206
|
+
done();
|
1207
|
+
}, done.fail);
|
1208
|
+
});
|
1209
|
+
it('should set valid flags', function (done) {
|
1004
1210
|
choiceWidgetDict.set('Ff', _util.AnnotationFieldFlag.READONLY + _util.AnnotationFieldFlag.COMBO + _util.AnnotationFieldFlag.MULTISELECT);
|
1005
1211
|
var choiceWidgetRef = new _primitives.Ref(512, 0);
|
1006
1212
|
var xref = new _test_utils.XRefMock([{
|
1007
1213
|
ref: choiceWidgetRef,
|
1008
1214
|
data: choiceWidgetDict
|
1009
1215
|
}]);
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1216
|
+
|
1217
|
+
_annotation.AnnotationFactory.create(xref, choiceWidgetRef, pdfManagerMock, idFactoryMock).then(function (_ref42) {
|
1218
|
+
var data = _ref42.data;
|
1219
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.WIDGET);
|
1220
|
+
expect(data.readOnly).toEqual(true);
|
1221
|
+
expect(data.combo).toEqual(true);
|
1222
|
+
expect(data.multiSelect).toEqual(true);
|
1223
|
+
done();
|
1224
|
+
}, done.fail);
|
1016
1225
|
});
|
1017
1226
|
});
|
1018
1227
|
describe('LineAnnotation', function () {
|
1019
|
-
it('should set the line coordinates', function () {
|
1228
|
+
it('should set the line coordinates', function (done) {
|
1020
1229
|
var lineDict = new _primitives.Dict();
|
1021
1230
|
lineDict.set('Type', _primitives.Name.get('Annot'));
|
1022
1231
|
lineDict.set('Subtype', _primitives.Name.get('Line'));
|
@@ -1026,14 +1235,17 @@ describe('annotation', function () {
|
|
1026
1235
|
ref: lineRef,
|
1027
1236
|
data: lineDict
|
1028
1237
|
}]);
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1238
|
+
|
1239
|
+
_annotation.AnnotationFactory.create(xref, lineRef, pdfManagerMock, idFactoryMock).then(function (_ref43) {
|
1240
|
+
var data = _ref43.data;
|
1241
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.LINE);
|
1242
|
+
expect(data.lineCoordinates).toEqual([1, 2, 3, 4]);
|
1243
|
+
done();
|
1244
|
+
}, done.fail);
|
1033
1245
|
});
|
1034
1246
|
});
|
1035
1247
|
describe('FileAttachmentAnnotation', function () {
|
1036
|
-
it('should correctly parse a file attachment', function () {
|
1248
|
+
it('should correctly parse a file attachment', function (done) {
|
1037
1249
|
var fileStream = new _stream.StringStream('<<\n' + '/Type /EmbeddedFile\n' + '/Subtype /text#2Fplain\n' + '>>\n' + 'stream\n' + 'Test attachment' + 'endstream\n');
|
1038
1250
|
var lexer = new _parser.Lexer(fileStream);
|
1039
1251
|
var parser = new _parser.Parser(lexer, true);
|
@@ -1067,15 +1279,18 @@ describe('annotation', function () {
|
|
1067
1279
|
embeddedFileDict.assignXref(xref);
|
1068
1280
|
fileSpecDict.assignXref(xref);
|
1069
1281
|
fileAttachmentDict.assignXref(xref);
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1282
|
+
|
1283
|
+
_annotation.AnnotationFactory.create(xref, fileAttachmentRef, pdfManagerMock, idFactoryMock).then(function (_ref44) {
|
1284
|
+
var data = _ref44.data;
|
1285
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.FILEATTACHMENT);
|
1286
|
+
expect(data.file.filename).toEqual('Test.txt');
|
1287
|
+
expect(data.file.content).toEqual((0, _util.stringToBytes)('Test attachment'));
|
1288
|
+
done();
|
1289
|
+
}, done.fail);
|
1075
1290
|
});
|
1076
1291
|
});
|
1077
1292
|
describe('PopupAnnotation', function () {
|
1078
|
-
it('should inherit the parent flags when the Popup is not viewable, ' + 'but the parent is (PR 7352)', function () {
|
1293
|
+
it('should inherit the parent flags when the Popup is not viewable, ' + 'but the parent is (PR 7352)', function (done) {
|
1079
1294
|
var parentDict = new _primitives.Dict();
|
1080
1295
|
parentDict.set('Type', _primitives.Name.get('Annot'));
|
1081
1296
|
parentDict.set('Subtype', _primitives.Name.get('Text'));
|
@@ -1090,11 +1305,80 @@ describe('annotation', function () {
|
|
1090
1305
|
ref: popupRef,
|
1091
1306
|
data: popupDict
|
1092
1307
|
}]);
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1308
|
+
|
1309
|
+
_annotation.AnnotationFactory.create(xref, popupRef, pdfManagerMock, idFactoryMock).then(function (_ref45) {
|
1310
|
+
var data = _ref45.data,
|
1311
|
+
viewable = _ref45.viewable;
|
1312
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.POPUP);
|
1313
|
+
expect(data.annotationFlags).toEqual(25);
|
1314
|
+
expect(viewable).toEqual(true);
|
1315
|
+
done();
|
1316
|
+
}, done.fail);
|
1317
|
+
});
|
1318
|
+
});
|
1319
|
+
describe('InkAnnotation', function () {
|
1320
|
+
it('should handle a single ink list', function (done) {
|
1321
|
+
var inkDict = new _primitives.Dict();
|
1322
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1323
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1324
|
+
inkDict.set('InkList', [[1, 1, 1, 2, 2, 2, 3, 3]]);
|
1325
|
+
var inkRef = new _primitives.Ref(142, 0);
|
1326
|
+
var xref = new _test_utils.XRefMock([{
|
1327
|
+
ref: inkRef,
|
1328
|
+
data: inkDict
|
1329
|
+
}]);
|
1330
|
+
|
1331
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref46) {
|
1332
|
+
var data = _ref46.data;
|
1333
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1334
|
+
expect(data.inkLists.length).toEqual(1);
|
1335
|
+
expect(data.inkLists[0]).toEqual([{
|
1336
|
+
x: 1,
|
1337
|
+
y: 1
|
1338
|
+
}, {
|
1339
|
+
x: 1,
|
1340
|
+
y: 2
|
1341
|
+
}, {
|
1342
|
+
x: 2,
|
1343
|
+
y: 2
|
1344
|
+
}, {
|
1345
|
+
x: 3,
|
1346
|
+
y: 3
|
1347
|
+
}]);
|
1348
|
+
done();
|
1349
|
+
}, done.fail);
|
1350
|
+
});
|
1351
|
+
it('should handle multiple ink lists', function (done) {
|
1352
|
+
var inkDict = new _primitives.Dict();
|
1353
|
+
inkDict.set('Type', _primitives.Name.get('Annot'));
|
1354
|
+
inkDict.set('Subtype', _primitives.Name.get('Ink'));
|
1355
|
+
inkDict.set('InkList', [[1, 1, 1, 2], [3, 3, 4, 5]]);
|
1356
|
+
var inkRef = new _primitives.Ref(143, 0);
|
1357
|
+
var xref = new _test_utils.XRefMock([{
|
1358
|
+
ref: inkRef,
|
1359
|
+
data: inkDict
|
1360
|
+
}]);
|
1361
|
+
|
1362
|
+
_annotation.AnnotationFactory.create(xref, inkRef, pdfManagerMock, idFactoryMock).then(function (_ref47) {
|
1363
|
+
var data = _ref47.data;
|
1364
|
+
expect(data.annotationType).toEqual(_util.AnnotationType.INK);
|
1365
|
+
expect(data.inkLists.length).toEqual(2);
|
1366
|
+
expect(data.inkLists[0]).toEqual([{
|
1367
|
+
x: 1,
|
1368
|
+
y: 1
|
1369
|
+
}, {
|
1370
|
+
x: 1,
|
1371
|
+
y: 2
|
1372
|
+
}]);
|
1373
|
+
expect(data.inkLists[1]).toEqual([{
|
1374
|
+
x: 3,
|
1375
|
+
y: 3
|
1376
|
+
}, {
|
1377
|
+
x: 4,
|
1378
|
+
y: 5
|
1379
|
+
}]);
|
1380
|
+
done();
|
1381
|
+
}, done.fail);
|
1098
1382
|
});
|
1099
1383
|
});
|
1100
1384
|
});
|