pdfjs-dist 1.8.349 → 1.8.357
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.combined.js +6 -6
- package/build/pdf.combined.js.map +1 -1
- package/build/pdf.js +8 -7
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +3 -3
- package/build/pdf.worker.js +2 -2
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +2 -2
- package/lib/display/api.js +4 -3
- package/lib/display/global.js +2 -2
- package/lib/pdf.js +2 -2
- package/lib/pdf.worker.js +2 -2
- package/lib/test/unit/api_spec.js +122 -105
- package/lib/test/unit/test_utils.js +19 -1
- package/lib/web/pdf_page_view.js +32 -31
- package/lib/web/pdf_thumbnail_view.js +18 -16
- package/package.json +1 -1
- package/web/pdf_viewer.js +32 -31
- package/web/pdf_viewer.js.map +1 -1
package/lib/display/api.js
CHANGED
@@ -58,7 +58,8 @@ if (typeof __pdfjsdev_webpack__ === 'undefined') {
|
|
58
58
|
var dynamicLoaderSupported = typeof requirejs !== 'undefined' && requirejs.load;
|
59
59
|
fakeWorkerFilesLoader = useRequireEnsure ? function (callback) {
|
60
60
|
require.ensure([], function () {
|
61
|
-
var worker
|
61
|
+
var worker;
|
62
|
+
worker = require('../pdf.worker.js');
|
62
63
|
callback(worker.WorkerMessageHandler);
|
63
64
|
});
|
64
65
|
} : dynamicLoaderSupported ? function (callback) {
|
@@ -1412,8 +1413,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
|
|
1412
1413
|
}();
|
1413
1414
|
var version, build;
|
1414
1415
|
{
|
1415
|
-
exports.version = version = '1.8.
|
1416
|
-
exports.build = build = '
|
1416
|
+
exports.version = version = '1.8.357';
|
1417
|
+
exports.build = build = 'ca3cf6e7';
|
1417
1418
|
}
|
1418
1419
|
exports.getDocument = getDocument;
|
1419
1420
|
exports.LoopbackPort = LoopbackPort;
|
package/lib/display/global.js
CHANGED
@@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
|
|
39
39
|
}
|
40
40
|
var PDFJS = _util.globalScope.PDFJS;
|
41
41
|
{
|
42
|
-
PDFJS.version = '1.8.
|
43
|
-
PDFJS.build = '
|
42
|
+
PDFJS.version = '1.8.357';
|
43
|
+
PDFJS.build = 'ca3cf6e7';
|
44
44
|
}
|
45
45
|
PDFJS.pdfBug = false;
|
46
46
|
if (PDFJS.verbosity !== undefined) {
|
package/lib/pdf.js
CHANGED
@@ -14,8 +14,8 @@
|
|
14
14
|
*/
|
15
15
|
'use strict';
|
16
16
|
|
17
|
-
var pdfjsVersion = '1.8.
|
18
|
-
var pdfjsBuild = '
|
17
|
+
var pdfjsVersion = '1.8.357';
|
18
|
+
var pdfjsBuild = 'ca3cf6e7';
|
19
19
|
var pdfjsSharedUtil = require('./shared/util.js');
|
20
20
|
var pdfjsDisplayGlobal = require('./display/global.js');
|
21
21
|
var pdfjsDisplayAPI = require('./display/api.js');
|
package/lib/pdf.worker.js
CHANGED
@@ -22,18 +22,42 @@ var _dom_utils = require('../../display/dom_utils');
|
|
22
22
|
|
23
23
|
var _api = require('../../display/api');
|
24
24
|
|
25
|
+
var _test_utils = require('./test_utils');
|
26
|
+
|
25
27
|
var _global = require('../../display/global');
|
26
28
|
|
29
|
+
var TEST_PDFS_PATH = {
|
30
|
+
dom: '../pdfs/',
|
31
|
+
node: './test/pdfs/'
|
32
|
+
};
|
33
|
+
function buildGetDocumentParams(filename, options) {
|
34
|
+
var params = Object.create(null);
|
35
|
+
if ((0, _util.isNodeJS)()) {
|
36
|
+
params.data = _test_utils.NodeFileReaderFactory.fetch({ path: TEST_PDFS_PATH.node + filename });
|
37
|
+
} else {
|
38
|
+
params.url = new URL(TEST_PDFS_PATH.dom + filename, window.location).href;
|
39
|
+
}
|
40
|
+
for (var option in options) {
|
41
|
+
params[option] = options[option];
|
42
|
+
}
|
43
|
+
return params;
|
44
|
+
}
|
27
45
|
describe('api', function () {
|
28
|
-
var
|
46
|
+
var basicApiFileName = 'basicapi.pdf';
|
29
47
|
var basicApiFileLength = 105779;
|
30
|
-
var
|
48
|
+
var basicApiGetDocumentParams = buildGetDocumentParams(basicApiFileName);
|
49
|
+
var CanvasFactory = void 0;
|
31
50
|
beforeAll(function (done) {
|
32
|
-
|
51
|
+
if ((0, _util.isNodeJS)()) {
|
52
|
+
_global.PDFJS.pdfjsNext = true;
|
53
|
+
} else {
|
54
|
+
CanvasFactory = new _dom_utils.DOMCanvasFactory();
|
55
|
+
}
|
33
56
|
done();
|
34
57
|
});
|
35
|
-
afterAll(function () {
|
58
|
+
afterAll(function (done) {
|
36
59
|
CanvasFactory = null;
|
60
|
+
done();
|
37
61
|
});
|
38
62
|
function waitSome(callback) {
|
39
63
|
var WAIT_TIMEOUT = 10;
|
@@ -44,7 +68,10 @@ describe('api', function () {
|
|
44
68
|
describe('PDFJS', function () {
|
45
69
|
describe('getDocument', function () {
|
46
70
|
it('creates pdf doc from URL', function (done) {
|
47
|
-
|
71
|
+
if ((0, _util.isNodeJS)()) {
|
72
|
+
pending('XMLHttpRequest is not supported in Node.js.');
|
73
|
+
}
|
74
|
+
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
48
75
|
var isProgressReportedResolved = false;
|
49
76
|
var progressReportedCapability = (0, _util.createPromiseCapability)();
|
50
77
|
loadingTask.onProgress = function (progressData) {
|
@@ -64,7 +91,10 @@ describe('api', function () {
|
|
64
91
|
});
|
65
92
|
});
|
66
93
|
it('creates pdf doc from URL and aborts before worker initialized', function (done) {
|
67
|
-
|
94
|
+
if ((0, _util.isNodeJS)()) {
|
95
|
+
pending('XMLHttpRequest is not supported in Node.js.');
|
96
|
+
}
|
97
|
+
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
68
98
|
var destroyed = loadingTask.destroy();
|
69
99
|
loadingTask.promise.then(function (reason) {
|
70
100
|
done.fail('shall fail loading');
|
@@ -74,7 +104,10 @@ describe('api', function () {
|
|
74
104
|
});
|
75
105
|
});
|
76
106
|
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) {
|
77
|
-
|
107
|
+
if ((0, _util.isNodeJS)()) {
|
108
|
+
pending('XMLHttpRequest is not supported in Node.js.');
|
109
|
+
}
|
110
|
+
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
78
111
|
var destroyed = loadingTask._worker.promise.then(function () {
|
79
112
|
return loadingTask.destroy();
|
80
113
|
});
|
@@ -86,32 +119,33 @@ describe('api', function () {
|
|
86
119
|
});
|
87
120
|
});
|
88
121
|
it('creates pdf doc from typed array', function (done) {
|
89
|
-
var nonBinaryRequest = _global.PDFJS.disableWorker;
|
90
|
-
var request = new XMLHttpRequest();
|
91
|
-
request.open('GET', basicApiUrl, false);
|
92
|
-
if (!nonBinaryRequest) {
|
93
|
-
try {
|
94
|
-
request.responseType = 'arraybuffer';
|
95
|
-
nonBinaryRequest = request.responseType !== 'arraybuffer';
|
96
|
-
} catch (e) {
|
97
|
-
nonBinaryRequest = true;
|
98
|
-
}
|
99
|
-
}
|
100
|
-
if (nonBinaryRequest && request.overrideMimeType) {
|
101
|
-
request.overrideMimeType('text/plain; charset=x-user-defined');
|
102
|
-
}
|
103
|
-
request.send(null);
|
104
122
|
var typedArrayPdf;
|
105
|
-
if (
|
106
|
-
|
107
|
-
return ch.charCodeAt(0) & 0xFF;
|
108
|
-
});
|
109
|
-
typedArrayPdf = new Uint8Array(data);
|
123
|
+
if ((0, _util.isNodeJS)()) {
|
124
|
+
typedArrayPdf = _test_utils.NodeFileReaderFactory.fetch({ path: TEST_PDFS_PATH.node + basicApiFileName });
|
110
125
|
} else {
|
111
|
-
|
126
|
+
var nonBinaryRequest = _global.PDFJS.disableWorker;
|
127
|
+
var request = new XMLHttpRequest();
|
128
|
+
request.open('GET', TEST_PDFS_PATH.dom + basicApiFileName, false);
|
129
|
+
if (!nonBinaryRequest) {
|
130
|
+
try {
|
131
|
+
request.responseType = 'arraybuffer';
|
132
|
+
nonBinaryRequest = request.responseType !== 'arraybuffer';
|
133
|
+
} catch (e) {
|
134
|
+
nonBinaryRequest = true;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
if (nonBinaryRequest && request.overrideMimeType) {
|
138
|
+
request.overrideMimeType('text/plain; charset=x-user-defined');
|
139
|
+
}
|
140
|
+
request.send(null);
|
141
|
+
if (nonBinaryRequest) {
|
142
|
+
typedArrayPdf = (0, _util.stringToBytes)(request.responseText);
|
143
|
+
} else {
|
144
|
+
typedArrayPdf = new Uint8Array(request.response);
|
145
|
+
}
|
112
146
|
}
|
113
147
|
expect(typedArrayPdf.length).toEqual(basicApiFileLength);
|
114
|
-
var loadingTask =
|
148
|
+
var loadingTask = (0, _api.getDocument)(typedArrayPdf);
|
115
149
|
loadingTask.promise.then(function (data) {
|
116
150
|
expect(data instanceof _api.PDFDocumentProxy).toEqual(true);
|
117
151
|
loadingTask.destroy().then(done);
|
@@ -120,8 +154,7 @@ describe('api', function () {
|
|
120
154
|
});
|
121
155
|
});
|
122
156
|
it('creates pdf doc from invalid PDF file', function (done) {
|
123
|
-
var
|
124
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
157
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug1020226.pdf'));
|
125
158
|
loadingTask.promise.then(function () {
|
126
159
|
done.fail('shall fail loading');
|
127
160
|
}).catch(function (error) {
|
@@ -130,8 +163,10 @@ describe('api', function () {
|
|
130
163
|
});
|
131
164
|
});
|
132
165
|
it('creates pdf doc from non-existent URL', function (done) {
|
133
|
-
|
134
|
-
|
166
|
+
if ((0, _util.isNodeJS)()) {
|
167
|
+
pending('XMLHttpRequest is not supported in Node.js.');
|
168
|
+
}
|
169
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('non-existent.pdf'));
|
135
170
|
loadingTask.promise.then(function (error) {
|
136
171
|
done.fail('shall fail loading');
|
137
172
|
}).catch(function (error) {
|
@@ -140,8 +175,7 @@ describe('api', function () {
|
|
140
175
|
});
|
141
176
|
});
|
142
177
|
it('creates pdf doc from PDF file protected with user and owner password', function (done) {
|
143
|
-
var
|
144
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
178
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('pr6531_1.pdf'));
|
145
179
|
var isPasswordNeededResolved = false;
|
146
180
|
var passwordNeededCapability = (0, _util.createPromiseCapability)();
|
147
181
|
var isPasswordIncorrectResolved = false;
|
@@ -170,11 +204,8 @@ describe('api', function () {
|
|
170
204
|
});
|
171
205
|
});
|
172
206
|
it('creates pdf doc from PDF file protected with only a user password', function (done) {
|
173
|
-
var
|
174
|
-
var passwordNeededLoadingTask =
|
175
|
-
url: url,
|
176
|
-
password: ''
|
177
|
-
});
|
207
|
+
var filename = 'pr6531_2.pdf';
|
208
|
+
var passwordNeededLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: '' }));
|
178
209
|
var result1 = passwordNeededLoadingTask.promise.then(function () {
|
179
210
|
done.fail('shall fail with no password');
|
180
211
|
return Promise.reject(new Error('loadingTask should be rejected'));
|
@@ -183,10 +214,7 @@ describe('api', function () {
|
|
183
214
|
expect(data.code).toEqual(_util.PasswordResponses.NEED_PASSWORD);
|
184
215
|
return passwordNeededLoadingTask.destroy();
|
185
216
|
});
|
186
|
-
var passwordIncorrectLoadingTask =
|
187
|
-
url: url,
|
188
|
-
password: 'qwerty'
|
189
|
-
});
|
217
|
+
var passwordIncorrectLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'qwerty' }));
|
190
218
|
var result2 = passwordIncorrectLoadingTask.promise.then(function () {
|
191
219
|
done.fail('shall fail with wrong password');
|
192
220
|
return Promise.reject(new Error('loadingTask should be rejected'));
|
@@ -195,10 +223,7 @@ describe('api', function () {
|
|
195
223
|
expect(data.code).toEqual(_util.PasswordResponses.INCORRECT_PASSWORD);
|
196
224
|
return passwordIncorrectLoadingTask.destroy();
|
197
225
|
});
|
198
|
-
var passwordAcceptedLoadingTask =
|
199
|
-
url: url,
|
200
|
-
password: 'asdfasdf'
|
201
|
-
});
|
226
|
+
var passwordAcceptedLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'asdfasdf' }));
|
202
227
|
var result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
|
203
228
|
expect(data instanceof _api.PDFDocumentProxy).toEqual(true);
|
204
229
|
return passwordAcceptedLoadingTask.destroy();
|
@@ -210,12 +235,9 @@ describe('api', function () {
|
|
210
235
|
});
|
211
236
|
});
|
212
237
|
it('creates pdf doc from password protected PDF file and aborts/throws ' + 'in the onPassword callback (issue 7806)', function (done) {
|
213
|
-
var
|
214
|
-
var passwordNeededLoadingTask =
|
215
|
-
var passwordIncorrectLoadingTask =
|
216
|
-
url: url,
|
217
|
-
password: 'qwerty'
|
218
|
-
});
|
238
|
+
var filename = 'issue3371.pdf';
|
239
|
+
var passwordNeededLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename));
|
240
|
+
var passwordIncorrectLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { password: 'qwerty' }));
|
219
241
|
var passwordNeededDestroyed = void 0;
|
220
242
|
passwordNeededLoadingTask.onPassword = function (callback, reason) {
|
221
243
|
if (reason === _util.PasswordResponses.NEED_PASSWORD) {
|
@@ -255,6 +277,9 @@ describe('api', function () {
|
|
255
277
|
});
|
256
278
|
});
|
257
279
|
describe('PDFWorker', function () {
|
280
|
+
if ((0, _util.isNodeJS)()) {
|
281
|
+
pending('Worker is not supported in Node.js.');
|
282
|
+
}
|
258
283
|
it('worker created or destroyed', function (done) {
|
259
284
|
var worker = new _global.PDFJS.PDFWorker('test1');
|
260
285
|
worker.promise.then(function () {
|
@@ -272,7 +297,7 @@ describe('api', function () {
|
|
272
297
|
});
|
273
298
|
});
|
274
299
|
it('worker created or destroyed by getDocument', function (done) {
|
275
|
-
var loadingTask =
|
300
|
+
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
276
301
|
var worker;
|
277
302
|
loadingTask.promise.then(function () {
|
278
303
|
worker = loadingTask._worker;
|
@@ -292,10 +317,7 @@ describe('api', function () {
|
|
292
317
|
});
|
293
318
|
it('worker created and can be used in getDocument', function (done) {
|
294
319
|
var worker = new _global.PDFJS.PDFWorker('test1');
|
295
|
-
var loadingTask =
|
296
|
-
url: basicApiUrl,
|
297
|
-
worker: worker
|
298
|
-
});
|
320
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams(basicApiFileName, { worker: worker }));
|
299
321
|
loadingTask.promise.then(function () {
|
300
322
|
var docWorker = loadingTask._worker;
|
301
323
|
expect(!!docWorker).toEqual(false);
|
@@ -333,7 +355,7 @@ describe('api', function () {
|
|
333
355
|
var loadingTask;
|
334
356
|
var doc;
|
335
357
|
beforeAll(function (done) {
|
336
|
-
loadingTask =
|
358
|
+
loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
337
359
|
loadingTask.promise.then(function (data) {
|
338
360
|
doc = data;
|
339
361
|
done();
|
@@ -447,8 +469,7 @@ describe('api', function () {
|
|
447
469
|
});
|
448
470
|
});
|
449
471
|
it('gets destinations, from /Names (NameTree) dictionary', function (done) {
|
450
|
-
var
|
451
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
472
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
|
452
473
|
var promise = loadingTask.promise.then(function (pdfDocument) {
|
453
474
|
return pdfDocument.getDestinations();
|
454
475
|
});
|
@@ -469,8 +490,7 @@ describe('api', function () {
|
|
469
490
|
});
|
470
491
|
});
|
471
492
|
it('gets a destination, from /Names (NameTree) dictionary', function (done) {
|
472
|
-
var
|
473
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
493
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
|
474
494
|
var promise = loadingTask.promise.then(function (pdfDocument) {
|
475
495
|
return pdfDocument.getDestination('Page.1');
|
476
496
|
});
|
@@ -485,8 +505,7 @@ describe('api', function () {
|
|
485
505
|
});
|
486
506
|
});
|
487
507
|
it('gets a non-existent destination, from /Names (NameTree) dictionary', function (done) {
|
488
|
-
var
|
489
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
508
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6204.pdf'));
|
490
509
|
var promise = loadingTask.promise.then(function (pdfDocument) {
|
491
510
|
return pdfDocument.getDestination('non-existent-named-destination');
|
492
511
|
});
|
@@ -507,23 +526,19 @@ describe('api', function () {
|
|
507
526
|
});
|
508
527
|
});
|
509
528
|
it('gets page labels', function (done) {
|
510
|
-
var
|
511
|
-
var loadingTask0 = _global.PDFJS.getDocument(url0);
|
529
|
+
var loadingTask0 = (0, _api.getDocument)(buildGetDocumentParams('bug793632.pdf'));
|
512
530
|
var promise0 = loadingTask0.promise.then(function (pdfDoc) {
|
513
531
|
return pdfDoc.getPageLabels();
|
514
532
|
});
|
515
|
-
var
|
516
|
-
var loadingTask1 = _global.PDFJS.getDocument(url1);
|
533
|
+
var loadingTask1 = (0, _api.getDocument)(buildGetDocumentParams('issue1453.pdf'));
|
517
534
|
var promise1 = loadingTask1.promise.then(function (pdfDoc) {
|
518
535
|
return pdfDoc.getPageLabels();
|
519
536
|
});
|
520
|
-
var
|
521
|
-
var loadingTask2 = _global.PDFJS.getDocument(url2);
|
537
|
+
var loadingTask2 = (0, _api.getDocument)(buildGetDocumentParams('rotation.pdf'));
|
522
538
|
var promise2 = loadingTask2.promise.then(function (pdfDoc) {
|
523
539
|
return pdfDoc.getPageLabels();
|
524
540
|
});
|
525
|
-
var
|
526
|
-
var loadingTask3 = _global.PDFJS.getDocument(url3);
|
541
|
+
var loadingTask3 = (0, _api.getDocument)(buildGetDocumentParams('bad-PageLabels.pdf'));
|
527
542
|
var promise3 = loadingTask3.promise.then(function (pdfDoc) {
|
528
543
|
return pdfDoc.getPageLabels();
|
529
544
|
});
|
@@ -547,8 +562,10 @@ describe('api', function () {
|
|
547
562
|
});
|
548
563
|
});
|
549
564
|
it('gets attachments', function (done) {
|
550
|
-
|
551
|
-
|
565
|
+
if ((0, _util.isNodeJS)()) {
|
566
|
+
pending('TODO: Use a non-linked test-case.');
|
567
|
+
}
|
568
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug766138.pdf'));
|
552
569
|
var promise = loadingTask.promise.then(function (pdfDoc) {
|
553
570
|
return pdfDoc.getAttachments();
|
554
571
|
});
|
@@ -573,8 +590,7 @@ describe('api', function () {
|
|
573
590
|
});
|
574
591
|
var viewerPrintRegExp = /\bprint\s*\(/;
|
575
592
|
it('gets javascript with printing instructions (Print action)', function (done) {
|
576
|
-
var
|
577
|
-
var loadingTask = _global.PDFJS.getDocument(pdfUrl);
|
593
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('bug1001080.pdf'));
|
578
594
|
var promise = loadingTask.promise.then(function (doc) {
|
579
595
|
return doc.getJavaScript();
|
580
596
|
});
|
@@ -587,8 +603,7 @@ describe('api', function () {
|
|
587
603
|
});
|
588
604
|
});
|
589
605
|
it('gets javascript with printing instructions (JS action)', function (done) {
|
590
|
-
var
|
591
|
-
var loadingTask = _global.PDFJS.getDocument(pdfUrl);
|
606
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue6106.pdf'));
|
592
607
|
var promise = loadingTask.promise.then(function (doc) {
|
593
608
|
return doc.getJavaScript();
|
594
609
|
});
|
@@ -601,8 +616,7 @@ describe('api', function () {
|
|
601
616
|
});
|
602
617
|
});
|
603
618
|
it('gets non-existent outline', function (done) {
|
604
|
-
var
|
605
|
-
var loadingTask = _global.PDFJS.getDocument(url);
|
619
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('tracemonkey.pdf'));
|
606
620
|
var promise = loadingTask.promise.then(function (pdfDocument) {
|
607
621
|
return pdfDocument.getOutline();
|
608
622
|
});
|
@@ -635,8 +649,7 @@ describe('api', function () {
|
|
635
649
|
});
|
636
650
|
});
|
637
651
|
it('gets outline containing a url', function (done) {
|
638
|
-
var
|
639
|
-
var loadingTask = _global.PDFJS.getDocument(pdfUrl);
|
652
|
+
var loadingTask = (0, _api.getDocument)(buildGetDocumentParams('issue3214.pdf'));
|
640
653
|
loadingTask.promise.then(function (pdfDocument) {
|
641
654
|
pdfDocument.getOutline().then(function (outline) {
|
642
655
|
expect(outline instanceof Array).toEqual(true);
|
@@ -658,6 +671,9 @@ describe('api', function () {
|
|
658
671
|
});
|
659
672
|
});
|
660
673
|
it('gets metadata', function (done) {
|
674
|
+
if ((0, _util.isNodeJS)()) {
|
675
|
+
pending('Document is not supported in Node.js.');
|
676
|
+
}
|
661
677
|
var promise = doc.getMetadata();
|
662
678
|
promise.then(function (metadata) {
|
663
679
|
expect(metadata.info['Title']).toEqual('Basic API Test');
|
@@ -700,10 +716,8 @@ describe('api', function () {
|
|
700
716
|
});
|
701
717
|
});
|
702
718
|
it('checks that fingerprints are unique', function (done) {
|
703
|
-
var
|
704
|
-
var
|
705
|
-
var url2 = new URL('../pdfs/issue4575.pdf', window.location).href;
|
706
|
-
var loadingTask2 = _global.PDFJS.getDocument(url2);
|
719
|
+
var loadingTask1 = (0, _api.getDocument)(buildGetDocumentParams('issue4436r.pdf'));
|
720
|
+
var loadingTask2 = (0, _api.getDocument)(buildGetDocumentParams('issue4575.pdf'));
|
707
721
|
var promises = [loadingTask1.promise, loadingTask2.promise];
|
708
722
|
Promise.all(promises).then(function (data) {
|
709
723
|
var fingerprint1 = data[0].fingerprint;
|
@@ -723,7 +737,7 @@ describe('api', function () {
|
|
723
737
|
var loadingTask;
|
724
738
|
var pdfDocument, page;
|
725
739
|
beforeAll(function (done) {
|
726
|
-
loadingTask =
|
740
|
+
loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams);
|
727
741
|
loadingTask.promise.then(function (doc) {
|
728
742
|
pdfDocument = doc;
|
729
743
|
pdfDocument.getPage(1).then(function (data) {
|
@@ -781,26 +795,20 @@ describe('api', function () {
|
|
781
795
|
});
|
782
796
|
});
|
783
797
|
it('gets annotations containing relative URLs (bug 766086)', function (done) {
|
784
|
-
var
|
785
|
-
var defaultLoadingTask =
|
798
|
+
var filename = 'bug766086.pdf';
|
799
|
+
var defaultLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename));
|
786
800
|
var defaultPromise = defaultLoadingTask.promise.then(function (pdfDoc) {
|
787
801
|
return pdfDoc.getPage(1).then(function (pdfPage) {
|
788
802
|
return pdfPage.getAnnotations();
|
789
803
|
});
|
790
804
|
});
|
791
|
-
var docBaseUrlLoadingTask =
|
792
|
-
url: url,
|
793
|
-
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf'
|
794
|
-
});
|
805
|
+
var docBaseUrlLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf' }));
|
795
806
|
var docBaseUrlPromise = docBaseUrlLoadingTask.promise.then(function (pdfDoc) {
|
796
807
|
return pdfDoc.getPage(1).then(function (pdfPage) {
|
797
808
|
return pdfPage.getAnnotations();
|
798
809
|
});
|
799
810
|
});
|
800
|
-
var invalidDocBaseUrlLoadingTask =
|
801
|
-
url: url,
|
802
|
-
docBaseUrl: 'qwerty.pdf'
|
803
|
-
});
|
811
|
+
var invalidDocBaseUrlLoadingTask = (0, _api.getDocument)(buildGetDocumentParams(filename, { docBaseUrl: 'qwerty.pdf' }));
|
804
812
|
var invalidDocBaseUrlPromise = invalidDocBaseUrlLoadingTask.promise.then(function (pdfDoc) {
|
805
813
|
return pdfDoc.getPage(1).then(function (pdfPage) {
|
806
814
|
return pdfPage.getAnnotations();
|
@@ -869,6 +877,9 @@ describe('api', function () {
|
|
869
877
|
});
|
870
878
|
});
|
871
879
|
it('cancels rendering of page', function (done) {
|
880
|
+
if ((0, _util.isNodeJS)()) {
|
881
|
+
pending('TODO: Support Canvas testing in Node.js.');
|
882
|
+
}
|
872
883
|
var viewport = page.getViewport(1);
|
873
884
|
var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
|
874
885
|
var renderTask = page.render({
|
@@ -887,13 +898,16 @@ describe('api', function () {
|
|
887
898
|
});
|
888
899
|
});
|
889
900
|
describe('Multiple PDFJS instances', function () {
|
890
|
-
|
891
|
-
|
892
|
-
|
901
|
+
if ((0, _util.isNodeJS)()) {
|
902
|
+
pending('TODO: Support Canvas testing in Node.js.');
|
903
|
+
}
|
904
|
+
var pdf1 = buildGetDocumentParams('tracemonkey.pdf');
|
905
|
+
var pdf2 = buildGetDocumentParams('TAMReview.pdf');
|
906
|
+
var pdf3 = buildGetDocumentParams('issue6068.pdf');
|
893
907
|
var loadingTasks = [];
|
894
908
|
var pdfDocuments = [];
|
895
909
|
function renderPDF(filename) {
|
896
|
-
var loadingTask =
|
910
|
+
var loadingTask = (0, _api.getDocument)(filename);
|
897
911
|
loadingTasks.push(loadingTask);
|
898
912
|
return loadingTask.promise.then(function (pdf) {
|
899
913
|
pdfDocuments.push(pdf);
|
@@ -947,6 +961,9 @@ describe('api', function () {
|
|
947
961
|
});
|
948
962
|
});
|
949
963
|
describe('PDFDataRangeTransport', function () {
|
964
|
+
if ((0, _util.isNodeJS)()) {
|
965
|
+
pending('XMLHttpRequest is not supported in Node.js.');
|
966
|
+
}
|
950
967
|
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href;
|
951
968
|
var loadPromise;
|
952
969
|
function getDocumentData() {
|
@@ -981,7 +998,7 @@ describe('api', function () {
|
|
981
998
|
transport.onDataRange(begin, data.subarray(begin, end));
|
982
999
|
});
|
983
1000
|
};
|
984
|
-
var loadingTask =
|
1001
|
+
var loadingTask = (0, _api.getDocument)(transport);
|
985
1002
|
return loadingTask.promise;
|
986
1003
|
});
|
987
1004
|
var pdfDocument;
|
@@ -1015,7 +1032,7 @@ describe('api', function () {
|
|
1015
1032
|
transport.onDataRange(begin, data.subarray(begin, end));
|
1016
1033
|
});
|
1017
1034
|
};
|
1018
|
-
var loadingTask =
|
1035
|
+
var loadingTask = (0, _api.getDocument)(transport);
|
1019
1036
|
return loadingTask.promise;
|
1020
1037
|
});
|
1021
1038
|
var pdfDocument;
|
@@ -17,7 +17,7 @@
|
|
17
17
|
Object.defineProperty(exports, "__esModule", {
|
18
18
|
value: true
|
19
19
|
});
|
20
|
-
exports.NodeCMapReaderFactory = undefined;
|
20
|
+
exports.NodeCMapReaderFactory = exports.NodeFileReaderFactory = undefined;
|
21
21
|
|
22
22
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
23
23
|
|
@@ -25,6 +25,23 @@ var _util = require('../../shared/util');
|
|
25
25
|
|
26
26
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
27
27
|
|
28
|
+
var NodeFileReaderFactory = function () {
|
29
|
+
function NodeFileReaderFactory() {
|
30
|
+
_classCallCheck(this, NodeFileReaderFactory);
|
31
|
+
}
|
32
|
+
|
33
|
+
_createClass(NodeFileReaderFactory, null, [{
|
34
|
+
key: 'fetch',
|
35
|
+
value: function fetch(params) {
|
36
|
+
var fs = require('fs');
|
37
|
+
var file = fs.readFileSync(params.path);
|
38
|
+
return new Uint8Array(file);
|
39
|
+
}
|
40
|
+
}]);
|
41
|
+
|
42
|
+
return NodeFileReaderFactory;
|
43
|
+
}();
|
44
|
+
|
28
45
|
var NodeCMapReaderFactory = function () {
|
29
46
|
function NodeCMapReaderFactory(_ref) {
|
30
47
|
var _ref$baseUrl = _ref.baseUrl,
|
@@ -68,4 +85,5 @@ var NodeCMapReaderFactory = function () {
|
|
68
85
|
return NodeCMapReaderFactory;
|
69
86
|
}();
|
70
87
|
|
88
|
+
exports.NodeFileReaderFactory = NodeFileReaderFactory;
|
71
89
|
exports.NodeCMapReaderFactory = NodeCMapReaderFactory;
|