pdfjs-dist 2.2.228 → 2.6.347
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/README.md +4 -0
- package/bower.json +1 -1
- package/build/pdf.js +8816 -19300
- 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 +27185 -35746
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +22 -1
- package/es5/build/pdf.js +26665 -0
- package/es5/build/pdf.js.map +1 -0
- package/es5/build/pdf.min.js +22 -0
- package/{lib/shared/global_scope.js → es5/build/pdf.worker.entry.js} +5 -10
- package/es5/build/pdf.worker.js +61231 -0
- package/es5/build/pdf.worker.js.map +1 -0
- package/es5/build/pdf.worker.min.js +22 -0
- package/es5/image_decoders/pdf.image_decoders.js +12529 -0
- package/es5/image_decoders/pdf.image_decoders.js.map +1 -0
- package/es5/image_decoders/pdf.image_decoders.min.js +22 -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/pdf_viewer.css +406 -0
- package/es5/web/pdf_viewer.js +7886 -0
- package/es5/web/pdf_viewer.js.map +1 -0
- package/image_decoders/pdf.image_decoders.js +1498 -4832
- 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 +1144 -927
- package/lib/core/arithmetic_decoder.js +81 -97
- package/lib/core/bidi.js +54 -46
- package/lib/core/ccitt.js +88 -81
- package/lib/core/ccitt_stream.js +15 -14
- package/lib/core/cff_parser.js +747 -716
- package/lib/core/charsets.js +4 -4
- package/lib/core/chunked_stream.js +462 -553
- package/lib/core/cmap.js +231 -277
- package/lib/core/colorspace.js +715 -857
- package/lib/core/core_utils.js +57 -52
- package/lib/core/crypto.js +416 -437
- package/lib/core/document.js +629 -670
- package/lib/core/encodings.js +15 -15
- package/lib/core/evaluator.js +3229 -2800
- package/lib/core/font_renderer.js +135 -178
- package/lib/core/fonts.js +602 -534
- package/lib/core/function.js +355 -279
- package/lib/core/glyphlist.js +4527 -4526
- package/lib/core/image.js +442 -439
- package/lib/core/image_utils.js +221 -61
- package/lib/core/jbig2.js +325 -316
- package/lib/core/jbig2_stream.js +18 -17
- package/lib/core/jpeg_stream.js +21 -26
- package/lib/core/jpg.js +289 -233
- package/lib/core/jpx.js +161 -143
- package/lib/core/jpx_stream.js +28 -28
- package/lib/core/metrics.js +2928 -2928
- package/lib/core/murmurhash3.js +87 -102
- package/lib/core/obj.js +1343 -1300
- package/lib/core/operator_list.js +90 -67
- package/lib/core/parser.js +990 -987
- package/lib/core/pattern.js +105 -77
- package/lib/core/pdf_manager.js +149 -316
- package/lib/core/primitives.js +156 -104
- package/lib/core/ps_parser.js +175 -214
- package/lib/core/standard_fonts.js +237 -236
- package/lib/core/stream.js +94 -74
- package/lib/core/type1_parser.js +89 -69
- package/lib/core/unicode.js +1654 -1654
- package/lib/core/worker.js +275 -290
- package/lib/core/worker_stream.js +101 -210
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +772 -1041
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +1575 -1868
- package/lib/display/api_compatibility.js +12 -17
- package/lib/display/canvas.js +370 -222
- package/lib/display/content_disposition.js +40 -59
- package/lib/display/display_utils.js +341 -536
- package/lib/display/fetch_stream.js +188 -304
- package/lib/display/font_loader.js +282 -414
- package/lib/display/metadata.js +81 -99
- package/lib/display/network.js +362 -511
- package/lib/display/network_utils.js +25 -18
- package/lib/display/node_stream.js +283 -465
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/pattern_helper.js +93 -44
- package/lib/display/svg.js +1163 -1401
- package/lib/display/text_layer.js +154 -137
- package/lib/display/transport_stream.js +237 -375
- package/lib/display/webgl.js +70 -83
- package/lib/display/worker_options.js +3 -3
- package/lib/display/xml_parser.js +303 -392
- package/lib/examples/node/domstubs.js +37 -37
- package/lib/pdf.js +220 -58
- package/lib/pdf.worker.js +14 -6
- package/lib/shared/compatibility.js +3 -246
- package/lib/shared/is_node.js +7 -6
- package/lib/shared/message_handler.js +327 -332
- package/lib/shared/util.js +271 -306
- package/lib/test/unit/annotation_spec.js +1902 -763
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +790 -592
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +73 -72
- package/lib/test/unit/clitests_helper.js +7 -9
- package/lib/test/unit/cmap_spec.js +86 -88
- package/lib/test/unit/colorspace_spec.js +346 -154
- package/lib/test/unit/core_utils_spec.js +125 -105
- package/lib/test/unit/crypto_spec.js +232 -185
- package/lib/test/unit/custom_spec.js +150 -24
- package/lib/test/unit/display_svg_spec.js +34 -39
- package/lib/test/unit/display_utils_spec.js +139 -149
- package/lib/test/unit/document_spec.js +128 -17
- package/lib/test/unit/encodings_spec.js +12 -34
- package/lib/test/unit/evaluator_spec.js +112 -91
- package/lib/test/unit/fetch_stream_spec.js +31 -29
- package/lib/test/unit/function_spec.js +206 -204
- package/lib/test/unit/jasmine-boot.js +48 -32
- package/lib/test/unit/message_handler_spec.js +173 -159
- package/lib/test/unit/metadata_spec.js +71 -71
- package/lib/test/unit/murmurhash3_spec.js +12 -12
- package/lib/test/unit/network_spec.js +13 -11
- package/lib/test/unit/network_utils_spec.js +158 -144
- package/lib/test/unit/node_stream_spec.js +76 -90
- package/lib/test/unit/parser_spec.js +108 -114
- package/lib/test/unit/pdf_find_controller_spec.js +55 -86
- package/lib/test/unit/pdf_find_utils_spec.js +32 -32
- package/lib/test/unit/pdf_history_spec.js +32 -32
- package/lib/test/unit/primitives_spec.js +337 -156
- package/lib/test/unit/stream_spec.js +16 -14
- package/lib/test/unit/test_utils.js +91 -304
- package/lib/test/unit/testreporter.js +33 -22
- package/lib/test/unit/type1_parser_spec.js +42 -42
- package/lib/test/unit/ui_utils_spec.js +299 -461
- package/lib/test/unit/unicode_spec.js +42 -42
- package/lib/test/unit/util_spec.js +129 -149
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +78 -111
- package/lib/web/app.js +1542 -1267
- package/lib/web/app_options.js +76 -91
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +869 -834
- package/lib/web/chromecom.js +165 -252
- package/lib/web/debugger.js +149 -205
- package/lib/web/download_manager.js +34 -58
- package/lib/web/firefox_print_service.js +62 -34
- package/lib/web/firefoxcom.js +206 -374
- package/lib/web/genericcom.js +26 -108
- package/lib/web/genericl10n.js +24 -153
- package/lib/web/grab_to_pan.js +30 -30
- package/lib/web/interfaces.js +80 -254
- package/lib/web/overlay_manager.js +70 -246
- package/lib/web/password_prompt.js +38 -64
- package/lib/web/pdf_attachment_viewer.js +150 -126
- package/lib/web/pdf_cursor_tools.js +75 -102
- package/lib/web/pdf_document_properties.js +229 -383
- package/lib/web/pdf_find_bar.js +136 -170
- package/lib/web/pdf_find_controller.js +492 -548
- package/lib/web/pdf_find_utils.js +13 -13
- package/lib/web/pdf_history.js +397 -406
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_link_service.js +304 -348
- package/lib/web/pdf_outline_viewer.js +119 -212
- package/lib/web/pdf_page_view.js +474 -513
- package/lib/web/pdf_presentation_mode.js +308 -357
- package/lib/web/pdf_print_service.js +96 -110
- package/lib/web/pdf_rendering_queue.js +87 -108
- package/lib/web/pdf_sidebar.js +286 -302
- package/lib/web/pdf_sidebar_resizer.js +92 -119
- package/lib/web/pdf_single_page_viewer.js +77 -126
- package/lib/web/pdf_thumbnail_view.js +289 -297
- package/lib/web/pdf_thumbnail_viewer.js +202 -206
- package/lib/web/pdf_viewer.component.js +20 -21
- package/lib/web/pdf_viewer.js +55 -115
- package/lib/web/preferences.js +69 -273
- package/lib/web/secondary_toolbar.js +164 -196
- package/lib/web/text_layer_builder.js +284 -319
- package/lib/web/toolbar.js +217 -210
- package/lib/web/ui_utils.js +274 -421
- package/lib/web/view_history.js +52 -226
- package/lib/web/viewer_compatibility.js +21 -6
- package/package.json +4 -9
- package/types/display/annotation_layer.d.ts +61 -0
- package/types/display/annotation_storage.d.ts +36 -0
- package/types/display/api.d.ts +1107 -0
- package/types/display/api_compatibility.d.ts +1 -0
- package/types/display/canvas.d.ts +4 -0
- package/types/display/content_disposition.d.ts +7 -0
- package/types/display/display_utils.d.ts +243 -0
- package/types/display/fetch_stream.d.ts +67 -0
- package/types/display/font_loader.d.ts +19 -0
- package/types/display/metadata.d.ts +9 -0
- package/types/display/network.d.ts +80 -0
- package/types/display/network_utils.d.ts +14 -0
- package/types/display/node_stream.d.ts +72 -0
- package/types/display/node_utils.d.ts +6 -0
- package/types/display/optional_content_config.d.ts +12 -0
- package/types/display/pattern_helper.d.ts +5 -0
- package/types/display/svg.d.ts +2 -0
- package/types/display/text_layer.d.ts +83 -0
- package/types/display/transport_stream.d.ts +57 -0
- package/types/display/webgl.d.ts +20 -0
- package/types/display/worker_options.d.ts +27 -0
- package/types/display/xml_parser.d.ts +35 -0
- package/types/pdf.d.ts +33 -0
- package/types/shared/compatibility.d.ts +1 -0
- package/types/shared/is_node.d.ts +1 -0
- package/types/shared/message_handler.d.ts +62 -0
- package/types/shared/util.d.ts +421 -0
- package/web/images/shadow.png +0 -0
- package/web/pdf_viewer.css +29 -27
- package/web/pdf_viewer.js +3524 -4746
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +6 -5
- package/external/streams/streams-lib.js +0 -3962
- package/external/url/url-lib.js +0 -627
- package/lib/shared/streams_polyfill.js +0 -43
- package/lib/shared/url_polyfill.js +0 -56
- package/web/images/texture.png +0 -0
@@ -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.
|
@@ -21,26 +21,28 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var _primitives = require("../../core/primitives");
|
24
|
+
var _primitives = require("../../core/primitives.js");
|
25
25
|
|
26
|
-
var _stream = require("../../core/stream");
|
26
|
+
var _stream = require("../../core/stream.js");
|
27
27
|
|
28
|
-
var _colorspace = require("../../core/colorspace");
|
28
|
+
var _colorspace = require("../../core/colorspace.js");
|
29
29
|
|
30
|
-
var
|
30
|
+
var _image_utils = require("../../core/image_utils.js");
|
31
31
|
|
32
|
-
var
|
32
|
+
var _function = require("../../core/function.js");
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
var _test_utils = require("./test_utils.js");
|
35
|
+
|
36
|
+
describe("colorspace", function () {
|
37
|
+
describe("ColorSpace.isDefaultDecode", function () {
|
38
|
+
it("should be true if decode is not an array", function () {
|
39
|
+
expect(_colorspace.ColorSpace.isDefaultDecode("string", 0)).toBeTruthy();
|
38
40
|
});
|
39
|
-
it(
|
41
|
+
it("should be true if length of decode array is not correct", function () {
|
40
42
|
expect(_colorspace.ColorSpace.isDefaultDecode([0], 1)).toBeTruthy();
|
41
43
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 1, 0], 1)).toBeTruthy();
|
42
44
|
});
|
43
|
-
it(
|
45
|
+
it("should be true if decode map matches the default decode map", function () {
|
44
46
|
expect(_colorspace.ColorSpace.isDefaultDecode([], 0)).toBeTruthy();
|
45
47
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 0], 1)).toBeFalsy();
|
46
48
|
expect(_colorspace.ColorSpace.isDefaultDecode([0, 1], 1)).toBeTruthy();
|
@@ -50,47 +52,183 @@ describe('colorspace', function () {
|
|
50
52
|
expect(_colorspace.ColorSpace.isDefaultDecode([1, 0, 0, 1, 0, 1, 0, 1], 4)).toBeFalsy();
|
51
53
|
});
|
52
54
|
});
|
53
|
-
describe(
|
54
|
-
|
55
|
-
|
55
|
+
describe("ColorSpace caching", function () {
|
56
|
+
let localColorSpaceCache = null;
|
57
|
+
beforeAll(function (done) {
|
58
|
+
localColorSpaceCache = new _image_utils.LocalColorSpaceCache();
|
59
|
+
done();
|
60
|
+
});
|
61
|
+
afterAll(function (done) {
|
62
|
+
localColorSpaceCache = null;
|
63
|
+
done();
|
64
|
+
});
|
65
|
+
it("caching by Name", function () {
|
66
|
+
const xref = new _test_utils.XRefMock();
|
67
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
68
|
+
xref
|
69
|
+
});
|
70
|
+
|
71
|
+
const colorSpace1 = _colorspace.ColorSpace.parse({
|
72
|
+
cs: _primitives.Name.get("Pattern"),
|
73
|
+
xref,
|
74
|
+
resources: null,
|
75
|
+
pdfFunctionFactory,
|
76
|
+
localColorSpaceCache
|
77
|
+
});
|
78
|
+
|
79
|
+
expect(colorSpace1.name).toEqual("Pattern");
|
80
|
+
|
81
|
+
const colorSpace2 = _colorspace.ColorSpace.parse({
|
82
|
+
cs: _primitives.Name.get("Pattern"),
|
83
|
+
xref,
|
84
|
+
resources: null,
|
85
|
+
pdfFunctionFactory,
|
86
|
+
localColorSpaceCache
|
87
|
+
});
|
88
|
+
|
89
|
+
expect(colorSpace2.name).toEqual("Pattern");
|
90
|
+
|
91
|
+
const colorSpaceNonCached = _colorspace.ColorSpace.parse({
|
92
|
+
cs: _primitives.Name.get("Pattern"),
|
93
|
+
xref,
|
94
|
+
resources: null,
|
95
|
+
pdfFunctionFactory,
|
96
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
97
|
+
});
|
98
|
+
|
99
|
+
expect(colorSpaceNonCached.name).toEqual("Pattern");
|
100
|
+
|
101
|
+
const colorSpaceOther = _colorspace.ColorSpace.parse({
|
102
|
+
cs: _primitives.Name.get("RGB"),
|
103
|
+
xref,
|
104
|
+
resources: null,
|
105
|
+
pdfFunctionFactory,
|
106
|
+
localColorSpaceCache
|
107
|
+
});
|
108
|
+
|
109
|
+
expect(colorSpaceOther.name).toEqual("DeviceRGB");
|
110
|
+
expect(colorSpace1).toBe(colorSpace2);
|
111
|
+
expect(colorSpace1).not.toBe(colorSpaceNonCached);
|
112
|
+
expect(colorSpace1).not.toBe(colorSpaceOther);
|
113
|
+
});
|
114
|
+
it("caching by Ref", function () {
|
115
|
+
const paramsCalGray = new _primitives.Dict();
|
116
|
+
paramsCalGray.set("WhitePoint", [1, 1, 1]);
|
117
|
+
paramsCalGray.set("BlackPoint", [0, 0, 0]);
|
118
|
+
paramsCalGray.set("Gamma", 2.0);
|
119
|
+
const paramsCalRGB = new _primitives.Dict();
|
120
|
+
paramsCalRGB.set("WhitePoint", [1, 1, 1]);
|
121
|
+
paramsCalRGB.set("BlackPoint", [0, 0, 0]);
|
122
|
+
paramsCalRGB.set("Gamma", [1, 1, 1]);
|
123
|
+
paramsCalRGB.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
124
|
+
const xref = new _test_utils.XRefMock([{
|
125
|
+
ref: _primitives.Ref.get(50, 0),
|
126
|
+
data: [_primitives.Name.get("CalGray"), paramsCalGray]
|
127
|
+
}, {
|
128
|
+
ref: _primitives.Ref.get(100, 0),
|
129
|
+
data: [_primitives.Name.get("CalRGB"), paramsCalRGB]
|
130
|
+
}]);
|
131
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
132
|
+
xref
|
133
|
+
});
|
134
|
+
|
135
|
+
const colorSpace1 = _colorspace.ColorSpace.parse({
|
136
|
+
cs: _primitives.Ref.get(50, 0),
|
137
|
+
xref,
|
138
|
+
resources: null,
|
139
|
+
pdfFunctionFactory,
|
140
|
+
localColorSpaceCache
|
141
|
+
});
|
142
|
+
|
143
|
+
expect(colorSpace1.name).toEqual("CalGray");
|
144
|
+
|
145
|
+
const colorSpace2 = _colorspace.ColorSpace.parse({
|
146
|
+
cs: _primitives.Ref.get(50, 0),
|
147
|
+
xref,
|
148
|
+
resources: null,
|
149
|
+
pdfFunctionFactory,
|
150
|
+
localColorSpaceCache
|
151
|
+
});
|
152
|
+
|
153
|
+
expect(colorSpace2.name).toEqual("CalGray");
|
154
|
+
|
155
|
+
const colorSpaceNonCached = _colorspace.ColorSpace.parse({
|
156
|
+
cs: _primitives.Ref.get(50, 0),
|
157
|
+
xref,
|
158
|
+
resources: null,
|
159
|
+
pdfFunctionFactory,
|
160
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
161
|
+
});
|
162
|
+
|
163
|
+
expect(colorSpaceNonCached.name).toEqual("CalGray");
|
164
|
+
|
165
|
+
const colorSpaceOther = _colorspace.ColorSpace.parse({
|
166
|
+
cs: _primitives.Ref.get(100, 0),
|
167
|
+
xref,
|
168
|
+
resources: null,
|
169
|
+
pdfFunctionFactory,
|
170
|
+
localColorSpaceCache
|
171
|
+
});
|
172
|
+
|
173
|
+
expect(colorSpaceOther.name).toEqual("CalRGB");
|
174
|
+
expect(colorSpace1).toBe(colorSpace2);
|
175
|
+
expect(colorSpace1).not.toBe(colorSpaceNonCached);
|
176
|
+
expect(colorSpace1).not.toBe(colorSpaceOther);
|
177
|
+
});
|
178
|
+
});
|
179
|
+
describe("DeviceGrayCS", function () {
|
180
|
+
it("should handle the case when cs is a Name object", function () {
|
181
|
+
const cs = _primitives.Name.get("DeviceGray");
|
56
182
|
|
57
|
-
|
183
|
+
const xref = new _test_utils.XRefMock([{
|
58
184
|
ref: _primitives.Ref.get(10, 0),
|
59
185
|
data: new _primitives.Dict()
|
60
186
|
}]);
|
61
|
-
|
62
|
-
|
63
|
-
xref
|
187
|
+
const resources = new _primitives.Dict();
|
188
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
189
|
+
xref
|
64
190
|
});
|
65
191
|
|
66
|
-
|
192
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
193
|
+
cs,
|
194
|
+
xref,
|
195
|
+
resources,
|
196
|
+
pdfFunctionFactory,
|
197
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
198
|
+
});
|
67
199
|
|
68
|
-
|
69
|
-
|
70
|
-
|
200
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
201
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
202
|
+
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]);
|
71
203
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
72
204
|
expect(colorSpace.getRgb(new Float32Array([0.1]), 0)).toEqual(new Uint8ClampedArray([26, 26, 26]));
|
73
205
|
expect(colorSpace.getOutputLength(2, 0)).toEqual(6);
|
74
206
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
75
207
|
expect(testDest).toEqual(expectedDest);
|
76
208
|
});
|
77
|
-
it(
|
78
|
-
|
209
|
+
it("should handle the case when cs is an indirect object", function () {
|
210
|
+
const cs = _primitives.Ref.get(10, 0);
|
79
211
|
|
80
|
-
|
212
|
+
const xref = new _test_utils.XRefMock([{
|
81
213
|
ref: cs,
|
82
|
-
data: _primitives.Name.get(
|
214
|
+
data: _primitives.Name.get("DeviceGray")
|
83
215
|
}]);
|
84
|
-
|
85
|
-
|
86
|
-
xref
|
216
|
+
const resources = new _primitives.Dict();
|
217
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
218
|
+
xref
|
87
219
|
});
|
88
220
|
|
89
|
-
|
221
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
222
|
+
cs,
|
223
|
+
xref,
|
224
|
+
resources,
|
225
|
+
pdfFunctionFactory,
|
226
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
227
|
+
});
|
90
228
|
|
91
|
-
|
92
|
-
|
93
|
-
|
229
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
230
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
231
|
+
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]);
|
94
232
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
95
233
|
expect(colorSpace.getRgb(new Float32Array([0.2]), 0)).toEqual(new Uint8ClampedArray([51, 51, 51]));
|
96
234
|
expect(colorSpace.getOutputLength(3, 1)).toEqual(12);
|
@@ -98,47 +236,59 @@ describe('colorspace', function () {
|
|
98
236
|
expect(testDest).toEqual(expectedDest);
|
99
237
|
});
|
100
238
|
});
|
101
|
-
describe(
|
102
|
-
it(
|
103
|
-
|
239
|
+
describe("DeviceRgbCS", function () {
|
240
|
+
it("should handle the case when cs is a Name object", function () {
|
241
|
+
const cs = _primitives.Name.get("DeviceRGB");
|
104
242
|
|
105
|
-
|
243
|
+
const xref = new _test_utils.XRefMock([{
|
106
244
|
ref: _primitives.Ref.get(10, 0),
|
107
245
|
data: new _primitives.Dict()
|
108
246
|
}]);
|
109
|
-
|
110
|
-
|
111
|
-
xref
|
247
|
+
const resources = new _primitives.Dict();
|
248
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
249
|
+
xref
|
112
250
|
});
|
113
251
|
|
114
|
-
|
252
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
253
|
+
cs,
|
254
|
+
xref,
|
255
|
+
resources,
|
256
|
+
pdfFunctionFactory,
|
257
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
258
|
+
});
|
115
259
|
|
116
|
-
|
117
|
-
|
118
|
-
|
260
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
261
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
262
|
+
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]);
|
119
263
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
120
264
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
|
121
265
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
122
266
|
expect(colorSpace.isPassthrough(8)).toBeTruthy();
|
123
267
|
expect(testDest).toEqual(expectedDest);
|
124
268
|
});
|
125
|
-
it(
|
126
|
-
|
269
|
+
it("should handle the case when cs is an indirect object", function () {
|
270
|
+
const cs = _primitives.Ref.get(10, 0);
|
127
271
|
|
128
|
-
|
272
|
+
const xref = new _test_utils.XRefMock([{
|
129
273
|
ref: cs,
|
130
|
-
data: _primitives.Name.get(
|
274
|
+
data: _primitives.Name.get("DeviceRGB")
|
131
275
|
}]);
|
132
|
-
|
133
|
-
|
134
|
-
xref
|
276
|
+
const resources = new _primitives.Dict();
|
277
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
278
|
+
xref
|
135
279
|
});
|
136
280
|
|
137
|
-
|
281
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
282
|
+
cs,
|
283
|
+
xref,
|
284
|
+
resources,
|
285
|
+
pdfFunctionFactory,
|
286
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
287
|
+
});
|
138
288
|
|
139
|
-
|
140
|
-
|
141
|
-
|
289
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
290
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
291
|
+
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]);
|
142
292
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
143
293
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([26, 51, 77]));
|
144
294
|
expect(colorSpace.getOutputLength(4, 1)).toEqual(5);
|
@@ -146,47 +296,59 @@ describe('colorspace', function () {
|
|
146
296
|
expect(testDest).toEqual(expectedDest);
|
147
297
|
});
|
148
298
|
});
|
149
|
-
describe(
|
150
|
-
it(
|
151
|
-
|
299
|
+
describe("DeviceCmykCS", function () {
|
300
|
+
it("should handle the case when cs is a Name object", function () {
|
301
|
+
const cs = _primitives.Name.get("DeviceCMYK");
|
152
302
|
|
153
|
-
|
303
|
+
const xref = new _test_utils.XRefMock([{
|
154
304
|
ref: _primitives.Ref.get(10, 0),
|
155
305
|
data: new _primitives.Dict()
|
156
306
|
}]);
|
157
|
-
|
158
|
-
|
159
|
-
xref
|
307
|
+
const resources = new _primitives.Dict();
|
308
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
309
|
+
xref
|
160
310
|
});
|
161
311
|
|
162
|
-
|
312
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
313
|
+
cs,
|
314
|
+
xref,
|
315
|
+
resources,
|
316
|
+
pdfFunctionFactory,
|
317
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
318
|
+
});
|
163
319
|
|
164
|
-
|
165
|
-
|
166
|
-
|
320
|
+
const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
321
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
322
|
+
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]);
|
167
323
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
168
324
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
|
169
325
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(3);
|
170
326
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
171
327
|
expect(testDest).toEqual(expectedDest);
|
172
328
|
});
|
173
|
-
it(
|
174
|
-
|
329
|
+
it("should handle the case when cs is an indirect object", function () {
|
330
|
+
const cs = _primitives.Ref.get(10, 0);
|
175
331
|
|
176
|
-
|
332
|
+
const xref = new _test_utils.XRefMock([{
|
177
333
|
ref: cs,
|
178
|
-
data: _primitives.Name.get(
|
334
|
+
data: _primitives.Name.get("DeviceCMYK")
|
179
335
|
}]);
|
180
|
-
|
181
|
-
|
182
|
-
xref
|
336
|
+
const resources = new _primitives.Dict();
|
337
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
338
|
+
xref
|
183
339
|
});
|
184
340
|
|
185
|
-
|
341
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
342
|
+
cs,
|
343
|
+
xref,
|
344
|
+
resources,
|
345
|
+
pdfFunctionFactory,
|
346
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
347
|
+
});
|
186
348
|
|
187
|
-
|
188
|
-
|
189
|
-
|
349
|
+
const testSrc = new Uint8Array([27, 125, 250, 128, 131, 139, 140, 45, 111, 25, 198, 78, 21, 147, 255, 69]);
|
350
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
351
|
+
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]);
|
190
352
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
191
353
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3, 1]), 0)).toEqual(new Uint8ClampedArray([32, 28, 21]));
|
192
354
|
expect(colorSpace.getOutputLength(4, 1)).toEqual(4);
|
@@ -194,27 +356,33 @@ describe('colorspace', function () {
|
|
194
356
|
expect(testDest).toEqual(expectedDest);
|
195
357
|
});
|
196
358
|
});
|
197
|
-
describe(
|
198
|
-
it(
|
199
|
-
|
200
|
-
params.set(
|
201
|
-
params.set(
|
202
|
-
params.set(
|
203
|
-
|
204
|
-
|
359
|
+
describe("CalGrayCS", function () {
|
360
|
+
it("should handle the case when cs is an array", function () {
|
361
|
+
const params = new _primitives.Dict();
|
362
|
+
params.set("WhitePoint", [1, 1, 1]);
|
363
|
+
params.set("BlackPoint", [0, 0, 0]);
|
364
|
+
params.set("Gamma", 2.0);
|
365
|
+
const cs = [_primitives.Name.get("CalGray"), params];
|
366
|
+
const xref = new _test_utils.XRefMock([{
|
205
367
|
ref: _primitives.Ref.get(10, 0),
|
206
368
|
data: new _primitives.Dict()
|
207
369
|
}]);
|
208
|
-
|
209
|
-
|
210
|
-
xref
|
370
|
+
const resources = new _primitives.Dict();
|
371
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
372
|
+
xref
|
211
373
|
});
|
212
374
|
|
213
|
-
|
375
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
376
|
+
cs,
|
377
|
+
xref,
|
378
|
+
resources,
|
379
|
+
pdfFunctionFactory,
|
380
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
381
|
+
});
|
214
382
|
|
215
|
-
|
216
|
-
|
217
|
-
|
383
|
+
const testSrc = new Uint8Array([27, 125, 250, 131]);
|
384
|
+
const testDest = new Uint8ClampedArray(4 * 4 * 3);
|
385
|
+
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]);
|
218
386
|
colorSpace.fillRgb(testDest, 2, 2, 4, 4, 4, 8, testSrc, 0);
|
219
387
|
expect(colorSpace.getRgb(new Float32Array([1.0]), 0)).toEqual(new Uint8ClampedArray([255, 255, 255]));
|
220
388
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(12);
|
@@ -222,28 +390,34 @@ describe('colorspace', function () {
|
|
222
390
|
expect(testDest).toEqual(expectedDest);
|
223
391
|
});
|
224
392
|
});
|
225
|
-
describe(
|
226
|
-
it(
|
227
|
-
|
228
|
-
params.set(
|
229
|
-
params.set(
|
230
|
-
params.set(
|
231
|
-
params.set(
|
232
|
-
|
233
|
-
|
393
|
+
describe("CalRGBCS", function () {
|
394
|
+
it("should handle the case when cs is an array", function () {
|
395
|
+
const params = new _primitives.Dict();
|
396
|
+
params.set("WhitePoint", [1, 1, 1]);
|
397
|
+
params.set("BlackPoint", [0, 0, 0]);
|
398
|
+
params.set("Gamma", [1, 1, 1]);
|
399
|
+
params.set("Matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
400
|
+
const cs = [_primitives.Name.get("CalRGB"), params];
|
401
|
+
const xref = new _test_utils.XRefMock([{
|
234
402
|
ref: _primitives.Ref.get(10, 0),
|
235
403
|
data: new _primitives.Dict()
|
236
404
|
}]);
|
237
|
-
|
238
|
-
|
239
|
-
xref
|
405
|
+
const resources = new _primitives.Dict();
|
406
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
407
|
+
xref
|
240
408
|
});
|
241
409
|
|
242
|
-
|
410
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
411
|
+
cs,
|
412
|
+
xref,
|
413
|
+
resources,
|
414
|
+
pdfFunctionFactory,
|
415
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
416
|
+
});
|
243
417
|
|
244
|
-
|
245
|
-
|
246
|
-
|
418
|
+
const testSrc = new Uint8Array([27, 125, 250, 131, 139, 140, 111, 25, 198, 21, 147, 255]);
|
419
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
420
|
+
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]);
|
247
421
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
248
422
|
expect(colorSpace.getRgb(new Float32Array([0.1, 0.2, 0.3]), 0)).toEqual(new Uint8ClampedArray([0, 147, 151]));
|
249
423
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
@@ -251,27 +425,33 @@ describe('colorspace', function () {
|
|
251
425
|
expect(testDest).toEqual(expectedDest);
|
252
426
|
});
|
253
427
|
});
|
254
|
-
describe(
|
255
|
-
it(
|
256
|
-
|
257
|
-
params.set(
|
258
|
-
params.set(
|
259
|
-
params.set(
|
260
|
-
|
261
|
-
|
428
|
+
describe("LabCS", function () {
|
429
|
+
it("should handle the case when cs is an array", function () {
|
430
|
+
const params = new _primitives.Dict();
|
431
|
+
params.set("WhitePoint", [1, 1, 1]);
|
432
|
+
params.set("BlackPoint", [0, 0, 0]);
|
433
|
+
params.set("Range", [-100, 100, -100, 100]);
|
434
|
+
const cs = [_primitives.Name.get("Lab"), params];
|
435
|
+
const xref = new _test_utils.XRefMock([{
|
262
436
|
ref: _primitives.Ref.get(10, 0),
|
263
437
|
data: new _primitives.Dict()
|
264
438
|
}]);
|
265
|
-
|
266
|
-
|
267
|
-
xref
|
439
|
+
const resources = new _primitives.Dict();
|
440
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
441
|
+
xref
|
268
442
|
});
|
269
443
|
|
270
|
-
|
444
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
445
|
+
cs,
|
446
|
+
xref,
|
447
|
+
resources,
|
448
|
+
pdfFunctionFactory,
|
449
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
450
|
+
});
|
271
451
|
|
272
|
-
|
273
|
-
|
274
|
-
|
452
|
+
const testSrc = new Uint8Array([27, 25, 50, 31, 19, 40, 11, 25, 98, 21, 47, 55]);
|
453
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
454
|
+
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]);
|
275
455
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
276
456
|
expect(colorSpace.getRgb([55, 25, 35], 0)).toEqual(new Uint8ClampedArray([188, 100, 61]));
|
277
457
|
expect(colorSpace.getOutputLength(4, 0)).toEqual(4);
|
@@ -280,24 +460,30 @@ describe('colorspace', function () {
|
|
280
460
|
expect(testDest).toEqual(expectedDest);
|
281
461
|
});
|
282
462
|
});
|
283
|
-
describe(
|
284
|
-
it(
|
285
|
-
|
286
|
-
|
287
|
-
|
463
|
+
describe("IndexedCS", function () {
|
464
|
+
it("should handle the case when cs is an array", function () {
|
465
|
+
const lookup = new _stream.Stream(new Uint8Array([23, 155, 35, 147, 69, 93, 255, 109, 70]));
|
466
|
+
const cs = [_primitives.Name.get("Indexed"), _primitives.Name.get("DeviceRGB"), 2, lookup];
|
467
|
+
const xref = new _test_utils.XRefMock([{
|
288
468
|
ref: _primitives.Ref.get(10, 0),
|
289
469
|
data: new _primitives.Dict()
|
290
470
|
}]);
|
291
|
-
|
292
|
-
|
293
|
-
xref
|
471
|
+
const resources = new _primitives.Dict();
|
472
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
473
|
+
xref
|
294
474
|
});
|
295
475
|
|
296
|
-
|
476
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
477
|
+
cs,
|
478
|
+
xref,
|
479
|
+
resources,
|
480
|
+
pdfFunctionFactory,
|
481
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
482
|
+
});
|
297
483
|
|
298
|
-
|
299
|
-
|
300
|
-
|
484
|
+
const testSrc = new Uint8Array([2, 2, 0, 1]);
|
485
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
486
|
+
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]);
|
301
487
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
302
488
|
expect(colorSpace.getRgb([2], 0)).toEqual(new Uint8ClampedArray([255, 109, 70]));
|
303
489
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|
@@ -305,33 +491,39 @@ describe('colorspace', function () {
|
|
305
491
|
expect(testDest).toEqual(expectedDest);
|
306
492
|
});
|
307
493
|
});
|
308
|
-
describe(
|
309
|
-
it(
|
310
|
-
|
311
|
-
fnDict.set(
|
312
|
-
fnDict.set(
|
313
|
-
fnDict.set(
|
314
|
-
fnDict.set(
|
315
|
-
|
494
|
+
describe("AlternateCS", function () {
|
495
|
+
it("should handle the case when cs is an array", function () {
|
496
|
+
const fnDict = new _primitives.Dict();
|
497
|
+
fnDict.set("FunctionType", 4);
|
498
|
+
fnDict.set("Domain", [0.0, 1.0]);
|
499
|
+
fnDict.set("Range", [0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0]);
|
500
|
+
fnDict.set("Length", 58);
|
501
|
+
let fn = new _stream.StringStream("{ dup 0.84 mul " + "exch 0.00 exch " + "dup 0.44 mul " + "exch 0.21 mul }");
|
316
502
|
fn = new _stream.Stream(fn.bytes, 0, 58, fnDict);
|
317
503
|
|
318
|
-
|
504
|
+
const fnRef = _primitives.Ref.get(10, 0);
|
319
505
|
|
320
|
-
|
321
|
-
|
506
|
+
const cs = [_primitives.Name.get("Separation"), _primitives.Name.get("LogoGreen"), _primitives.Name.get("DeviceCMYK"), fnRef];
|
507
|
+
const xref = new _test_utils.XRefMock([{
|
322
508
|
ref: fnRef,
|
323
509
|
data: fn
|
324
510
|
}]);
|
325
|
-
|
326
|
-
|
327
|
-
xref
|
511
|
+
const resources = new _primitives.Dict();
|
512
|
+
const pdfFunctionFactory = new _function.PDFFunctionFactory({
|
513
|
+
xref
|
328
514
|
});
|
329
515
|
|
330
|
-
|
516
|
+
const colorSpace = _colorspace.ColorSpace.parse({
|
517
|
+
cs,
|
518
|
+
xref,
|
519
|
+
resources,
|
520
|
+
pdfFunctionFactory,
|
521
|
+
localColorSpaceCache: new _image_utils.LocalColorSpaceCache()
|
522
|
+
});
|
331
523
|
|
332
|
-
|
333
|
-
|
334
|
-
|
524
|
+
const testSrc = new Uint8Array([27, 25, 50, 31]);
|
525
|
+
const testDest = new Uint8ClampedArray(3 * 3 * 3);
|
526
|
+
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]);
|
335
527
|
colorSpace.fillRgb(testDest, 2, 2, 3, 3, 3, 8, testSrc, 0);
|
336
528
|
expect(colorSpace.getRgb([0.1], 0)).toEqual(new Uint8ClampedArray([228, 243, 242]));
|
337
529
|
expect(colorSpace.isPassthrough(8)).toBeFalsy();
|