mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Make worker support work again after file split. Add PDFJS_WORKER_DIR/PDFJS_WORKER_FILE to specify where to load files if worker support is enabled
This commit is contained in:
parent
21a6467b23
commit
1e6d1f9922
8 changed files with 91 additions and 46 deletions
21
src/core.js
21
src/core.js
|
@ -471,7 +471,26 @@ var PDFDoc = (function() {
|
|||
this.pageCache = [];
|
||||
|
||||
if (useWorker) {
|
||||
var worker = new Worker('../src/worker_loader.js');
|
||||
var worker;
|
||||
if (typeof PDFJS_WORKER_DIR !== 'undefined') {
|
||||
// If `PDFJS_WORKER_DIR` is specified, we assume the pdf.js files
|
||||
// located all in that directory. Create a new worker and tell him
|
||||
// the directory, such that he can load the scripts from there.
|
||||
worker = new Worker(PDFJS_WORKER_DIR + 'worker_loader.js');
|
||||
console.log('main: post dir');
|
||||
|
||||
worker.postMessage(PDFJS_WORKER_DIR);
|
||||
} else if (typeof PDFJS_WORKER_FILE !== 'undefined') {
|
||||
// If we build the worker using a worker file, then we assume, that
|
||||
// everything the worker needs is already included in that file.
|
||||
// Therefore the worker doesn't have to call `importScripts` to load
|
||||
// all the single files and therefore it's not necessary to tell the
|
||||
// worker a directory to laod the js files from.
|
||||
// (Which is different from the PDFJS_WORKER_DIR case above.)
|
||||
worker = new Worker(PDFJS_WORKER_FILE);
|
||||
} else {
|
||||
throw 'No worker file or directory specified.';
|
||||
}
|
||||
} else {
|
||||
// If we don't use a worker, just post/sendMessage to the main thread.
|
||||
var worker = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue