pdfjs-dist 2.0.943 → 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 +15329 -11095
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +12497 -4184
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/image_decoders/pdf.image_decoders.js +3438 -1209
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/core/annotation.js +335 -109
- package/lib/core/arithmetic_decoder.js +274 -244
- package/lib/core/bidi.js +64 -5
- package/lib/core/ccitt.js +172 -17
- package/lib/core/ccitt_stream.js +14 -5
- package/lib/core/cff_parser.js +304 -28
- package/lib/core/charsets.js +4 -3
- package/lib/core/chunked_stream.js +379 -149
- package/lib/core/cmap.js +210 -40
- package/lib/core/colorspace.js +332 -187
- package/lib/core/crypto.js +289 -44
- package/lib/core/document.js +508 -249
- package/lib/core/encodings.js +18 -9
- package/lib/core/evaluator.js +657 -119
- package/lib/core/font_renderer.js +217 -34
- package/lib/core/fonts.js +632 -41
- package/lib/core/function.js +252 -26
- package/lib/core/glyphlist.js +2 -1
- package/lib/core/image.js +124 -27
- package/lib/core/jbig2.js +425 -65
- package/lib/core/jbig2_stream.js +18 -7
- package/lib/core/jpeg_stream.js +24 -8
- package/lib/core/jpg.js +208 -16
- package/lib/core/jpx.js +395 -5
- package/lib/core/jpx_stream.js +17 -5
- package/lib/core/metrics.js +3 -3
- package/lib/core/murmurhash3.js +23 -5
- package/lib/core/obj.js +625 -132
- package/lib/core/operator_list.js +104 -3
- package/lib/core/parser.js +262 -25
- package/lib/core/pattern.js +144 -12
- package/lib/core/pdf_manager.js +104 -70
- package/lib/core/primitives.js +74 -21
- package/lib/core/ps_parser.js +133 -44
- package/lib/core/standard_fonts.js +9 -9
- package/lib/core/stream.js +283 -31
- package/lib/core/type1_parser.js +138 -6
- package/lib/core/unicode.js +28 -1
- package/lib/core/worker.js +192 -57
- package/lib/display/annotation_layer.js +303 -123
- package/lib/display/api.js +1073 -574
- package/lib/display/api_compatibility.js +4 -1
- package/lib/display/canvas.js +314 -18
- package/lib/display/content_disposition.js +70 -23
- package/lib/display/dom_utils.js +112 -59
- package/lib/display/fetch_stream.js +95 -50
- package/lib/display/font_loader.js +250 -132
- package/lib/display/metadata.js +37 -15
- package/lib/display/network.js +123 -34
- package/lib/display/network_utils.js +23 -10
- package/lib/display/node_stream.js +162 -65
- package/lib/display/pattern_helper.js +57 -6
- package/lib/display/svg.js +194 -18
- package/lib/display/text_layer.js +128 -14
- package/lib/display/transport_stream.js +83 -27
- package/lib/display/webgl.js +63 -17
- package/lib/display/worker_options.js +4 -3
- package/lib/display/xml_parser.js +162 -52
- package/lib/examples/node/domstubs.js +56 -3
- package/lib/pdf.js +15 -2
- package/lib/pdf.worker.js +4 -2
- package/lib/shared/compatibility.js +129 -26
- package/lib/shared/global_scope.js +1 -1
- package/lib/shared/is_node.js +3 -3
- package/lib/shared/message_handler.js +103 -45
- package/lib/shared/streams_polyfill.js +20 -16
- package/lib/shared/url_polyfill.js +8 -2
- package/lib/shared/util.js +246 -84
- package/lib/test/unit/annotation_spec.js +99 -73
- package/lib/test/unit/api_spec.js +347 -113
- package/lib/test/unit/bidi_spec.js +6 -6
- package/lib/test/unit/cff_parser_spec.js +17 -5
- package/lib/test/unit/clitests_helper.js +7 -8
- package/lib/test/unit/cmap_spec.js +79 -25
- package/lib/test/unit/colorspace_spec.js +65 -18
- package/lib/test/unit/crypto_spec.js +16 -4
- package/lib/test/unit/custom_spec.js +40 -52
- package/lib/test/unit/display_svg_spec.js +32 -16
- package/lib/test/unit/document_spec.js +2 -2
- package/lib/test/unit/dom_utils_spec.js +8 -8
- package/lib/test/unit/encodings_spec.js +24 -44
- package/lib/test/unit/evaluator_spec.js +15 -8
- package/lib/test/unit/function_spec.js +16 -4
- package/lib/test/unit/jasmine-boot.js +29 -16
- package/lib/test/unit/message_handler_spec.js +19 -6
- package/lib/test/unit/metadata_spec.js +64 -11
- package/lib/test/unit/murmurhash3_spec.js +2 -2
- package/lib/test/unit/network_spec.js +19 -4
- package/lib/test/unit/network_utils_spec.js +6 -4
- package/lib/test/unit/node_stream_spec.js +50 -26
- package/lib/test/unit/parser_spec.js +13 -29
- package/lib/test/unit/pdf_find_controller_spec.js +144 -32
- package/lib/test/unit/pdf_find_utils_spec.js +10 -9
- package/lib/test/unit/pdf_history_spec.js +20 -8
- package/lib/test/unit/primitives_spec.js +23 -3
- package/lib/test/unit/stream_spec.js +8 -3
- package/lib/test/unit/test_utils.js +89 -26
- package/lib/test/unit/testreporter.js +19 -1
- package/lib/test/unit/type1_parser_spec.js +7 -5
- package/lib/test/unit/ui_utils_spec.js +162 -38
- package/lib/test/unit/unicode_spec.js +13 -10
- package/lib/test/unit/util_spec.js +89 -9
- package/lib/web/annotation_layer_builder.js +38 -21
- package/lib/web/app.js +610 -245
- package/lib/web/app_options.js +54 -34
- package/lib/web/base_viewer.js +359 -162
- package/lib/web/chromecom.js +159 -80
- package/lib/web/debugger.js +161 -17
- package/lib/web/download_manager.js +29 -11
- package/lib/web/firefox_print_service.js +16 -8
- package/lib/web/firefoxcom.js +127 -91
- package/lib/web/genericcom.js +50 -31
- package/lib/web/genericl10n.js +46 -34
- package/lib/web/grab_to_pan.js +25 -3
- package/lib/web/interfaces.js +108 -61
- package/lib/web/overlay_manager.js +67 -45
- package/lib/web/password_prompt.js +20 -12
- package/lib/web/pdf_attachment_viewer.js +37 -17
- package/lib/web/pdf_cursor_tools.js +38 -15
- package/lib/web/pdf_document_properties.js +65 -24
- package/lib/web/pdf_find_bar.js +48 -20
- package/lib/web/pdf_find_controller.js +290 -89
- package/lib/web/pdf_find_utils.js +19 -3
- package/lib/web/pdf_history.js +186 -49
- package/lib/web/pdf_link_service.js +127 -52
- package/lib/web/pdf_outline_viewer.js +71 -21
- package/lib/web/pdf_page_view.js +188 -63
- package/lib/web/pdf_presentation_mode.js +98 -33
- package/lib/web/pdf_print_service.js +54 -10
- package/lib/web/pdf_rendering_queue.js +26 -4
- package/lib/web/pdf_sidebar.js +116 -62
- package/lib/web/pdf_sidebar_resizer.js +41 -15
- package/lib/web/pdf_single_page_viewer.js +65 -68
- package/lib/web/pdf_thumbnail_view.js +102 -31
- package/lib/web/pdf_thumbnail_viewer.js +62 -22
- package/lib/web/pdf_viewer.component.js +111 -31
- package/lib/web/pdf_viewer.js +80 -60
- package/lib/web/preferences.js +61 -39
- package/lib/web/secondary_toolbar.js +101 -82
- package/lib/web/text_layer_builder.js +124 -69
- package/lib/web/toolbar.js +67 -27
- package/lib/web/ui_utils.js +284 -128
- package/lib/web/view_history.js +75 -51
- package/lib/web/viewer_compatibility.js +2 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +1 -1
- package/web/pdf_viewer.js +2200 -973
- package/web/pdf_viewer.js.map +1 -1
- package/lib/web/dom_events.js +0 -140
@@ -19,21 +19,21 @@
|
|
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 _bidi = require(
|
24
|
+
var _bidi = require("../../core/bidi");
|
25
25
|
|
26
26
|
describe('bidi', function () {
|
27
27
|
it('should mark text as RTL if more than 30% of text is RTL', function () {
|
28
|
-
var test =
|
29
|
-
var result =
|
28
|
+
var test = "\u0645\u0635\u0631 Egypt";
|
29
|
+
var result = "Egypt \u0631\u0635\u0645";
|
30
30
|
var bidiText = (0, _bidi.bidi)(test, -1, false);
|
31
31
|
expect(bidiText.str).toEqual(result);
|
32
32
|
expect(bidiText.dir).toEqual('rtl');
|
33
33
|
});
|
34
34
|
it('should mark text as LTR if less than 30% of text is RTL', function () {
|
35
|
-
var test =
|
36
|
-
var result =
|
35
|
+
var test = "Egypt is known as \u0645\u0635\u0631 in Arabic.";
|
36
|
+
var result = "Egypt is known as \u0631\u0635\u0645 in Arabic.";
|
37
37
|
var bidiText = (0, _bidi.bidi)(test, -1, false);
|
38
38
|
expect(bidiText.str).toEqual(result);
|
39
39
|
expect(bidiText.dir).toEqual('ltr');
|
@@ -19,22 +19,25 @@
|
|
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 _cff_parser = require(
|
24
|
+
var _cff_parser = require("../../core/cff_parser");
|
25
25
|
|
26
|
-
var _fonts = require(
|
26
|
+
var _fonts = require("../../core/fonts");
|
27
27
|
|
28
|
-
var _stream = require(
|
28
|
+
var _stream = require("../../core/stream");
|
29
29
|
|
30
30
|
describe('CFFParser', function () {
|
31
31
|
function createWithNullProto(obj) {
|
32
32
|
var result = Object.create(null);
|
33
|
+
|
33
34
|
for (var i in obj) {
|
34
35
|
result[i] = obj[i];
|
35
36
|
}
|
37
|
+
|
36
38
|
return result;
|
37
39
|
}
|
40
|
+
|
38
41
|
var privateDictStub = {
|
39
42
|
getByName: function getByName(name) {
|
40
43
|
return 0;
|
@@ -44,10 +47,12 @@ describe('CFFParser', function () {
|
|
44
47
|
beforeAll(function (done) {
|
45
48
|
var exampleFont = '0100040100010101134142434445462b' + '54696d65732d526f6d616e000101011f' + 'f81b00f81c02f81d03f819041c6f000d' + 'fb3cfb6efa7cfa1605e911b8f1120003' + '01010813183030312e30303754696d65' + '7320526f6d616e54696d657300000002' + '010102030e0e7d99f92a99fb7695f773' + '8b06f79a93fc7c8c077d99f85695f75e' + '9908fb6e8cf87393f7108b09a70adf0b' + 'f78e14';
|
46
49
|
var fontArr = [];
|
50
|
+
|
47
51
|
for (var i = 0, ii = exampleFont.length; i < ii; i += 2) {
|
48
52
|
var hex = exampleFont.substring(i, i + 2);
|
49
53
|
fontArr.push(parseInt(hex, 16));
|
50
54
|
}
|
55
|
+
|
51
56
|
fontData = new _stream.Stream(fontArr);
|
52
57
|
done();
|
53
58
|
});
|
@@ -103,9 +108,11 @@ describe('CFFParser', function () {
|
|
103
108
|
parser.bytes = bytes;
|
104
109
|
var topDict = cff.topDict;
|
105
110
|
topDict.setByName('Private', [bytes.length, 0]);
|
111
|
+
|
106
112
|
var parsePrivateDict = function parsePrivateDict() {
|
107
113
|
parser.parsePrivateDict(topDict);
|
108
114
|
};
|
115
|
+
|
109
116
|
expect(parsePrivateDict).not.toThrow();
|
110
117
|
var privateDict = topDict.privateDict;
|
111
118
|
expect(privateDict.getByName('BlueValues')).toBeNull();
|
@@ -198,7 +205,9 @@ describe('CFFParser', function () {
|
|
198
205
|
var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x08]);
|
199
206
|
parser.bytes = bytes;
|
200
207
|
var encoding = parser.parseEncoding(2, {}, new _cff_parser.CFFStrings(), null);
|
201
|
-
expect(encoding.encoding).toEqual(createWithNullProto({
|
208
|
+
expect(encoding.encoding).toEqual(createWithNullProto({
|
209
|
+
0x8: 1
|
210
|
+
}));
|
202
211
|
});
|
203
212
|
it('parses encoding format 1', function () {
|
204
213
|
var bytes = new Uint8Array([0x00, 0x00, 0x01, 0x01, 0x07, 0x01]);
|
@@ -240,6 +249,7 @@ describe('CFFCompiler', function () {
|
|
240
249
|
}
|
241
250
|
}, {}, _fonts.SEAC_ANALYSIS_ENABLED);
|
242
251
|
}
|
252
|
+
|
243
253
|
it('encodes integers', function () {
|
244
254
|
var c = new _cff_parser.CFFCompiler();
|
245
255
|
expect(c.encodeInteger(0)).toEqual([0x8b]);
|
@@ -265,9 +275,11 @@ describe('CFFCompiler', function () {
|
|
265
275
|
var names = parser.parseNameIndex(nameIndex.obj);
|
266
276
|
expect(names).toEqual(['_a']);
|
267
277
|
var longName = '';
|
278
|
+
|
268
279
|
for (var i = 0; i < 129; i++) {
|
269
280
|
longName += '_';
|
270
281
|
}
|
282
|
+
|
271
283
|
nameIndexCompiled = c.compileNameIndex([longName]);
|
272
284
|
parser = testParser(nameIndexCompiled);
|
273
285
|
nameIndex = parser.parseIndex(0);
|
@@ -19,23 +19,22 @@
|
|
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 _util = require(
|
24
|
+
var _util = require("../../shared/util");
|
25
25
|
|
26
|
-
var _is_node = require(
|
26
|
+
var _is_node = _interopRequireDefault(require("../../shared/is_node"));
|
27
27
|
|
28
|
-
var
|
28
|
+
var _node_stream = require("../../display/node_stream");
|
29
29
|
|
30
|
-
var
|
31
|
-
|
32
|
-
var _api = require('../../display/api');
|
30
|
+
var _api = require("../../display/api");
|
33
31
|
|
34
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
33
|
|
36
|
-
if (!(0,
|
34
|
+
if (!(0, _is_node.default)()) {
|
37
35
|
throw new Error('The `gulp unittestcli` command can only be used in ' + 'Node.js environments.');
|
38
36
|
}
|
37
|
+
|
39
38
|
(0, _util.setVerbosityLevel)(_util.VerbosityLevel.ERRORS);
|
40
39
|
(0, _api.setPDFNetworkStreamFactory)(function (params) {
|
41
40
|
return new _node_stream.PDFNodeStream(params);
|
@@ -19,21 +19,19 @@
|
|
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");
|
25
25
|
|
26
|
-
var _dom_utils = require(
|
26
|
+
var _dom_utils = require("../../display/dom_utils");
|
27
27
|
|
28
|
-
var _is_node = require(
|
28
|
+
var _is_node = _interopRequireDefault(require("../../shared/is_node"));
|
29
29
|
|
30
|
-
var
|
30
|
+
var _primitives = require("../../core/primitives");
|
31
31
|
|
32
|
-
var
|
32
|
+
var _test_utils = require("./test_utils");
|
33
33
|
|
34
|
-
var
|
35
|
-
|
36
|
-
var _stream = require('../../core/stream');
|
34
|
+
var _stream = require("../../core/stream");
|
37
35
|
|
38
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
39
37
|
|
@@ -46,7 +44,8 @@ describe('cmap', function () {
|
|
46
44
|
var fetchBuiltInCMap;
|
47
45
|
beforeAll(function (done) {
|
48
46
|
var CMapReaderFactory;
|
49
|
-
|
47
|
+
|
48
|
+
if ((0, _is_node.default)()) {
|
50
49
|
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
|
51
50
|
baseUrl: cMapUrl.node,
|
52
51
|
isCompressed: cMapPacked
|
@@ -57,9 +56,13 @@ describe('cmap', function () {
|
|
57
56
|
isCompressed: cMapPacked
|
58
57
|
});
|
59
58
|
}
|
59
|
+
|
60
60
|
fetchBuiltInCMap = function fetchBuiltInCMap(name) {
|
61
|
-
return CMapReaderFactory.fetch({
|
61
|
+
return CMapReaderFactory.fetch({
|
62
|
+
name: name
|
63
|
+
});
|
62
64
|
};
|
65
|
+
|
63
66
|
done();
|
64
67
|
});
|
65
68
|
afterAll(function () {
|
@@ -68,7 +71,11 @@ describe('cmap', function () {
|
|
68
71
|
it('parses beginbfchar', function (done) {
|
69
72
|
var str = '2 beginbfchar\n' + '<03> <00>\n' + '<04> <01>\n' + 'endbfchar\n';
|
70
73
|
var stream = new _stream.StringStream(str);
|
71
|
-
|
74
|
+
|
75
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
76
|
+
encoding: stream
|
77
|
+
});
|
78
|
+
|
72
79
|
cmapPromise.then(function (cmap) {
|
73
80
|
expect(cmap.lookup(0x03)).toEqual(String.fromCharCode(0x00));
|
74
81
|
expect(cmap.lookup(0x04)).toEqual(String.fromCharCode(0x01));
|
@@ -81,7 +88,11 @@ describe('cmap', function () {
|
|
81
88
|
it('parses beginbfrange with range', function (done) {
|
82
89
|
var str = '1 beginbfrange\n' + '<06> <0B> 0\n' + 'endbfrange\n';
|
83
90
|
var stream = new _stream.StringStream(str);
|
84
|
-
|
91
|
+
|
92
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
93
|
+
encoding: stream
|
94
|
+
});
|
95
|
+
|
85
96
|
cmapPromise.then(function (cmap) {
|
86
97
|
expect(cmap.lookup(0x05)).toBeUndefined();
|
87
98
|
expect(cmap.lookup(0x06)).toEqual(String.fromCharCode(0x00));
|
@@ -95,7 +106,11 @@ describe('cmap', function () {
|
|
95
106
|
it('parses beginbfrange with array', function (done) {
|
96
107
|
var str = '1 beginbfrange\n' + '<0D> <12> [ 0 1 2 3 4 5 ]\n' + 'endbfrange\n';
|
97
108
|
var stream = new _stream.StringStream(str);
|
98
|
-
|
109
|
+
|
110
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
111
|
+
encoding: stream
|
112
|
+
});
|
113
|
+
|
99
114
|
cmapPromise.then(function (cmap) {
|
100
115
|
expect(cmap.lookup(0x0C)).toBeUndefined();
|
101
116
|
expect(cmap.lookup(0x0D)).toEqual(0x00);
|
@@ -109,7 +124,11 @@ describe('cmap', function () {
|
|
109
124
|
it('parses begincidchar', function (done) {
|
110
125
|
var str = '1 begincidchar\n' + '<14> 0\n' + 'endcidchar\n';
|
111
126
|
var stream = new _stream.StringStream(str);
|
112
|
-
|
127
|
+
|
128
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
129
|
+
encoding: stream
|
130
|
+
});
|
131
|
+
|
113
132
|
cmapPromise.then(function (cmap) {
|
114
133
|
expect(cmap.lookup(0x14)).toEqual(0x00);
|
115
134
|
expect(cmap.lookup(0x15)).toBeUndefined();
|
@@ -121,7 +140,11 @@ describe('cmap', function () {
|
|
121
140
|
it('parses begincidrange', function (done) {
|
122
141
|
var str = '1 begincidrange\n' + '<0016> <001B> 0\n' + 'endcidrange\n';
|
123
142
|
var stream = new _stream.StringStream(str);
|
124
|
-
|
143
|
+
|
144
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
145
|
+
encoding: stream
|
146
|
+
});
|
147
|
+
|
125
148
|
cmapPromise.then(function (cmap) {
|
126
149
|
expect(cmap.lookup(0x15)).toBeUndefined();
|
127
150
|
expect(cmap.lookup(0x16)).toEqual(0x00);
|
@@ -135,7 +158,11 @@ describe('cmap', function () {
|
|
135
158
|
it('decodes codespace ranges', function (done) {
|
136
159
|
var str = '1 begincodespacerange\n' + '<01> <02>\n' + '<00000003> <00000004>\n' + 'endcodespacerange\n';
|
137
160
|
var stream = new _stream.StringStream(str);
|
138
|
-
|
161
|
+
|
162
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
163
|
+
encoding: stream
|
164
|
+
});
|
165
|
+
|
139
166
|
cmapPromise.then(function (cmap) {
|
140
167
|
var c = {};
|
141
168
|
cmap.readCharCode(String.fromCharCode(1), 0, c);
|
@@ -152,7 +179,11 @@ describe('cmap', function () {
|
|
152
179
|
it('decodes 4 byte codespace ranges', function (done) {
|
153
180
|
var str = '1 begincodespacerange\n' + '<8EA1A1A1> <8EA1FEFE>\n' + 'endcodespacerange\n';
|
154
181
|
var stream = new _stream.StringStream(str);
|
155
|
-
|
182
|
+
|
183
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
184
|
+
encoding: stream
|
185
|
+
});
|
186
|
+
|
156
187
|
cmapPromise.then(function (cmap) {
|
157
188
|
var c = {};
|
158
189
|
cmap.readCharCode(String.fromCharCode(0x8E, 0xA1, 0xA1, 0xA1), 0, c);
|
@@ -166,11 +197,13 @@ describe('cmap', function () {
|
|
166
197
|
it('read usecmap', function (done) {
|
167
198
|
var str = '/Adobe-Japan1-1 usecmap\n';
|
168
199
|
var stream = new _stream.StringStream(str);
|
200
|
+
|
169
201
|
var cmapPromise = _cmap.CMapFactory.create({
|
170
202
|
encoding: stream,
|
171
203
|
fetchBuiltInCMap: fetchBuiltInCMap,
|
172
204
|
useCMap: null
|
173
205
|
});
|
206
|
+
|
174
207
|
cmapPromise.then(function (cmap) {
|
175
208
|
expect(cmap instanceof _cmap.CMap).toEqual(true);
|
176
209
|
expect(cmap.useCMap).not.toBeNull();
|
@@ -185,7 +218,11 @@ describe('cmap', function () {
|
|
185
218
|
it('parses cmapname', function (done) {
|
186
219
|
var str = '/CMapName /Identity-H def\n';
|
187
220
|
var stream = new _stream.StringStream(str);
|
188
|
-
|
221
|
+
|
222
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
223
|
+
encoding: stream
|
224
|
+
});
|
225
|
+
|
189
226
|
cmapPromise.then(function (cmap) {
|
190
227
|
expect(cmap.name).toEqual('Identity-H');
|
191
228
|
done();
|
@@ -196,7 +233,11 @@ describe('cmap', function () {
|
|
196
233
|
it('parses wmode', function (done) {
|
197
234
|
var str = '/WMode 1 def\n';
|
198
235
|
var stream = new _stream.StringStream(str);
|
199
|
-
|
236
|
+
|
237
|
+
var cmapPromise = _cmap.CMapFactory.create({
|
238
|
+
encoding: stream
|
239
|
+
});
|
240
|
+
|
200
241
|
cmapPromise.then(function (cmap) {
|
201
242
|
expect(cmap.vertical).toEqual(true);
|
202
243
|
done();
|
@@ -210,6 +251,7 @@ describe('cmap', function () {
|
|
210
251
|
fetchBuiltInCMap: fetchBuiltInCMap,
|
211
252
|
useCMap: null
|
212
253
|
});
|
254
|
+
|
213
255
|
cmapPromise.then(function (cmap) {
|
214
256
|
expect(cmap instanceof _cmap.CMap).toEqual(true);
|
215
257
|
expect(cmap.useCMap).toBeNull();
|
@@ -227,6 +269,7 @@ describe('cmap', function () {
|
|
227
269
|
fetchBuiltInCMap: fetchBuiltInCMap,
|
228
270
|
useCMap: null
|
229
271
|
});
|
272
|
+
|
230
273
|
cmapPromise.then(function (cmap) {
|
231
274
|
expect(cmap instanceof _cmap.IdentityCMap).toEqual(true);
|
232
275
|
expect(cmap.vertical).toEqual(false);
|
@@ -245,6 +288,7 @@ describe('cmap', function () {
|
|
245
288
|
fetchBuiltInCMap: fetchBuiltInCMap,
|
246
289
|
useCMap: null
|
247
290
|
});
|
291
|
+
|
248
292
|
cmapPromise.then(function () {
|
249
293
|
done.fail('No CMap should be loaded');
|
250
294
|
}, function (reason) {
|
@@ -255,14 +299,18 @@ describe('cmap', function () {
|
|
255
299
|
});
|
256
300
|
it('attempts to load a built-in CMap without the necessary API parameters', function (done) {
|
257
301
|
function tmpFetchBuiltInCMap(name) {
|
258
|
-
var CMapReaderFactory = (0,
|
259
|
-
return CMapReaderFactory.fetch({
|
302
|
+
var CMapReaderFactory = (0, _is_node.default)() ? new _test_utils.NodeCMapReaderFactory({}) : new _dom_utils.DOMCMapReaderFactory({});
|
303
|
+
return CMapReaderFactory.fetch({
|
304
|
+
name: name
|
305
|
+
});
|
260
306
|
}
|
307
|
+
|
261
308
|
var cmapPromise = _cmap.CMapFactory.create({
|
262
309
|
encoding: _primitives.Name.get('Adobe-Japan1-1'),
|
263
310
|
fetchBuiltInCMap: tmpFetchBuiltInCMap,
|
264
311
|
useCMap: null
|
265
312
|
});
|
313
|
+
|
266
314
|
cmapPromise.then(function () {
|
267
315
|
done.fail('No CMap should be loaded');
|
268
316
|
}, function (reason) {
|
@@ -273,8 +321,9 @@ describe('cmap', function () {
|
|
273
321
|
});
|
274
322
|
it('attempts to load a built-in CMap with inconsistent API parameters', function (done) {
|
275
323
|
function tmpFetchBuiltInCMap(name) {
|
276
|
-
var CMapReaderFactory
|
277
|
-
|
324
|
+
var CMapReaderFactory;
|
325
|
+
|
326
|
+
if ((0, _is_node.default)()) {
|
278
327
|
CMapReaderFactory = new _test_utils.NodeCMapReaderFactory({
|
279
328
|
baseUrl: cMapUrl.node,
|
280
329
|
isCompressed: false
|
@@ -285,13 +334,18 @@ describe('cmap', function () {
|
|
285
334
|
isCompressed: false
|
286
335
|
});
|
287
336
|
}
|
288
|
-
|
337
|
+
|
338
|
+
return CMapReaderFactory.fetch({
|
339
|
+
name: name
|
340
|
+
});
|
289
341
|
}
|
342
|
+
|
290
343
|
var cmapPromise = _cmap.CMapFactory.create({
|
291
344
|
encoding: _primitives.Name.get('Adobe-Japan1-1'),
|
292
345
|
fetchBuiltInCMap: tmpFetchBuiltInCMap,
|
293
346
|
useCMap: null
|
294
347
|
});
|
348
|
+
|
295
349
|
cmapPromise.then(function () {
|
296
350
|
done.fail('No CMap should be loaded');
|
297
351
|
}, function (reason) {
|
@@ -19,17 +19,17 @@
|
|
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 _primitives = require(
|
24
|
+
var _primitives = require("../../core/primitives");
|
25
25
|
|
26
|
-
var _stream = require(
|
26
|
+
var _stream = require("../../core/stream");
|
27
27
|
|
28
|
-
var _colorspace = require(
|
28
|
+
var _colorspace = require("../../core/colorspace");
|
29
29
|
|
30
|
-
var _function = require(
|
30
|
+
var _function = require("../../core/function");
|
31
31
|
|
32
|
-
var _test_utils = require(
|
32
|
+
var _test_utils = require("./test_utils");
|
33
33
|
|
34
34
|
describe('colorspace', function () {
|
35
35
|
describe('ColorSpace', function () {
|
@@ -53,13 +53,18 @@ describe('colorspace', function () {
|
|
53
53
|
describe('DeviceGrayCS', function () {
|
54
54
|
it('should handle the case when cs is a Name object', function () {
|
55
55
|
var cs = _primitives.Name.get('DeviceGray');
|
56
|
+
|
56
57
|
var xref = new _test_utils.XRefMock([{
|
57
58
|
ref: new _primitives.Ref(10, 0),
|
58
59
|
data: new _primitives.Dict()
|
59
60
|
}]);
|
60
61
|
var res = new _primitives.Dict();
|
61
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
62
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
63
|
+
xref: xref
|
64
|
+
});
|
65
|
+
|
62
66
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
67
|
+
|
63
68
|
var testSrc = new Uint8Array([27, 125, 250, 131]);
|
64
69
|
var testDest = new Uint8ClampedArray(4 * 4 * 3);
|
65
70
|
var expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131, 250, 250, 250, 250, 250, 250, 131, 131, 131, 131, 131, 131]);
|
@@ -76,8 +81,12 @@ describe('colorspace', function () {
|
|
76
81
|
data: _primitives.Name.get('DeviceGray')
|
77
82
|
}]);
|
78
83
|
var res = new _primitives.Dict();
|
79
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
84
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
85
|
+
xref: xref
|
86
|
+
});
|
87
|
+
|
80
88
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
89
|
+
|
81
90
|
var testSrc = new Uint8Array([27, 125, 250, 131]);
|
82
91
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
83
92
|
var expectedDest = new Uint8ClampedArray([27, 27, 27, 27, 27, 27, 125, 125, 125, 27, 27, 27, 27, 27, 27, 125, 125, 125, 250, 250, 250, 250, 250, 250, 131, 131, 131]);
|
@@ -91,13 +100,18 @@ describe('colorspace', function () {
|
|
91
100
|
describe('DeviceRgbCS', function () {
|
92
101
|
it('should handle the case when cs is a Name object', function () {
|
93
102
|
var cs = _primitives.Name.get('DeviceRGB');
|
103
|
+
|
94
104
|
var xref = new _test_utils.XRefMock([{
|
95
105
|
ref: new _primitives.Ref(10, 0),
|
96
106
|
data: new _primitives.Dict()
|
97
107
|
}]);
|
98
108
|
var res = new _primitives.Dict();
|
99
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
109
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
110
|
+
xref: xref
|
111
|
+
});
|
112
|
+
|
100
113
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
114
|
+
|
101
115
|
var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
102
116
|
var testDest = new Uint8ClampedArray(4 * 4 * 3);
|
103
117
|
var expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255, 111, 25, 198, 111, 25, 198, 21, 147, 255, 21, 147, 255]);
|
@@ -114,8 +128,12 @@ describe('colorspace', function () {
|
|
114
128
|
data: _primitives.Name.get('DeviceRGB')
|
115
129
|
}]);
|
116
130
|
var res = new _primitives.Dict();
|
117
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
131
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
132
|
+
xref: xref
|
133
|
+
});
|
134
|
+
|
118
135
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
136
|
+
|
119
137
|
var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
120
138
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
121
139
|
var expectedDest = new Uint8ClampedArray([27, 125, 250, 27, 125, 250, 131, 139, 140, 27, 125, 250, 27, 125, 250, 131, 139, 140, 111, 25, 198, 111, 25, 198, 21, 147, 255]);
|
@@ -129,13 +147,18 @@ describe('colorspace', function () {
|
|
129
147
|
describe('DeviceCmykCS', function () {
|
130
148
|
it('should handle the case when cs is a Name object', function () {
|
131
149
|
var cs = _primitives.Name.get('DeviceCMYK');
|
150
|
+
|
132
151
|
var xref = new _test_utils.XRefMock([{
|
133
152
|
ref: new _primitives.Ref(10, 0),
|
134
153
|
data: new _primitives.Dict()
|
135
154
|
}]);
|
136
155
|
var res = new _primitives.Dict();
|
137
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
156
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
157
|
+
xref: xref
|
158
|
+
});
|
159
|
+
|
138
160
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
161
|
+
|
139
162
|
var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
140
163
|
var testDest = new Uint8ClampedArray(4 * 4 * 3);
|
141
164
|
var expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27, 112, 144, 75, 112, 144, 75, 188, 98, 27, 188, 98, 27]);
|
@@ -152,8 +175,12 @@ describe('colorspace', function () {
|
|
152
175
|
data: _primitives.Name.get('DeviceCMYK')
|
153
176
|
}]);
|
154
177
|
var res = new _primitives.Dict();
|
155
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
178
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
179
|
+
xref: xref
|
180
|
+
});
|
181
|
+
|
156
182
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
183
|
+
|
157
184
|
var testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
158
185
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
159
186
|
var expectedDest = new Uint8ClampedArray([135, 81, 18, 135, 81, 18, 114, 102, 97, 135, 81, 18, 135, 81, 18, 114, 102, 97, 112, 144, 75, 112, 144, 75, 188, 98, 27]);
|
@@ -176,8 +203,12 @@ describe('colorspace', function () {
|
|
176
203
|
data: new _primitives.Dict()
|
177
204
|
}]);
|
178
205
|
var res = new _primitives.Dict();
|
179
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
206
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
207
|
+
xref: xref
|
208
|
+
});
|
209
|
+
|
180
210
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
211
|
+
|
181
212
|
var testSrc = new Uint8Array([27, 125, 250, 131]);
|
182
213
|
var testDest = new Uint8ClampedArray(4 * 4 * 3);
|
183
214
|
var expectedDest = new Uint8ClampedArray([25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 25, 25, 25, 25, 25, 25, 143, 143, 143, 143, 143, 143, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149, 251, 251, 251, 251, 251, 251, 149, 149, 149, 149, 149, 149]);
|
@@ -201,8 +232,12 @@ describe('colorspace', function () {
|
|
201
232
|
data: new _primitives.Dict()
|
202
233
|
}]);
|
203
234
|
var res = new _primitives.Dict();
|
204
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
235
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
236
|
+
xref: xref
|
237
|
+
});
|
238
|
+
|
205
239
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
240
|
+
|
206
241
|
var testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
207
242
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
208
243
|
var expectedDest = new Uint8ClampedArray([0, 238, 255, 0, 238, 255, 185, 196, 195, 0, 238, 255, 0, 238, 255, 185, 196, 195, 235, 0, 243, 235, 0, 243, 0, 255, 255]);
|
@@ -225,8 +260,12 @@ describe('colorspace', function () {
|
|
225
260
|
data: new _primitives.Dict()
|
226
261
|
}]);
|
227
262
|
var res = new _primitives.Dict();
|
228
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
263
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
264
|
+
xref: xref
|
265
|
+
});
|
266
|
+
|
229
267
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
268
|
+
|
230
269
|
var testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
|
231
270
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
232
271
|
var expectedDest = new Uint8ClampedArray([0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 49, 101, 0, 49, 101, 0, 53, 117, 0, 41, 40, 0, 41, 40, 0, 43, 90]);
|
@@ -247,15 +286,19 @@ describe('colorspace', function () {
|
|
247
286
|
data: new _primitives.Dict()
|
248
287
|
}]);
|
249
288
|
var res = new _primitives.Dict();
|
250
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
289
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
290
|
+
xref: xref
|
291
|
+
});
|
292
|
+
|
251
293
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
294
|
+
|
252
295
|
var testSrc = new Uint8Array([2, 2, 0, 1]);
|
253
296
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
254
297
|
var expectedDest = new Uint8ClampedArray([255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 255, 109, 70, 23, 155, 35, 23, 155, 35, 147, 69, 93]);
|
255
298
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
256
299
|
expect(colorSpace.getRgb([2], 0)).toEqual(new Uint8ClampedArray([255, 109, 70]));
|
257
300
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
258
|
-
expect(colorSpace.isDefaultDecode([0, 1])).toBeTruthy();
|
301
|
+
expect(colorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
|
259
302
|
expect(testDest).toEqual(expectedDest);
|
260
303
|
});
|
261
304
|
});
|
@@ -275,8 +318,12 @@ describe('colorspace', function () {
|
|
275
318
|
data: fn
|
276
319
|
}]);
|
277
320
|
var res = new _primitives.Dict();
|
278
|
-
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
321
|
+
var pdfFunctionFactory = new _function.PDFFunctionFactory({
|
322
|
+
xref: xref
|
323
|
+
});
|
324
|
+
|
279
325
|
var colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
326
|
+
|
280
327
|
var testSrc = new Uint8Array([27, 25, 50, 31]);
|
281
328
|
var testDest = new Uint8ClampedArray(3 * 3 * 3);
|
282
329
|
var expectedDest = new Uint8ClampedArray([226, 242, 241, 226, 242, 241, 229, 244, 242, 226, 242, 241, 226, 242, 241, 229, 244, 242, 203, 232, 229, 203, 232, 229, 222, 241, 238]);
|