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,28 +19,28 @@
|
|
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.js");
|
25
25
|
|
26
|
-
var _stream = require(
|
26
|
+
var _stream = require("../../core/stream.js");
|
27
27
|
|
28
|
-
var _colorspace = require(
|
28
|
+
var _colorspace = require("../../core/colorspace.js");
|
29
29
|
|
30
|
-
var _function = require(
|
30
|
+
var _function = require("../../core/function.js");
|
31
31
|
|
32
|
-
var _test_utils = require(
|
32
|
+
var _test_utils = require("./test_utils.js");
|
33
33
|
|
34
|
-
describe(
|
35
|
-
describe(
|
36
|
-
it(
|
37
|
-
expect(_colorspace.ColorSpace.isDefaultDecode(
|
34
|
+
describe("colorspace", function () {
|
35
|
+
describe("ColorSpace", function () {
|
36
|
+
it("should be true if decode is not an array", function () {
|
37
|
+
expect(_colorspace.ColorSpace.isDefaultDecode("string", 0)).toBeTruthy();
|
38
38
|
});
|
39
|
-
it(
|
39
|
+
it("should be true if length of decode array is not correct", function () {
|
40
40
|
expect(_colorspace.ColorSpace.isDefaultDecode([0], 1)).toBeTruthy();
|
41
41
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 1, 0], 1)).toBeTruthy();
|
42
42
|
});
|
43
|
-
it(
|
43
|
+
it("should be true if decode map matches the default decode map", function () {
|
44
44
|
expect(_colorspace.ColorSpace.isDefaultDecode([], 0)).toBeTruthy();
|
45
45
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 0], 1)).toBeFalsy();
|
46
46
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
|
@@ -50,37 +50,47 @@ describe('colorspace', function () {
|
|
50
50
|
expect(_colorspace.ColorSpace.isDefaultDecode([1, 0, 0, 1, 0, 1, 0, 1], 4)).toBeFalsy();
|
51
51
|
});
|
52
52
|
});
|
53
|
-
describe(
|
54
|
-
it(
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
describe("DeviceGrayCS", function () {
|
54
|
+
it("should handle the case when cs is a Name object", function () {
|
55
|
+
const cs = _primitives.Name.get("DeviceGray");
|
56
|
+
|
57
|
+
const xref = new _test_utils.XRefMock([{
|
58
|
+
ref: _primitives.Ref.get(10, 0),
|
58
59
|
data: new _primitives.Dict()
|
59
60
|
}]);
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
const res = new _primitives.Dict();
|
62
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
63
|
+
xref
|
64
|
+
});
|
65
|
+
|
66
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
67
|
+
|
68
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
69
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
70
|
+
const 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]);
|
66
71
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
67
72
|
expect(colorSpace.getRgb(new Float32Array([0.1]), 0)).toEqual(new Uint8ClampedArray([26, 26, 26]));
|
68
73
|
expect(colorSpace.getOutputLength(2, 0)).toEqual(6);
|
69
74
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
70
75
|
expect(testDest).toEqual(expectedDest);
|
71
76
|
});
|
72
|
-
it(
|
73
|
-
|
74
|
-
|
77
|
+
it("should handle the case when cs is an indirect object", function () {
|
78
|
+
const cs = _primitives.Ref.get(10, 0);
|
79
|
+
|
80
|
+
const xref = new _test_utils.XRefMock([{
|
75
81
|
ref: cs,
|
76
|
-
data: _primitives.Name.get(
|
82
|
+
data: _primitives.Name.get("DeviceGray")
|
77
83
|
}]);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
const res = new _primitives.Dict();
|
85
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
86
|
+
xref
|
87
|
+
});
|
88
|
+
|
89
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
90
|
+
|
91
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
92
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
93
|
+
const 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]);
|
84
94
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
85
95
|
expect(colorSpace.getRgb(new Float32Array([0.2]), 0)).toEqual(new Uint8ClampedArray([51, 51, 51]));
|
86
96
|
expect(colorSpace.getOutputLength(3, 1)).toEqual(12);
|
@@ -88,37 +98,47 @@ describe('colorspace', function () {
|
|
88
98
|
expect(testDest).toEqual(expectedDest);
|
89
99
|
});
|
90
100
|
});
|
91
|
-
describe(
|
92
|
-
it(
|
93
|
-
|
94
|
-
|
95
|
-
|
101
|
+
describe("DeviceRgbCS", function () {
|
102
|
+
it("should handle the case when cs is a Name object", function () {
|
103
|
+
const cs = _primitives.Name.get("DeviceRGB");
|
104
|
+
|
105
|
+
const xref = new _test_utils.XRefMock([{
|
106
|
+
ref: _primitives.Ref.get(10, 0),
|
96
107
|
data: new _primitives.Dict()
|
97
108
|
}]);
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
109
|
+
const res = new _primitives.Dict();
|
110
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
111
|
+
xref
|
112
|
+
});
|
113
|
+
|
114
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
115
|
+
|
116
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
117
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
118
|
+
const 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]);
|
104
119
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
105
120
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
|
106
121
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
107
122
|
expect(colorSpace.isPassthrough(8)).toBeTruthy();
|
108
123
|
expect(testDest).toEqual(expectedDest);
|
109
124
|
});
|
110
|
-
it(
|
111
|
-
|
112
|
-
|
125
|
+
it("should handle the case when cs is an indirect object", function () {
|
126
|
+
const cs = _primitives.Ref.get(10, 0);
|
127
|
+
|
128
|
+
const xref = new _test_utils.XRefMock([{
|
113
129
|
ref: cs,
|
114
|
-
data: _primitives.Name.get(
|
130
|
+
data: _primitives.Name.get("DeviceRGB")
|
115
131
|
}]);
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
132
|
+
const res = new _primitives.Dict();
|
133
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
134
|
+
xref
|
135
|
+
});
|
136
|
+
|
137
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
138
|
+
|
139
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
140
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
141
|
+
const 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]);
|
122
142
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
123
143
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
|
124
144
|
expect(colorSpace.getOutputLength(4, 1)).toEqual(5);
|
@@ -126,37 +146,47 @@ describe('colorspace', function () {
|
|
126
146
|
expect(testDest).toEqual(expectedDest);
|
127
147
|
});
|
128
148
|
});
|
129
|
-
describe(
|
130
|
-
it(
|
131
|
-
|
132
|
-
|
133
|
-
|
149
|
+
describe("DeviceCmykCS", function () {
|
150
|
+
it("should handle the case when cs is a Name object", function () {
|
151
|
+
const cs = _primitives.Name.get("DeviceCMYK");
|
152
|
+
|
153
|
+
const xref = new _test_utils.XRefMock([{
|
154
|
+
ref: _primitives.Ref.get(10, 0),
|
134
155
|
data: new _primitives.Dict()
|
135
156
|
}]);
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
157
|
+
const res = new _primitives.Dict();
|
158
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
159
|
+
xref
|
160
|
+
});
|
161
|
+
|
162
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
163
|
+
|
164
|
+
const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
165
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
166
|
+
const 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]);
|
142
167
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
143
168
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
|
144
169
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(3);
|
145
170
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
146
171
|
expect(testDest).toEqual(expectedDest);
|
147
172
|
});
|
148
|
-
it(
|
149
|
-
|
150
|
-
|
173
|
+
it("should handle the case when cs is an indirect object", function () {
|
174
|
+
const cs = _primitives.Ref.get(10, 0);
|
175
|
+
|
176
|
+
const xref = new _test_utils.XRefMock([{
|
151
177
|
ref: cs,
|
152
|
-
data: _primitives.Name.get(
|
178
|
+
data: _primitives.Name.get("DeviceCMYK")
|
153
179
|
}]);
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
180
|
+
const res = new _primitives.Dict();
|
181
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
182
|
+
xref
|
183
|
+
});
|
184
|
+
|
185
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
186
|
+
|
187
|
+
const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
188
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
189
|
+
const 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]);
|
160
190
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
161
191
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
|
162
192
|
expect(colorSpace.getOutputLength(4, 1)).toEqual(4);
|
@@ -164,23 +194,27 @@ describe('colorspace', function () {
|
|
164
194
|
expect(testDest).toEqual(expectedDest);
|
165
195
|
});
|
166
196
|
});
|
167
|
-
describe(
|
168
|
-
it(
|
169
|
-
|
170
|
-
params.set(
|
171
|
-
params.set(
|
172
|
-
params.set(
|
173
|
-
|
174
|
-
|
175
|
-
ref:
|
197
|
+
describe("CalGrayCS", function () {
|
198
|
+
it("should handle the case when cs is an array", function () {
|
199
|
+
const params = new _primitives.Dict();
|
200
|
+
params.set("WhitePoint", [1, 1, 1]);
|
201
|
+
params.set("BlackPoint", [0, 0, 0]);
|
202
|
+
params.set("Gamma", 2.0);
|
203
|
+
const cs = [_primitives.Name.get("CalGray"), params];
|
204
|
+
const xref = new _test_utils.XRefMock([{
|
205
|
+
ref: _primitives.Ref.get(10, 0),
|
176
206
|
data: new _primitives.Dict()
|
177
207
|
}]);
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
208
|
+
const res = new _primitives.Dict();
|
209
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
210
|
+
xref
|
211
|
+
});
|
212
|
+
|
213
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
214
|
+
|
215
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
216
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
217
|
+
const 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]);
|
184
218
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
185
219
|
expect(colorSpace.getRgb(new Float32Array([1.0]), 0)).toEqual(new Uint8ClampedArray([255, 255, 255]));
|
186
220
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(12);
|
@@ -188,24 +222,28 @@ describe('colorspace', function () {
|
|
188
222
|
expect(testDest).toEqual(expectedDest);
|
189
223
|
});
|
190
224
|
});
|
191
|
-
describe(
|
192
|
-
it(
|
193
|
-
|
194
|
-
params.set(
|
195
|
-
params.set(
|
196
|
-
params.set(
|
197
|
-
params.set(
|
198
|
-
|
199
|
-
|
200
|
-
ref:
|
225
|
+
describe("CalRGBCS", function () {
|
226
|
+
it("should handle the case when cs is an array", function () {
|
227
|
+
const params = new _primitives.Dict();
|
228
|
+
params.set("WhitePoint", [1, 1, 1]);
|
229
|
+
params.set("BlackPoint", [0, 0, 0]);
|
230
|
+
params.set("Gamma", [1, 1, 1]);
|
231
|
+
params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
232
|
+
const cs = [_primitives.Name.get("CalRGB"), params];
|
233
|
+
const xref = new _test_utils.XRefMock([{
|
234
|
+
ref: _primitives.Ref.get(10, 0),
|
201
235
|
data: new _primitives.Dict()
|
202
236
|
}]);
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
237
|
+
const res = new _primitives.Dict();
|
238
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
239
|
+
xref
|
240
|
+
});
|
241
|
+
|
242
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
243
|
+
|
244
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
245
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
246
|
+
const 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]);
|
209
247
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
210
248
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([0, 147, 151]));
|
211
249
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
@@ -213,23 +251,27 @@ describe('colorspace', function () {
|
|
213
251
|
expect(testDest).toEqual(expectedDest);
|
214
252
|
});
|
215
253
|
});
|
216
|
-
describe(
|
217
|
-
it(
|
218
|
-
|
219
|
-
params.set(
|
220
|
-
params.set(
|
221
|
-
params.set(
|
222
|
-
|
223
|
-
|
224
|
-
ref:
|
254
|
+
describe("LabCS", function () {
|
255
|
+
it("should handle the case when cs is an array", function () {
|
256
|
+
const params = new _primitives.Dict();
|
257
|
+
params.set("WhitePoint", [1, 1, 1]);
|
258
|
+
params.set("BlackPoint", [0, 0, 0]);
|
259
|
+
params.set("Range", [-100, 100, -100, 100]);
|
260
|
+
const cs = [_primitives.Name.get("Lab"), params];
|
261
|
+
const xref = new _test_utils.XRefMock([{
|
262
|
+
ref: _primitives.Ref.get(10, 0),
|
225
263
|
data: new _primitives.Dict()
|
226
264
|
}]);
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
265
|
+
const res = new _primitives.Dict();
|
266
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
267
|
+
xref
|
268
|
+
});
|
269
|
+
|
270
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
271
|
+
|
272
|
+
const testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
|
273
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
274
|
+
const 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]);
|
233
275
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
234
276
|
expect(colorSpace.getRgb([55, 25, 35], 0)).toEqual(new Uint8ClampedArray([188, 100, 61]));
|
235
277
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
@@ -238,48 +280,58 @@ describe('colorspace', function () {
|
|
238
280
|
expect(testDest).toEqual(expectedDest);
|
239
281
|
});
|
240
282
|
});
|
241
|
-
describe(
|
242
|
-
it(
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
ref:
|
283
|
+
describe("IndexedCS", function () {
|
284
|
+
it("should handle the case when cs is an array", function () {
|
285
|
+
const lookup = new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]);
|
286
|
+
const cs = [_primitives.Name.get("Indexed"), _primitives.Name.get("DeviceRGB"), 2, lookup];
|
287
|
+
const xref = new _test_utils.XRefMock([{
|
288
|
+
ref: _primitives.Ref.get(10, 0),
|
247
289
|
data: new _primitives.Dict()
|
248
290
|
}]);
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
291
|
+
const res = new _primitives.Dict();
|
292
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
293
|
+
xref
|
294
|
+
});
|
295
|
+
|
296
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
297
|
+
|
298
|
+
const testSrc = new Uint8Array([2, 2, 0, 1]);
|
299
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
300
|
+
const 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
301
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
256
302
|
expect(colorSpace.getRgb([2], 0)).toEqual(new Uint8ClampedArray([255, 109, 70]));
|
257
303
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
258
|
-
expect(colorSpace.isDefaultDecode([0, 1])).toBeTruthy();
|
304
|
+
expect(colorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
|
259
305
|
expect(testDest).toEqual(expectedDest);
|
260
306
|
});
|
261
307
|
});
|
262
|
-
describe(
|
263
|
-
it(
|
264
|
-
|
265
|
-
fnDict.set(
|
266
|
-
fnDict.set(
|
267
|
-
fnDict.set(
|
268
|
-
fnDict.set(
|
269
|
-
|
308
|
+
describe("AlternateCS", function () {
|
309
|
+
it("should handle the case when cs is an array", function () {
|
310
|
+
const fnDict = new _primitives.Dict();
|
311
|
+
fnDict.set("FunctionType", 4);
|
312
|
+
fnDict.set("Domain", [0.0, 1.0]);
|
313
|
+
fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
|
314
|
+
fnDict.set("Length", 58);
|
315
|
+
let fn = new _stream.StringStream("{ dup 0.84 mul " + "exch 0.00 exch " + "dup 0.44 mul " + "exch 0.21 mul }");
|
270
316
|
fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
|
271
|
-
|
272
|
-
|
273
|
-
|
317
|
+
|
318
|
+
const fnRef = _primitives.Ref.get(10, 0);
|
319
|
+
|
320
|
+
const cs = [_primitives.Name.get("Separation"), _primitives.Name.get("LogoGreen"), _primitives.Name.get("DeviceCMYK"), fnRef];
|
321
|
+
const xref = new _test_utils.XRefMock([{
|
274
322
|
ref: fnRef,
|
275
323
|
data: fn
|
276
324
|
}]);
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
325
|
+
const res = new _primitives.Dict();
|
326
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
327
|
+
xref
|
328
|
+
});
|
329
|
+
|
330
|
+
const colorSpace = _colorspace.ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
|
331
|
+
|
332
|
+
const testSrc = new Uint8Array([27, 25, 50, 31]);
|
333
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
334
|
+
const 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]);
|
283
335
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
284
336
|
expect(colorSpace.getRgb([0.1], 0)).toEqual(new Uint8ClampedArray([228, 243, 242]));
|
285
337
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|