pdfjs-dist 2.5.207 → 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/bower.json +1 -1
- package/build/pdf.js +867 -216
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +10214 -8547
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +2023 -1046
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.min.js +22 -0
- package/es5/build/pdf.worker.js +11136 -8144
- package/es5/build/pdf.worker.js.map +1 -1
- 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/shadow.png +0 -0
- package/es5/web/pdf_viewer.css +8 -5
- package/es5/web/pdf_viewer.js +195 -51
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +24 -16
- 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 +479 -43
- package/lib/core/cff_parser.js +643 -615
- package/lib/core/chunked_stream.js +64 -50
- package/lib/core/colorspace.js +126 -104
- package/lib/core/crypto.js +37 -0
- package/lib/core/document.js +128 -75
- package/lib/core/evaluator.js +3015 -2754
- package/lib/core/fonts.js +47 -46
- package/lib/core/function.js +79 -6
- package/lib/core/image.js +364 -357
- package/lib/core/image_utils.js +109 -8
- package/lib/core/jpg.js +8 -3
- package/lib/core/obj.js +255 -34
- package/lib/core/operator_list.js +17 -15
- package/lib/core/parser.js +40 -3
- package/lib/core/pattern.js +24 -11
- package/lib/core/primitives.js +112 -53
- package/lib/core/type1_parser.js +2 -0
- package/lib/core/worker.js +102 -37
- package/lib/core/writer.js +242 -0
- package/lib/display/annotation_layer.js +51 -10
- package/lib/display/annotation_storage.js +89 -0
- package/lib/display/api.js +140 -54
- package/lib/display/canvas.js +215 -46
- package/lib/display/display_utils.js +55 -18
- package/lib/display/fetch_stream.js +6 -0
- package/lib/display/font_loader.js +26 -15
- package/lib/display/metadata.js +1 -7
- package/lib/display/network.js +0 -14
- package/lib/display/node_utils.js +87 -0
- package/lib/display/optional_content_config.js +184 -0
- package/lib/display/svg.js +1 -1
- package/lib/display/text_layer.js +4 -1
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/util.js +13 -10
- package/lib/test/unit/annotation_spec.js +520 -50
- package/lib/test/unit/annotation_storage_spec.js +83 -0
- package/lib/test/unit/api_spec.js +16 -6
- package/lib/test/unit/cmap_spec.js +4 -4
- package/lib/test/unit/colorspace_spec.js +216 -24
- package/lib/test/unit/crypto_spec.js +51 -4
- package/lib/test/unit/custom_spec.js +129 -1
- package/lib/test/unit/document_spec.js +112 -1
- package/lib/test/unit/evaluator_spec.js +29 -10
- package/lib/test/unit/jasmine-boot.js +1 -1
- package/lib/test/unit/metadata_spec.js +3 -3
- package/lib/test/unit/primitives_spec.js +242 -63
- package/lib/test/unit/test_utils.js +42 -89
- package/lib/test/unit/testreporter.js +17 -6
- package/lib/test/unit/util_spec.js +13 -12
- package/lib/test/unit/writer_spec.js +84 -0
- package/lib/web/annotation_layer_builder.js +13 -9
- package/lib/web/app.js +231 -26
- package/lib/web/app_options.js +1 -6
- package/lib/web/base_tree_viewer.js +100 -0
- package/lib/web/base_viewer.js +53 -4
- package/lib/web/download_manager.js +3 -10
- package/lib/web/firefox_print_service.js +32 -12
- package/lib/web/firefoxcom.js +20 -6
- package/lib/web/interfaces.js +1 -1
- package/lib/web/pdf_attachment_viewer.js +80 -38
- package/lib/web/pdf_find_controller.js +2 -1
- package/lib/web/pdf_layer_viewer.js +208 -0
- package/lib/web/pdf_outline_viewer.js +24 -57
- package/lib/web/pdf_page_view.js +29 -6
- package/lib/web/pdf_print_service.js +13 -11
- package/lib/web/pdf_sidebar.js +46 -25
- package/lib/web/pdf_thumbnail_view.js +16 -3
- package/lib/web/pdf_thumbnail_viewer.js +17 -1
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/preferences.js +1 -1
- package/lib/web/toolbar.js +1 -1
- package/lib/web/ui_utils.js +7 -1
- package/package.json +3 -1
- 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 +8 -5
- package/web/pdf_viewer.js +109 -33
- package/web/pdf_viewer.js.map +1 -1
- package/webpack.js +1 -9
- package/es5/web/images/texture.png +0 -0
- package/web/images/texture.png +0 -0
@@ -72,10 +72,22 @@ var TestReporter = function (browser) {
|
|
72
72
|
|
73
73
|
this.jasmineStarted = function (suiteInfo) {
|
74
74
|
this.runnerStartTime = this.now();
|
75
|
-
|
75
|
+
const total = suiteInfo.totalSpecsDefined;
|
76
|
+
const seed = suiteInfo.order.seed;
|
77
|
+
sendInfo(`Started ${total} tests for ${browser} with seed ${seed}.`);
|
76
78
|
};
|
77
79
|
|
78
|
-
this.suiteStarted = function (result) {
|
80
|
+
this.suiteStarted = function (result) {
|
81
|
+
if (result.failedExpectations.length > 0) {
|
82
|
+
let failedMessages = "";
|
83
|
+
|
84
|
+
for (const item of result.failedExpectations) {
|
85
|
+
failedMessages += `${item.message} `;
|
86
|
+
}
|
87
|
+
|
88
|
+
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
89
|
+
}
|
90
|
+
};
|
79
91
|
|
80
92
|
this.specStarted = function (result) {};
|
81
93
|
|
@@ -83,11 +95,10 @@ var TestReporter = function (browser) {
|
|
83
95
|
if (result.failedExpectations.length === 0) {
|
84
96
|
sendResult("TEST-PASSED", result.description);
|
85
97
|
} else {
|
86
|
-
|
87
|
-
var items = result.failedExpectations;
|
98
|
+
let failedMessages = "";
|
88
99
|
|
89
|
-
for (
|
90
|
-
failedMessages +=
|
100
|
+
for (const item of result.failedExpectations) {
|
101
|
+
failedMessages += `${item.message} `;
|
91
102
|
}
|
92
103
|
|
93
104
|
sendResult("TEST-UNEXPECTED-FAIL", result.description, failedMessages);
|
@@ -72,16 +72,6 @@ describe("util", function () {
|
|
72
72
|
expect((0, _util.isBool)(undefined)).toEqual(false);
|
73
73
|
});
|
74
74
|
});
|
75
|
-
describe("isEmptyObj", function () {
|
76
|
-
it("handles empty objects", function () {
|
77
|
-
expect((0, _util.isEmptyObj)({})).toEqual(true);
|
78
|
-
});
|
79
|
-
it("handles non-empty objects", function () {
|
80
|
-
expect((0, _util.isEmptyObj)({
|
81
|
-
foo: "bar"
|
82
|
-
})).toEqual(false);
|
83
|
-
});
|
84
|
-
});
|
85
75
|
describe("isNum", function () {
|
86
76
|
it("handles numeric values", function () {
|
87
77
|
expect((0, _util.isNum)(1)).toEqual(true);
|
@@ -195,10 +185,10 @@ describe("util", function () {
|
|
195
185
|
expect((0, _util.createValidAbsoluteUrl)(null, null)).toEqual(null);
|
196
186
|
expect((0, _util.createValidAbsoluteUrl)("/foo", "/bar")).toEqual(null);
|
197
187
|
});
|
198
|
-
it("handles URLs that do not use
|
188
|
+
it("handles URLs that do not use an allowed protocol", function () {
|
199
189
|
expect((0, _util.createValidAbsoluteUrl)("magnet:?foo", null)).toEqual(null);
|
200
190
|
});
|
201
|
-
it("correctly creates a valid URL for
|
191
|
+
it("correctly creates a valid URL for allowed protocols", function () {
|
202
192
|
expect((0, _util.createValidAbsoluteUrl)("http://www.mozilla.org/foo", null)).toEqual(new URL("http://www.mozilla.org/foo"));
|
203
193
|
expect((0, _util.createValidAbsoluteUrl)("/foo", "http://www.mozilla.org")).toEqual(new URL("http://www.mozilla.org/foo"));
|
204
194
|
expect((0, _util.createValidAbsoluteUrl)("https://www.mozilla.org/foo", null)).toEqual(new URL("https://www.mozilla.org/foo"));
|
@@ -238,4 +228,15 @@ describe("util", function () {
|
|
238
228
|
});
|
239
229
|
});
|
240
230
|
});
|
231
|
+
describe("escapeString", function () {
|
232
|
+
it("should escape (, ) and \\", function () {
|
233
|
+
expect((0, _util.escapeString)("((a\\a))(b(b\\b)b)")).toEqual("\\(\\(a\\\\a\\)\\)\\(b\\(b\\\\b\\)b\\)");
|
234
|
+
});
|
235
|
+
});
|
236
|
+
describe("getModificationDate", function () {
|
237
|
+
it("should get a correctly formatted date", function () {
|
238
|
+
const date = new Date(Date.UTC(3141, 5, 9, 2, 6, 53));
|
239
|
+
expect((0, _util.getModificationDate)(date)).toEqual("31410610020653");
|
240
|
+
});
|
241
|
+
});
|
241
242
|
});
|
@@ -0,0 +1,84 @@
|
|
1
|
+
/**
|
2
|
+
* @licstart The following is the entire license notice for the
|
3
|
+
* Javascript code in this page
|
4
|
+
*
|
5
|
+
* Copyright 2020 Mozilla Foundation
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
*
|
19
|
+
* @licend The above is the entire license notice for the
|
20
|
+
* Javascript code in this page
|
21
|
+
*/
|
22
|
+
"use strict";
|
23
|
+
|
24
|
+
var _primitives = require("../../core/primitives.js");
|
25
|
+
|
26
|
+
var _writer = require("../../core/writer.js");
|
27
|
+
|
28
|
+
var _util = require("../../shared/util.js");
|
29
|
+
|
30
|
+
var _stream = require("../../core/stream.js");
|
31
|
+
|
32
|
+
describe("Writer", function () {
|
33
|
+
describe("Incremental update", function () {
|
34
|
+
it("should update a file with new objects", function (done) {
|
35
|
+
const originalData = new Uint8Array();
|
36
|
+
const newRefs = [{
|
37
|
+
ref: _primitives.Ref.get(123, 0x2d),
|
38
|
+
data: "abc\n"
|
39
|
+
}, {
|
40
|
+
ref: _primitives.Ref.get(456, 0x4e),
|
41
|
+
data: "defg\n"
|
42
|
+
}];
|
43
|
+
const xrefInfo = {
|
44
|
+
newRef: _primitives.Ref.get(789, 0),
|
45
|
+
startXRef: 314,
|
46
|
+
fileIds: ["id", ""],
|
47
|
+
rootRef: null,
|
48
|
+
infoRef: null,
|
49
|
+
encrypt: null,
|
50
|
+
filename: "foo.pdf",
|
51
|
+
info: {}
|
52
|
+
};
|
53
|
+
let data = (0, _writer.incrementalUpdate)(originalData, xrefInfo, newRefs);
|
54
|
+
data = (0, _util.bytesToString)(data);
|
55
|
+
const expected = "\nabc\n" + "defg\n" + "789 0 obj\n" + "<< /Size 790 /Prev 314 /Type /XRef /Index [0 1 123 1 456 1 789 1] " + "/ID [(id) (\x01#Eg\x89\xab\xcd\xef\xfe\xdc\xba\x98vT2\x10)] " + "/W [1 1 2] /Length 16>> stream\n" + "\x00\x01\xff\xff" + "\x01\x01\x00\x2d" + "\x01\x05\x00\x4e" + "\x01\x0a\x00\x00\n" + "endstream\n" + "endobj\n" + "startxref\n" + "10\n" + "%%EOF\n";
|
56
|
+
expect(data).toEqual(expected);
|
57
|
+
done();
|
58
|
+
});
|
59
|
+
});
|
60
|
+
describe("writeDict", function () {
|
61
|
+
it("should write a Dict", function (done) {
|
62
|
+
const dict = new _primitives.Dict(null);
|
63
|
+
dict.set("A", _primitives.Name.get("B"));
|
64
|
+
dict.set("B", _primitives.Ref.get(123, 456));
|
65
|
+
dict.set("C", 789);
|
66
|
+
dict.set("D", "hello world");
|
67
|
+
dict.set("E", "(hello\\world)");
|
68
|
+
dict.set("F", [1.23001, 4.50001, 6]);
|
69
|
+
const gdict = new _primitives.Dict(null);
|
70
|
+
gdict.set("H", 123.00001);
|
71
|
+
const string = "a stream";
|
72
|
+
const stream = new _stream.StringStream(string);
|
73
|
+
stream.dict = new _primitives.Dict(null);
|
74
|
+
stream.dict.set("Length", string.length);
|
75
|
+
gdict.set("I", stream);
|
76
|
+
dict.set("G", gdict);
|
77
|
+
const buffer = [];
|
78
|
+
(0, _writer.writeDict)(dict, buffer, null);
|
79
|
+
const expected = "<< /A /B /B 123 456 R /C 789 /D (hello world) " + "/E (\\(hello\\\\world\\)) /F [1.23 4.5 6] " + "/G << /H 123 /I << /Length 8>> stream\n" + "a stream\n" + "endstream\n>>>>";
|
80
|
+
expect(buffer.join("")).toEqual(expected);
|
81
|
+
done();
|
82
|
+
});
|
83
|
+
});
|
84
|
+
});
|
@@ -38,8 +38,9 @@ class AnnotationLayerBuilder {
|
|
38
38
|
pdfPage,
|
39
39
|
linkService,
|
40
40
|
downloadManager,
|
41
|
+
annotationStorage = null,
|
41
42
|
imageResourcesPath = "",
|
42
|
-
renderInteractiveForms =
|
43
|
+
renderInteractiveForms = true,
|
43
44
|
l10n = _ui_utils.NullL10n
|
44
45
|
}) {
|
45
46
|
this.pageDiv = pageDiv;
|
@@ -49,18 +50,23 @@ class AnnotationLayerBuilder {
|
|
49
50
|
this.imageResourcesPath = imageResourcesPath;
|
50
51
|
this.renderInteractiveForms = renderInteractiveForms;
|
51
52
|
this.l10n = l10n;
|
53
|
+
this.annotationStorage = annotationStorage;
|
52
54
|
this.div = null;
|
53
55
|
this._cancelled = false;
|
54
56
|
}
|
55
57
|
|
56
58
|
render(viewport, intent = "display") {
|
57
|
-
this.pdfPage.getAnnotations({
|
59
|
+
return this.pdfPage.getAnnotations({
|
58
60
|
intent
|
59
61
|
}).then(annotations => {
|
60
62
|
if (this._cancelled) {
|
61
63
|
return;
|
62
64
|
}
|
63
65
|
|
66
|
+
if (annotations.length === 0) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
|
64
70
|
const parameters = {
|
65
71
|
viewport: viewport.clone({
|
66
72
|
dontFlip: true
|
@@ -71,16 +77,13 @@ class AnnotationLayerBuilder {
|
|
71
77
|
imageResourcesPath: this.imageResourcesPath,
|
72
78
|
renderInteractiveForms: this.renderInteractiveForms,
|
73
79
|
linkService: this.linkService,
|
74
|
-
downloadManager: this.downloadManager
|
80
|
+
downloadManager: this.downloadManager,
|
81
|
+
annotationStorage: this.annotationStorage
|
75
82
|
};
|
76
83
|
|
77
84
|
if (this.div) {
|
78
85
|
_pdf.AnnotationLayer.update(parameters);
|
79
86
|
} else {
|
80
|
-
if (annotations.length === 0) {
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
|
84
87
|
this.div = document.createElement("div");
|
85
88
|
this.div.className = "annotationLayer";
|
86
89
|
this.pageDiv.appendChild(this.div);
|
@@ -110,14 +113,15 @@ class AnnotationLayerBuilder {
|
|
110
113
|
exports.AnnotationLayerBuilder = AnnotationLayerBuilder;
|
111
114
|
|
112
115
|
class DefaultAnnotationLayerFactory {
|
113
|
-
createAnnotationLayerBuilder(pageDiv, pdfPage, imageResourcesPath = "", renderInteractiveForms =
|
116
|
+
createAnnotationLayerBuilder(pageDiv, pdfPage, annotationStorage = null, imageResourcesPath = "", renderInteractiveForms = true, l10n = _ui_utils.NullL10n) {
|
114
117
|
return new AnnotationLayerBuilder({
|
115
118
|
pageDiv,
|
116
119
|
pdfPage,
|
117
120
|
imageResourcesPath,
|
118
121
|
renderInteractiveForms,
|
119
122
|
linkService: new _pdf_link_service.SimpleLinkService(),
|
120
|
-
l10n
|
123
|
+
l10n,
|
124
|
+
annotationStorage
|
121
125
|
});
|
122
126
|
}
|
123
127
|
|