1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 07:38:07 +02:00

Move the cMapUrl and cMapPacked options from the global PDFJS object and into getDocument instead

This commit is contained in:
Jonas Jenwald 2018-02-17 16:57:24 +01:00
parent b674409397
commit 3c2fbdffe6
13 changed files with 72 additions and 63 deletions

View file

@ -18,6 +18,8 @@
const WAITING_TIME = 100; // ms
const PDF_TO_CSS_UNITS = 96.0 / 72.0;
const CMAP_URL = '../external/bcmaps/';
const CMAP_PACKED = true;
const IMAGE_RESOURCES_PATH = '/web/images/';
const WORKER_SRC = '../build/generic/build/pdf.worker.js';
@ -271,8 +273,6 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
// Configure the global worker options.
PDFJS.GlobalWorkerOptions.workerSrc = WORKER_SRC;
PDFJS.cMapPacked = true;
PDFJS.cMapUrl = '../external/bcmaps/';
PDFJS.pdfBug = true;
// Set the passed options
@ -366,6 +366,8 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
url: absoluteUrl,
password: task.password,
nativeImageDecoderSupport: task.nativeImageDecoderSupport,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
}).then((doc) => {
task.pdfDoc = doc;
this._nextPage(task, failure);

View file

@ -281,8 +281,9 @@ describe('cmap', function() {
done.fail('No CMap should be loaded');
}, function (reason) {
expect(reason instanceof Error).toEqual(true);
expect(reason.message).toEqual('CMap baseUrl must be specified, ' +
'see "PDFJS.cMapUrl" (and also "PDFJS.cMapPacked").');
expect(reason.message).toEqual(
'The CMap "baseUrl" parameter must be specified, ensure that ' +
'the "cMapUrl" and "cMapPacked" API parameters are provided.');
done();
});
});

View file

@ -51,8 +51,9 @@ class NodeCMapReaderFactory {
fetch({ name, }) {
if (!this.baseUrl) {
return Promise.reject(new Error('CMap baseUrl must be specified, ' +
'see "PDFJS.cMapUrl" (and also "PDFJS.cMapPacked").'));
return Promise.reject(new Error(
'The CMap "baseUrl" parameter must be specified, ensure that ' +
'the "cMapUrl" and "cMapPacked" API parameters are provided.'));
}
if (!name) {
return Promise.reject(new Error('CMap name must be specified.'));