pdfjs-dist 2.0.943 → 2.4.456
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8286 -14230
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +22 -1
- package/build/pdf.worker.entry.js +5 -3
- package/build/pdf.worker.js +25500 -26628
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +25473 -0
- package/es5/build/pdf.js.map +1 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +57878 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/web/images/annotation-check.svg +11 -0
- package/es5/web/images/annotation-comment.svg +16 -0
- package/es5/web/images/annotation-help.svg +26 -0
- package/es5/web/images/annotation-insert.svg +10 -0
- package/es5/web/images/annotation-key.svg +11 -0
- package/es5/web/images/annotation-newparagraph.svg +11 -0
- package/es5/web/images/annotation-noicon.svg +7 -0
- package/es5/web/images/annotation-note.svg +42 -0
- package/es5/web/images/annotation-paragraph.svg +16 -0
- package/es5/web/images/loading-icon.gif +0 -0
- package/es5/web/images/shadow.png +0 -0
- package/es5/web/images/texture.png +0 -0
- package/es5/web/pdf_viewer.css +407 -0
- package/es5/web/pdf_viewer.js +7757 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +2887 -4094
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +22 -1
- package/lib/README.md +7 -0
- package/lib/core/annotation.js +855 -778
- package/lib/core/arithmetic_decoder.js +325 -311
- package/lib/core/bidi.js +117 -50
- package/lib/core/ccitt.js +251 -89
- package/lib/core/ccitt_stream.js +26 -16
- package/lib/core/cff_parser.js +525 -197
- package/lib/core/charsets.js +6 -5
- package/lib/core/chunked_stream.js +541 -406
- package/lib/core/cmap.js +368 -253
- package/lib/core/colorspace.js +781 -800
- package/lib/core/core_utils.js +152 -0
- package/lib/core/crypto.js +609 -422
- package/lib/core/document.js +649 -481
- package/lib/core/encodings.js +33 -24
- package/lib/core/evaluator.js +1471 -736
- package/lib/core/font_renderer.js +289 -149
- package/lib/core/fonts.js +1067 -413
- package/lib/core/function.js +517 -287
- package/lib/core/glyphlist.js +4529 -4527
- package/lib/core/image.js +232 -114
- package/lib/core/image_utils.js +94 -0
- package/lib/core/jbig2.js +711 -342
- package/lib/core/jbig2_stream.js +31 -19
- package/lib/core/jpeg_stream.js +151 -26
- package/lib/core/jpg.js +433 -181
- package/lib/core/jpx.js +551 -143
- package/lib/core/jpx_stream.js +40 -28
- package/lib/core/metrics.js +2931 -2931
- package/lib/core/murmurhash3.js +104 -97
- package/lib/core/obj.js +1561 -1053
- package/lib/core/operator_list.js +192 -64
- package/lib/core/parser.js +1162 -864
- package/lib/core/pattern.js +224 -75
- package/lib/core/pdf_manager.js +154 -285
- package/lib/core/primitives.js +145 -69
- package/lib/core/ps_parser.js +212 -162
- package/lib/core/standard_fonts.js +245 -244
- package/lib/core/stream.js +353 -81
- package/lib/core/type1_parser.js +218 -68
- package/lib/core/unicode.js +1682 -1655
- package/lib/core/worker.js +233 -302
- package/lib/core/worker_stream.js +168 -0
- package/lib/display/annotation_layer.js +808 -862
- package/lib/display/api.js +1778 -1462
- package/lib/display/api_compatibility.js +14 -9
- package/lib/display/canvas.js +463 -140
- package/lib/display/content_disposition.js +86 -58
- package/lib/display/display_utils.js +524 -0
- package/lib/display/fetch_stream.js +202 -274
- package/lib/display/font_loader.js +311 -333
- package/lib/display/metadata.js +98 -88
- package/lib/display/network.js +343 -347
- package/lib/display/network_utils.js +46 -26
- package/lib/display/node_stream.js +326 -404
- package/lib/display/pattern_helper.js +168 -69
- package/lib/display/svg.js +1296 -885
- package/lib/display/text_layer.js +229 -103
- package/lib/display/transport_stream.js +290 -250
- package/lib/display/webgl.js +116 -83
- package/lib/display/worker_options.js +6 -5
- package/lib/display/xml_parser.js +358 -337
- package/lib/examples/node/domstubs.js +95 -39
- package/lib/pdf.js +49 -31
- package/lib/pdf.worker.js +7 -5
- package/lib/shared/compatibility.js +3 -145
- package/lib/shared/is_node.js +8 -7
- package/lib/shared/message_handler.js +367 -314
- package/lib/shared/util.js +421 -415
- package/lib/test/unit/annotation_spec.js +1570 -690
- package/lib/test/unit/api_spec.js +855 -493
- package/lib/test/unit/bidi_spec.js +12 -12
- package/lib/test/unit/cff_parser_spec.js +88 -61
- package/lib/test/unit/clitests_helper.js +9 -12
- package/lib/test/unit/cmap_spec.js +140 -88
- package/lib/test/unit/colorspace_spec.js +204 -152
- package/lib/test/unit/core_utils_spec.js +211 -0
- package/lib/test/unit/crypto_spec.js +194 -182
- package/lib/test/unit/custom_spec.js +50 -64
- package/lib/test/unit/display_svg_spec.js +53 -38
- package/lib/test/unit/display_utils_spec.js +263 -0
- package/lib/test/unit/document_spec.js +17 -22
- package/lib/test/unit/encodings_spec.js +15 -57
- package/lib/test/unit/evaluator_spec.js +90 -83
- package/lib/test/unit/fetch_stream_spec.js +111 -0
- package/lib/test/unit/function_spec.js +219 -205
- package/lib/test/unit/jasmine-boot.js +68 -39
- package/lib/test/unit/message_handler_spec.js +187 -160
- package/lib/test/unit/metadata_spec.js +87 -34
- package/lib/test/unit/murmurhash3_spec.js +13 -13
- package/lib/test/unit/network_spec.js +26 -59
- package/lib/test/unit/network_utils_spec.js +187 -121
- package/lib/test/unit/node_stream_spec.js +98 -90
- package/lib/test/unit/parser_spec.js +173 -131
- package/lib/test/unit/pdf_find_controller_spec.js +148 -67
- package/lib/test/unit/pdf_find_utils_spec.js +35 -34
- package/lib/test/unit/pdf_history_spec.js +45 -33
- package/lib/test/unit/primitives_spec.js +161 -126
- package/lib/test/unit/stream_spec.js +22 -15
- package/lib/test/unit/test_utils.js +149 -98
- package/lib/test/unit/testreporter.js +36 -18
- package/lib/test/unit/type1_parser_spec.js +46 -44
- package/lib/test/unit/ui_utils_spec.js +388 -372
- package/lib/test/unit/unicode_spec.js +49 -46
- package/lib/test/unit/util_spec.js +144 -248
- package/lib/web/annotation_layer_builder.js +75 -95
- package/lib/web/app.js +1538 -1147
- package/lib/web/app_options.js +116 -104
- package/lib/web/base_viewer.js +950 -775
- package/lib/web/chromecom.js +217 -225
- package/lib/web/debugger.js +236 -148
- package/lib/web/download_manager.js +50 -50
- package/lib/web/firefox_print_service.js +51 -33
- package/lib/web/firefoxcom.js +225 -352
- package/lib/web/genericcom.js +30 -93
- package/lib/web/genericl10n.js +26 -143
- package/lib/web/grab_to_pan.js +57 -33
- package/lib/web/interfaces.js +105 -232
- package/lib/web/overlay_manager.js +73 -227
- package/lib/web/password_prompt.js +44 -62
- package/lib/web/pdf_attachment_viewer.js +118 -123
- package/lib/web/pdf_cursor_tools.js +89 -93
- package/lib/web/pdf_document_properties.js +242 -281
- package/lib/web/pdf_find_bar.js +157 -163
- package/lib/web/pdf_find_controller.js +598 -454
- package/lib/web/pdf_find_utils.js +32 -16
- package/lib/web/pdf_history.js +481 -355
- package/lib/web/pdf_link_service.js +355 -323
- package/lib/web/pdf_outline_viewer.js +167 -152
- package/lib/web/pdf_page_view.js +511 -457
- package/lib/web/pdf_presentation_mode.js +347 -335
- package/lib/web/pdf_print_service.js +133 -103
- package/lib/web/pdf_rendering_queue.js +98 -100
- package/lib/web/pdf_sidebar.js +323 -299
- package/lib/web/pdf_sidebar_resizer.js +107 -108
- package/lib/web/pdf_single_page_viewer.js +94 -146
- package/lib/web/pdf_thumbnail_view.js +319 -269
- package/lib/web/pdf_thumbnail_viewer.js +219 -199
- package/lib/web/pdf_viewer.component.js +111 -32
- package/lib/web/pdf_viewer.js +61 -101
- package/lib/web/preferences.js +87 -272
- package/lib/web/secondary_toolbar.js +207 -220
- package/lib/web/text_layer_builder.js +322 -322
- package/lib/web/toolbar.js +227 -180
- package/lib/web/ui_utils.js +476 -421
- package/lib/web/view_history.js +59 -208
- package/lib/web/viewer_compatibility.js +9 -6
- package/package.json +2 -9
- package/web/pdf_viewer.css +36 -22
- package/web/pdf_viewer.js +4407 -4516
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +14 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/display/dom_utils.js +0 -441
- package/lib/shared/streams_polyfill.js +0 -39
- package/lib/shared/url_polyfill.js +0 -50
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/web/dom_events.js +0 -140
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,56 +19,61 @@
|
|
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 _cmap = require(
|
24
|
+
var _cmap = require("../../core/cmap.js");
|
25
25
|
|
26
|
-
var
|
26
|
+
var _display_utils = require("../../display/display_utils.js");
|
27
27
|
|
28
|
-
var _is_node = require(
|
28
|
+
var _is_node = require("../../shared/is_node.js");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _primitives = require("../../core/primitives.js");
|
31
31
|
|
32
|
-
var
|
32
|
+
var _test_utils = require("./test_utils.js");
|
33
33
|
|
34
|
-
var
|
35
|
-
|
36
|
-
var _stream = require('../../core/stream');
|
37
|
-
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
34
|
+
var _stream = require("../../core/stream.js");
|
39
35
|
|
40
36
|
var cMapUrl = {
|
41
|
-
dom:
|
42
|
-
node:
|
37
|
+
dom: "../../external/bcmaps/",
|
38
|
+
node: "./external/bcmaps/"
|
43
39
|
};
|
44
40
|
var cMapPacked = true;
|
45
|
-
describe(
|
41
|
+
describe("cmap", function () {
|
46
42
|
var fetchBuiltInCMap;
|
47
43
|
beforeAll(function (done) {
|
48
44
|
var CMapReaderFactory;
|
49
|
-
|
45
|
+
|
46
|
+
if (_is_node.isNodeJS) {
|
50
47
|
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
|
51
48
|
baseUrl: cMapUrl.node,
|
52
49
|
isCompressed: cMapPacked
|
53
50
|
});
|
54
51
|
} else {
|
55
|
-
CMapReaderFactory = new
|
52
|
+
CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
|
56
53
|
baseUrl: cMapUrl.dom,
|
57
54
|
isCompressed: cMapPacked
|
58
55
|
});
|
59
56
|
}
|
60
|
-
|
61
|
-
|
57
|
+
|
58
|
+
fetchBuiltInCMap = function (name) {
|
59
|
+
return CMapReaderFactory.fetch({
|
60
|
+
name
|
61
|
+
});
|
62
62
|
};
|
63
|
+
|
63
64
|
done();
|
64
65
|
});
|
65
66
|
afterAll(function () {
|
66
67
|
fetchBuiltInCMap = null;
|
67
68
|
});
|
68
|
-
it(
|
69
|
-
var str =
|
69
|
+
it("parses beginbfchar", function (done) {
|
70
|
+
var str = "2 beginbfchar\n" + "<03> <00>\n" + "<04> <01>\n" + "endbfchar\n";
|
70
71
|
var stream = new _stream.StringStream(str);
|
71
|
-
|
72
|
+
|
73
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
74
|
+
encoding: stream
|
75
|
+
});
|
76
|
+
|
72
77
|
cmapPromise.then(function (cmap) {
|
73
78
|
expect(cmap.lookup(0x03)).toEqual(String.fromCharCode(0x00));
|
74
79
|
expect(cmap.lookup(0x04)).toEqual(String.fromCharCode(0x01));
|
@@ -78,27 +83,35 @@ describe('cmap', function () {
|
|
78
83
|
done.fail(reason);
|
79
84
|
});
|
80
85
|
});
|
81
|
-
it(
|
82
|
-
var str =
|
86
|
+
it("parses beginbfrange with range", function (done) {
|
87
|
+
var str = "1 beginbfrange\n" + "<06> <0B> 0\n" + "endbfrange\n";
|
83
88
|
var stream = new _stream.StringStream(str);
|
84
|
-
|
89
|
+
|
90
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
91
|
+
encoding: stream
|
92
|
+
});
|
93
|
+
|
85
94
|
cmapPromise.then(function (cmap) {
|
86
95
|
expect(cmap.lookup(0x05)).toBeUndefined();
|
87
96
|
expect(cmap.lookup(0x06)).toEqual(String.fromCharCode(0x00));
|
88
|
-
expect(cmap.lookup(
|
89
|
-
expect(cmap.lookup(
|
97
|
+
expect(cmap.lookup(0x0b)).toEqual(String.fromCharCode(0x05));
|
98
|
+
expect(cmap.lookup(0x0c)).toBeUndefined();
|
90
99
|
done();
|
91
100
|
}).catch(function (reason) {
|
92
101
|
done.fail(reason);
|
93
102
|
});
|
94
103
|
});
|
95
|
-
it(
|
96
|
-
var str =
|
104
|
+
it("parses beginbfrange with array", function (done) {
|
105
|
+
var str = "1 beginbfrange\n" + "<0D> <12> [ 0 1 2 3 4 5 ]\n" + "endbfrange\n";
|
97
106
|
var stream = new _stream.StringStream(str);
|
98
|
-
|
107
|
+
|
108
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
109
|
+
encoding: stream
|
110
|
+
});
|
111
|
+
|
99
112
|
cmapPromise.then(function (cmap) {
|
100
|
-
expect(cmap.lookup(
|
101
|
-
expect(cmap.lookup(
|
113
|
+
expect(cmap.lookup(0x0c)).toBeUndefined();
|
114
|
+
expect(cmap.lookup(0x0d)).toEqual(0x00);
|
102
115
|
expect(cmap.lookup(0x12)).toEqual(0x05);
|
103
116
|
expect(cmap.lookup(0x13)).toBeUndefined();
|
104
117
|
done();
|
@@ -106,10 +119,14 @@ describe('cmap', function () {
|
|
106
119
|
done.fail(reason);
|
107
120
|
});
|
108
121
|
});
|
109
|
-
it(
|
110
|
-
var str =
|
122
|
+
it("parses begincidchar", function (done) {
|
123
|
+
var str = "1 begincidchar\n" + "<14> 0\n" + "endcidchar\n";
|
111
124
|
var stream = new _stream.StringStream(str);
|
112
|
-
|
125
|
+
|
126
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
127
|
+
encoding: stream
|
128
|
+
});
|
129
|
+
|
113
130
|
cmapPromise.then(function (cmap) {
|
114
131
|
expect(cmap.lookup(0x14)).toEqual(0x00);
|
115
132
|
expect(cmap.lookup(0x15)).toBeUndefined();
|
@@ -118,24 +135,32 @@ describe('cmap', function () {
|
|
118
135
|
done.fail(reason);
|
119
136
|
});
|
120
137
|
});
|
121
|
-
it(
|
122
|
-
var str =
|
138
|
+
it("parses begincidrange", function (done) {
|
139
|
+
var str = "1 begincidrange\n" + "<0016> <001B> 0\n" + "endcidrange\n";
|
123
140
|
var stream = new _stream.StringStream(str);
|
124
|
-
|
141
|
+
|
142
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
143
|
+
encoding: stream
|
144
|
+
});
|
145
|
+
|
125
146
|
cmapPromise.then(function (cmap) {
|
126
147
|
expect(cmap.lookup(0x15)).toBeUndefined();
|
127
148
|
expect(cmap.lookup(0x16)).toEqual(0x00);
|
128
|
-
expect(cmap.lookup(
|
129
|
-
expect(cmap.lookup(
|
149
|
+
expect(cmap.lookup(0x1b)).toEqual(0x05);
|
150
|
+
expect(cmap.lookup(0x1c)).toBeUndefined();
|
130
151
|
done();
|
131
152
|
}).catch(function (reason) {
|
132
153
|
done.fail(reason);
|
133
154
|
});
|
134
155
|
});
|
135
|
-
it(
|
136
|
-
var str =
|
156
|
+
it("decodes codespace ranges", function (done) {
|
157
|
+
var str = "1 begincodespacerange\n" + "<01> <02>\n" + "<00000003> <00000004>\n" + "endcodespacerange\n";
|
137
158
|
var stream = new _stream.StringStream(str);
|
138
|
-
|
159
|
+
|
160
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
161
|
+
encoding: stream
|
162
|
+
});
|
163
|
+
|
139
164
|
cmapPromise.then(function (cmap) {
|
140
165
|
var c = {};
|
141
166
|
cmap.readCharCode(String.fromCharCode(1), 0, c);
|
@@ -149,54 +174,68 @@ describe('cmap', function () {
|
|
149
174
|
done.fail(reason);
|
150
175
|
});
|
151
176
|
});
|
152
|
-
it(
|
153
|
-
var str =
|
177
|
+
it("decodes 4 byte codespace ranges", function (done) {
|
178
|
+
var str = "1 begincodespacerange\n" + "<8EA1A1A1> <8EA1FEFE>\n" + "endcodespacerange\n";
|
154
179
|
var stream = new _stream.StringStream(str);
|
155
|
-
|
180
|
+
|
181
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
182
|
+
encoding: stream
|
183
|
+
});
|
184
|
+
|
156
185
|
cmapPromise.then(function (cmap) {
|
157
186
|
var c = {};
|
158
|
-
cmap.readCharCode(String.fromCharCode(
|
159
|
-
expect(c.charcode).toEqual(
|
187
|
+
cmap.readCharCode(String.fromCharCode(0x8e, 0xa1, 0xa1, 0xa1), 0, c);
|
188
|
+
expect(c.charcode).toEqual(0x8ea1a1a1);
|
160
189
|
expect(c.length).toEqual(4);
|
161
190
|
done();
|
162
191
|
}).catch(function (reason) {
|
163
192
|
done.fail(reason);
|
164
193
|
});
|
165
194
|
});
|
166
|
-
it(
|
167
|
-
var str =
|
195
|
+
it("read usecmap", function (done) {
|
196
|
+
var str = "/Adobe-Japan1-1 usecmap\n";
|
168
197
|
var stream = new _stream.StringStream(str);
|
198
|
+
|
169
199
|
var cmapPromise = _cmap.CMapFactory.create({
|
170
200
|
encoding: stream,
|
171
|
-
fetchBuiltInCMap
|
201
|
+
fetchBuiltInCMap,
|
172
202
|
useCMap: null
|
173
203
|
});
|
204
|
+
|
174
205
|
cmapPromise.then(function (cmap) {
|
175
206
|
expect(cmap instanceof _cmap.CMap).toEqual(true);
|
176
207
|
expect(cmap.useCMap).not.toBeNull();
|
177
208
|
expect(cmap.builtInCMap).toBeFalsy();
|
178
|
-
expect(cmap.length).toEqual(
|
209
|
+
expect(cmap.length).toEqual(0x20a7);
|
179
210
|
expect(cmap.isIdentityCMap).toEqual(false);
|
180
211
|
done();
|
181
212
|
}).catch(function (reason) {
|
182
213
|
done.fail(reason);
|
183
214
|
});
|
184
215
|
});
|
185
|
-
it(
|
186
|
-
var str =
|
216
|
+
it("parses cmapname", function (done) {
|
217
|
+
var str = "/CMapName /Identity-H def\n";
|
187
218
|
var stream = new _stream.StringStream(str);
|
188
|
-
|
219
|
+
|
220
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
221
|
+
encoding: stream
|
222
|
+
});
|
223
|
+
|
189
224
|
cmapPromise.then(function (cmap) {
|
190
|
-
expect(cmap.name).toEqual(
|
225
|
+
expect(cmap.name).toEqual("Identity-H");
|
191
226
|
done();
|
192
227
|
}).catch(function (reason) {
|
193
228
|
done.fail(reason);
|
194
229
|
});
|
195
230
|
});
|
196
|
-
it(
|
197
|
-
var str =
|
231
|
+
it("parses wmode", function (done) {
|
232
|
+
var str = "/WMode 1 def\n";
|
198
233
|
var stream = new _stream.StringStream(str);
|
199
|
-
|
234
|
+
|
235
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
236
|
+
encoding: stream
|
237
|
+
});
|
238
|
+
|
200
239
|
cmapPromise.then(function (cmap) {
|
201
240
|
expect(cmap.vertical).toEqual(true);
|
202
241
|
done();
|
@@ -204,101 +243,114 @@ describe('cmap', function () {
|
|
204
243
|
done.fail(reason);
|
205
244
|
});
|
206
245
|
});
|
207
|
-
it(
|
246
|
+
it("loads built in cmap", function (done) {
|
208
247
|
var cmapPromise = _cmap.CMapFactory.create({
|
209
|
-
encoding: _primitives.Name.get(
|
210
|
-
fetchBuiltInCMap
|
248
|
+
encoding: _primitives.Name.get("Adobe-Japan1-1"),
|
249
|
+
fetchBuiltInCMap,
|
211
250
|
useCMap: null
|
212
251
|
});
|
252
|
+
|
213
253
|
cmapPromise.then(function (cmap) {
|
214
254
|
expect(cmap instanceof _cmap.CMap).toEqual(true);
|
215
255
|
expect(cmap.useCMap).toBeNull();
|
216
256
|
expect(cmap.builtInCMap).toBeTruthy();
|
217
|
-
expect(cmap.length).toEqual(
|
257
|
+
expect(cmap.length).toEqual(0x20a7);
|
218
258
|
expect(cmap.isIdentityCMap).toEqual(false);
|
219
259
|
done();
|
220
260
|
}).catch(function (reason) {
|
221
261
|
done.fail(reason);
|
222
262
|
});
|
223
263
|
});
|
224
|
-
it(
|
264
|
+
it("loads built in identity cmap", function (done) {
|
225
265
|
var cmapPromise = _cmap.CMapFactory.create({
|
226
|
-
encoding: _primitives.Name.get(
|
227
|
-
fetchBuiltInCMap
|
266
|
+
encoding: _primitives.Name.get("Identity-H"),
|
267
|
+
fetchBuiltInCMap,
|
228
268
|
useCMap: null
|
229
269
|
});
|
270
|
+
|
230
271
|
cmapPromise.then(function (cmap) {
|
231
272
|
expect(cmap instanceof _cmap.IdentityCMap).toEqual(true);
|
232
273
|
expect(cmap.vertical).toEqual(false);
|
233
274
|
expect(cmap.length).toEqual(0x10000);
|
234
275
|
expect(function () {
|
235
276
|
return cmap.isIdentityCMap;
|
236
|
-
}).toThrow(new Error(
|
277
|
+
}).toThrow(new Error("should not access .isIdentityCMap"));
|
237
278
|
done();
|
238
279
|
}).catch(function (reason) {
|
239
280
|
done.fail(reason);
|
240
281
|
});
|
241
282
|
});
|
242
|
-
it(
|
283
|
+
it("attempts to load a non-existent built-in CMap", function (done) {
|
243
284
|
var cmapPromise = _cmap.CMapFactory.create({
|
244
|
-
encoding: _primitives.Name.get(
|
245
|
-
fetchBuiltInCMap
|
285
|
+
encoding: _primitives.Name.get("null"),
|
286
|
+
fetchBuiltInCMap,
|
246
287
|
useCMap: null
|
247
288
|
});
|
289
|
+
|
248
290
|
cmapPromise.then(function () {
|
249
|
-
done.fail(
|
291
|
+
done.fail("No CMap should be loaded");
|
250
292
|
}, function (reason) {
|
251
293
|
expect(reason instanceof Error).toEqual(true);
|
252
|
-
expect(reason.message).toEqual(
|
294
|
+
expect(reason.message).toEqual("Unknown CMap name: null");
|
253
295
|
done();
|
254
296
|
});
|
255
297
|
});
|
256
|
-
it(
|
298
|
+
it("attempts to load a built-in CMap without the necessary API parameters", function (done) {
|
257
299
|
function tmpFetchBuiltInCMap(name) {
|
258
|
-
var CMapReaderFactory =
|
259
|
-
return CMapReaderFactory.fetch({
|
300
|
+
var CMapReaderFactory = _is_node.isNodeJS ? new _test_utils.NodeCMapReaderFactory({}) : new _display_utils.DOMCMapReaderFactory({});
|
301
|
+
return CMapReaderFactory.fetch({
|
302
|
+
name
|
303
|
+
});
|
260
304
|
}
|
305
|
+
|
261
306
|
var cmapPromise = _cmap.CMapFactory.create({
|
262
|
-
encoding: _primitives.Name.get(
|
307
|
+
encoding: _primitives.Name.get("Adobe-Japan1-1"),
|
263
308
|
fetchBuiltInCMap: tmpFetchBuiltInCMap,
|
264
309
|
useCMap: null
|
265
310
|
});
|
311
|
+
|
266
312
|
cmapPromise.then(function () {
|
267
|
-
done.fail(
|
313
|
+
done.fail("No CMap should be loaded");
|
268
314
|
}, function (reason) {
|
269
315
|
expect(reason instanceof Error).toEqual(true);
|
270
316
|
expect(reason.message).toEqual('The CMap "baseUrl" parameter must be specified, ensure that ' + 'the "cMapUrl" and "cMapPacked" API parameters are provided.');
|
271
317
|
done();
|
272
318
|
});
|
273
319
|
});
|
274
|
-
it(
|
320
|
+
it("attempts to load a built-in CMap with inconsistent API parameters", function (done) {
|
275
321
|
function tmpFetchBuiltInCMap(name) {
|
276
|
-
|
277
|
-
|
322
|
+
let CMapReaderFactory;
|
323
|
+
|
324
|
+
if (_is_node.isNodeJS) {
|
278
325
|
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
|
279
326
|
baseUrl: cMapUrl.node,
|
280
327
|
isCompressed: false
|
281
328
|
});
|
282
329
|
} else {
|
283
|
-
CMapReaderFactory = new
|
330
|
+
CMapReaderFactory = new _display_utils.DOMCMapReaderFactory({
|
284
331
|
baseUrl: cMapUrl.dom,
|
285
332
|
isCompressed: false
|
286
333
|
});
|
287
334
|
}
|
288
|
-
|
335
|
+
|
336
|
+
return CMapReaderFactory.fetch({
|
337
|
+
name
|
338
|
+
});
|
289
339
|
}
|
290
|
-
|
291
|
-
|
340
|
+
|
341
|
+
const cmapPromise = _cmap.CMapFactory.create({
|
342
|
+
encoding: _primitives.Name.get("Adobe-Japan1-1"),
|
292
343
|
fetchBuiltInCMap: tmpFetchBuiltInCMap,
|
293
344
|
useCMap: null
|
294
345
|
});
|
346
|
+
|
295
347
|
cmapPromise.then(function () {
|
296
|
-
done.fail(
|
348
|
+
done.fail("No CMap should be loaded");
|
297
349
|
}, function (reason) {
|
298
350
|
expect(reason instanceof Error).toEqual(true);
|
299
|
-
|
300
|
-
expect(message.startsWith(
|
301
|
-
expect(message.endsWith(
|
351
|
+
const message = reason.message;
|
352
|
+
expect(message.startsWith("Unable to load CMap at: ")).toEqual(true);
|
353
|
+
expect(message.endsWith("/external/bcmaps/Adobe-Japan1-1")).toEqual(true);
|
302
354
|
done();
|
303
355
|
});
|
304
356
|
});
|