pdfjs-dist 2.4.456 → 2.5.207
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 +4447 -4379
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +8549 -8507
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/es5/build/pdf.js +14755 -14540
- package/es5/build/pdf.js.map +1 -1
- package/es5/build/pdf.worker.js +9830 -9469
- package/es5/build/pdf.worker.js.map +1 -1
- package/es5/web/pdf_viewer.css +5 -9
- package/es5/web/pdf_viewer.js +157 -172
- package/es5/web/pdf_viewer.js.map +1 -1
- package/image_decoders/pdf.image_decoders.js +107 -93
- package/image_decoders/pdf.image_decoders.js.map +1 -1
- package/image_decoders/pdf.image_decoders.min.js +1 -1
- package/lib/README.md +2 -2
- package/lib/core/ccitt.js +7 -7
- package/lib/core/cff_parser.js +1 -1
- package/lib/core/chunked_stream.js +5 -5
- package/lib/core/cmap.js +13 -0
- package/lib/core/document.js +22 -18
- package/lib/core/evaluator.js +285 -247
- package/lib/core/font_renderer.js +7 -7
- package/lib/core/fonts.js +163 -147
- package/lib/core/function.js +4 -5
- package/lib/core/glyphlist.js +4523 -4523
- package/lib/core/image.js +19 -44
- package/lib/core/image_utils.js +123 -47
- package/lib/core/jpeg_stream.js +2 -116
- package/lib/core/jpg.js +47 -55
- package/lib/core/jpx.js +6 -6
- package/lib/core/metrics.js +2916 -2916
- package/lib/core/obj.js +18 -7
- package/lib/core/operator_list.js +5 -0
- package/lib/core/parser.js +1 -1
- package/lib/core/pdf_manager.js +2 -2
- package/lib/core/primitives.js +4 -0
- package/lib/core/standard_fonts.js +103 -103
- package/lib/core/type1_parser.js +6 -6
- package/lib/core/worker.js +31 -24
- package/lib/core/worker_stream.js +1 -1
- package/lib/display/annotation_layer.js +3 -0
- package/lib/display/api.js +29 -137
- package/lib/display/api_compatibility.js +11 -18
- package/lib/display/canvas.js +7 -34
- package/lib/display/content_disposition.js +4 -4
- package/lib/display/display_utils.js +6 -15
- package/lib/display/fetch_stream.js +3 -1
- package/lib/display/font_loader.js +2 -2
- package/lib/display/network.js +1 -1
- package/lib/display/node_stream.js +10 -8
- package/lib/display/pattern_helper.js +1 -1
- package/lib/display/svg.js +61 -31
- package/lib/display/text_layer.js +44 -32
- package/lib/display/transport_stream.js +3 -3
- package/lib/pdf.js +210 -48
- package/lib/pdf.worker.js +12 -4
- package/lib/shared/compatibility.js +2 -0
- package/lib/shared/is_node.js +1 -1
- package/lib/shared/message_handler.js +6 -6
- package/lib/shared/util.js +15 -9
- package/lib/test/unit/api_spec.js +165 -95
- package/lib/test/unit/cff_parser_spec.js +12 -12
- package/lib/test/unit/clitests_helper.js +1 -1
- package/lib/test/unit/display_svg_spec.js +1 -5
- package/lib/test/unit/jasmine-boot.js +2 -2
- package/lib/test/unit/node_stream_spec.js +5 -3
- package/lib/test/unit/parser_spec.js +3 -3
- package/lib/test/unit/test_utils.js +1 -1
- package/lib/test/unit/testreporter.js +4 -4
- package/lib/test/unit/ui_utils_spec.js +1 -55
- package/lib/test/unit/unicode_spec.js +1 -1
- package/lib/web/app.js +247 -159
- package/lib/web/app_options.js +16 -10
- package/lib/web/base_viewer.js +14 -6
- package/lib/web/download_manager.js +3 -1
- package/lib/web/firefox_print_service.js +1 -1
- package/lib/web/firefoxcom.js +16 -4
- package/lib/web/pdf_attachment_viewer.js +14 -7
- package/lib/web/pdf_document_properties.js +11 -16
- package/lib/web/pdf_find_bar.js +3 -3
- package/lib/web/pdf_find_controller.js +3 -3
- package/lib/web/pdf_history.js +7 -5
- package/lib/web/pdf_link_service.js +7 -8
- package/lib/web/pdf_page_view.js +1 -1
- package/lib/web/pdf_presentation_mode.js +6 -2
- package/lib/web/pdf_print_service.js +1 -1
- package/lib/web/pdf_single_page_viewer.js +2 -2
- package/lib/web/pdf_viewer.component.js +2 -2
- package/lib/web/pdf_viewer.js +2 -2
- package/lib/web/preferences.js +4 -1
- package/lib/web/text_layer_builder.js +1 -3
- package/lib/web/ui_utils.js +3 -55
- package/lib/web/view_history.js +8 -9
- package/lib/web/viewer_compatibility.js +14 -1
- package/package.json +1 -1
- package/web/pdf_viewer.css +5 -9
- package/web/pdf_viewer.js +97 -127
- package/web/pdf_viewer.js.map +1 -1
@@ -130,12 +130,12 @@ describe("CFFParser", function () {
|
|
130
130
|
expect(charStrings.get(0).length).toEqual(38);
|
131
131
|
});
|
132
132
|
it("parses a CharString endchar with 4 args w/seac enabled", function () {
|
133
|
-
|
134
|
-
|
133
|
+
const cffParser = new _cff_parser.CFFParser(fontData, {}, true);
|
134
|
+
cffParser.parse();
|
135
135
|
var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
|
136
|
-
|
137
|
-
var charStringsIndex =
|
138
|
-
var result =
|
136
|
+
cffParser.bytes = bytes;
|
137
|
+
var charStringsIndex = cffParser.parseIndex(0).obj;
|
138
|
+
var result = cffParser.parseCharStrings({
|
139
139
|
charStrings: charStringsIndex,
|
140
140
|
privateDict: privateDictStub
|
141
141
|
});
|
@@ -149,12 +149,12 @@ describe("CFFParser", function () {
|
|
149
149
|
expect(result.seacs[0][3]).toEqual(194);
|
150
150
|
});
|
151
151
|
it("parses a CharString endchar with 4 args w/seac disabled", function () {
|
152
|
-
|
153
|
-
|
152
|
+
const cffParser = new _cff_parser.CFFParser(fontData, {}, false);
|
153
|
+
cffParser.parse();
|
154
154
|
var bytes = new Uint8Array([0, 1, 1, 0, 237, 247, 22, 247, 72, 204, 247, 86, 14]);
|
155
|
-
|
156
|
-
var charStringsIndex =
|
157
|
-
var result =
|
155
|
+
cffParser.bytes = bytes;
|
156
|
+
var charStringsIndex = cffParser.parseIndex(0).obj;
|
157
|
+
var result = cffParser.parseCharStrings({
|
158
158
|
charStrings: charStringsIndex,
|
159
159
|
privateDict: privateDictStub
|
160
160
|
});
|
@@ -192,7 +192,7 @@ describe("CFFParser", function () {
|
|
192
192
|
var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
|
193
193
|
expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
|
194
194
|
charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
|
195
|
-
expect(charset.charset).toEqual([
|
195
|
+
expect(charset.charset).toEqual([0, 8, 9]);
|
196
196
|
});
|
197
197
|
it("parses charset format 2", function () {
|
198
198
|
var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x01]);
|
@@ -200,7 +200,7 @@ describe("CFFParser", function () {
|
|
200
200
|
var charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), false);
|
201
201
|
expect(charset.charset).toEqual([".notdef", "quoteright", "parenleft"]);
|
202
202
|
charset = parser.parseCharsets(3, 2, new _cff_parser.CFFStrings(), true);
|
203
|
-
expect(charset.charset).toEqual([
|
203
|
+
expect(charset.charset).toEqual([0, 8, 9]);
|
204
204
|
});
|
205
205
|
it("parses encoding format 0", function () {
|
206
206
|
var bytes = new Uint8Array([0x00, 0x00, 0x00, 0x01, 0x08]);
|
@@ -30,7 +30,7 @@ var _node_stream = require("../../display/node_stream.js");
|
|
30
30
|
var _api = require("../../display/api.js");
|
31
31
|
|
32
32
|
if (!_is_node.isNodeJS) {
|
33
|
-
throw new Error("The `gulp unittestcli` command can only be used in
|
33
|
+
throw new Error("The `gulp unittestcli` command can only be used in Node.js environments.");
|
34
34
|
}
|
35
35
|
|
36
36
|
(0, _util.setVerbosityLevel)(_util.VerbosityLevel.ERRORS);
|
@@ -29,8 +29,6 @@ var _api = require("../../display/api.js");
|
|
29
29
|
|
30
30
|
var _is_node = require("../../shared/is_node.js");
|
31
31
|
|
32
|
-
var _util = require("../../shared/util.js");
|
33
|
-
|
34
32
|
var _svg = require("../../display/svg.js");
|
35
33
|
|
36
34
|
const XLINK_NS = "http://www.w3.org/1999/xlink";
|
@@ -72,9 +70,7 @@ describe("SVGGraphics", function () {
|
|
72
70
|
var loadingTask;
|
73
71
|
var page;
|
74
72
|
beforeAll(function (done) {
|
75
|
-
loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("xobject-image.pdf"
|
76
|
-
nativeImageDecoderSupport: _util.NativeImageDecoding.DISPLAY
|
77
|
-
}));
|
73
|
+
loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)("xobject-image.pdf"));
|
78
74
|
loadingTask.promise.then(function (doc) {
|
79
75
|
doc.getPage(1).then(function (firstPage) {
|
80
76
|
page = firstPage;
|
@@ -40,7 +40,7 @@ function initializePDFJS(callback) {
|
|
40
40
|
} = modules[4];
|
41
41
|
|
42
42
|
if (isNodeJS) {
|
43
|
-
throw new Error("The `gulp unittest` command cannot be used in
|
43
|
+
throw new Error("The `gulp unittest` command cannot be used in Node.js environments.");
|
44
44
|
}
|
45
45
|
|
46
46
|
if (typeof Response !== "undefined" && "body" in Response.prototype && typeof ReadableStream !== "undefined") {
|
@@ -115,7 +115,7 @@ function initializePDFJS(callback) {
|
|
115
115
|
env.addReporter(htmlReporter);
|
116
116
|
|
117
117
|
if (queryString.getParam("browser")) {
|
118
|
-
var testReporter = new TestReporter(queryString.getParam("browser")
|
118
|
+
var testReporter = new TestReporter(queryString.getParam("browser"));
|
119
119
|
env.addReporter(testReporter);
|
120
120
|
}
|
121
121
|
|
@@ -27,7 +27,9 @@ var _is_node = require("../../shared/is_node.js");
|
|
27
27
|
|
28
28
|
var _node_stream = require("../../display/node_stream.js");
|
29
29
|
|
30
|
-
|
30
|
+
if (!_is_node.isNodeJS) {
|
31
|
+
throw new Error('The "node_stream" unit-tests can only be run in Node.js environments.');
|
32
|
+
}
|
31
33
|
|
32
34
|
const path = require("path");
|
33
35
|
|
@@ -52,7 +54,7 @@ describe("node_stream", function () {
|
|
52
54
|
return;
|
53
55
|
}
|
54
56
|
|
55
|
-
if (!request.headers
|
57
|
+
if (!request.headers.range) {
|
56
58
|
const contentLength = stat.size;
|
57
59
|
const stream = fs.createReadStream(filePath);
|
58
60
|
response.writeHead(200, {
|
@@ -62,7 +64,7 @@ describe("node_stream", function () {
|
|
62
64
|
});
|
63
65
|
stream.pipe(response);
|
64
66
|
} else {
|
65
|
-
const [start, end] = request.headers
|
67
|
+
const [start, end] = request.headers.range.split("=")[1].split("-").map(x => {
|
66
68
|
return Number(x);
|
67
69
|
});
|
68
70
|
const stream = fs.createReadStream(filePath, {
|
@@ -136,10 +136,10 @@ describe("parser", function () {
|
|
136
136
|
const numbers = ["..", "-.", "+.", "-\r\n.", "+\r\n."];
|
137
137
|
|
138
138
|
for (const number of numbers) {
|
139
|
-
const
|
140
|
-
const
|
139
|
+
const invalidInput = new _stream.StringStream(number);
|
140
|
+
const invalidLexer = new _parser.Lexer(invalidInput);
|
141
141
|
expect(function () {
|
142
|
-
return
|
142
|
+
return invalidLexer.getNumber();
|
143
143
|
}).toThrowError(_util.FormatError, /^Invalid number:\s/);
|
144
144
|
}
|
145
145
|
});
|
@@ -21,7 +21,7 @@
|
|
21
21
|
*/
|
22
22
|
"use strict";
|
23
23
|
|
24
|
-
var TestReporter = function (browser
|
24
|
+
var TestReporter = function (browser) {
|
25
25
|
function send(action, json, cb) {
|
26
26
|
var r = new XMLHttpRequest();
|
27
27
|
r.open("POST", action, true);
|
@@ -39,7 +39,7 @@ var TestReporter = function (browser, appPath) {
|
|
39
39
|
}
|
40
40
|
};
|
41
41
|
|
42
|
-
json
|
42
|
+
json.browser = browser;
|
43
43
|
r.send(JSON.stringify(json));
|
44
44
|
}
|
45
45
|
|
@@ -56,14 +56,14 @@ var TestReporter = function (browser, appPath) {
|
|
56
56
|
};
|
57
57
|
|
58
58
|
if (typeof error !== "undefined") {
|
59
|
-
message
|
59
|
+
message.error = error;
|
60
60
|
}
|
61
61
|
|
62
62
|
send("/submit_task_results", message);
|
63
63
|
}
|
64
64
|
|
65
65
|
function sendQuitRequest() {
|
66
|
-
send(
|
66
|
+
send(`/tellMeToQuit?browser=${escape(browser)}`, {});
|
67
67
|
}
|
68
68
|
|
69
69
|
this.now = function () {
|
@@ -228,7 +228,7 @@ describe("ui_utils", function () {
|
|
228
228
|
eventBus.dispatch("test");
|
229
229
|
expect(count).toEqual(2);
|
230
230
|
});
|
231
|
-
it("should not
|
231
|
+
it("should not re-dispatch to DOM", function (done) {
|
232
232
|
if (_is_node.isNodeJS) {
|
233
233
|
pending("Document in not supported in Node.js.");
|
234
234
|
}
|
@@ -252,60 +252,6 @@ describe("ui_utils", function () {
|
|
252
252
|
done();
|
253
253
|
});
|
254
254
|
});
|
255
|
-
it("should re-dispatch to DOM", function (done) {
|
256
|
-
if (_is_node.isNodeJS) {
|
257
|
-
pending("Document in not supported in Node.js.");
|
258
|
-
}
|
259
|
-
|
260
|
-
const eventBus = new _ui_utils.EventBus({
|
261
|
-
dispatchToDOM: true
|
262
|
-
});
|
263
|
-
let count = 0;
|
264
|
-
eventBus.on("test", function (evt) {
|
265
|
-
expect(evt).toEqual(undefined);
|
266
|
-
count++;
|
267
|
-
});
|
268
|
-
|
269
|
-
function domEventListener(evt) {
|
270
|
-
expect(evt.detail).toEqual({});
|
271
|
-
count++;
|
272
|
-
}
|
273
|
-
|
274
|
-
document.addEventListener("test", domEventListener);
|
275
|
-
eventBus.dispatch("test");
|
276
|
-
Promise.resolve().then(() => {
|
277
|
-
expect(count).toEqual(2);
|
278
|
-
document.removeEventListener("test", domEventListener);
|
279
|
-
done();
|
280
|
-
});
|
281
|
-
});
|
282
|
-
it("should re-dispatch to DOM, with arguments (without internal listeners)", function (done) {
|
283
|
-
if (_is_node.isNodeJS) {
|
284
|
-
pending("Document in not supported in Node.js.");
|
285
|
-
}
|
286
|
-
|
287
|
-
const eventBus = new _ui_utils.EventBus({
|
288
|
-
dispatchToDOM: true
|
289
|
-
});
|
290
|
-
let count = 0;
|
291
|
-
|
292
|
-
function domEventListener(evt) {
|
293
|
-
expect(evt.detail).toEqual({
|
294
|
-
abc: 123
|
295
|
-
});
|
296
|
-
count++;
|
297
|
-
}
|
298
|
-
|
299
|
-
document.addEventListener("test", domEventListener);
|
300
|
-
eventBus.dispatch("test", {
|
301
|
-
abc: 123
|
302
|
-
});
|
303
|
-
Promise.resolve().then(() => {
|
304
|
-
expect(count).toEqual(1);
|
305
|
-
document.removeEventListener("test", domEventListener);
|
306
|
-
done();
|
307
|
-
});
|
308
|
-
});
|
309
255
|
});
|
310
256
|
describe("isValidRotation", function () {
|
311
257
|
it("should reject non-integer angles", function () {
|
@@ -84,7 +84,7 @@ describe("unicode", function () {
|
|
84
84
|
expect(NormalizedUnicodes["\u0675"]).toEqual("\u0627\u0674");
|
85
85
|
});
|
86
86
|
it("should not normalize standard characters", function () {
|
87
|
-
expect(NormalizedUnicodes
|
87
|
+
expect(NormalizedUnicodes.A).toEqual(undefined);
|
88
88
|
});
|
89
89
|
});
|
90
90
|
describe("reverseIfRtl", function () {
|