Merge pull request #6595 from yurydelendik/currentscript
Uses document.currentScript for pdf.worker.js path.
This commit is contained in:
commit
1e0bd07d8d
@ -20,11 +20,9 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
' `node make generic components`');
|
' `node make generic components`');
|
||||||
}
|
}
|
||||||
|
|
||||||
// In cases when the pdf.worker.js is located at the different folder than the
|
// The workerSrc property shall be specified.
|
||||||
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
|
||||||
// shall be specified.
|
|
||||||
//
|
//
|
||||||
// PDFJS.workerSrc = '../../build/pdf.worker.js';
|
PDFJS.workerSrc = '../../build/pdf.worker.js';
|
||||||
|
|
||||||
// Some PDFs need external cmaps.
|
// Some PDFs need external cmaps.
|
||||||
//
|
//
|
||||||
|
@ -20,11 +20,9 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
' `node make generic components`');
|
' `node make generic components`');
|
||||||
}
|
}
|
||||||
|
|
||||||
// In cases when the pdf.worker.js is located at the different folder than the
|
// The workerSrc property shall be specified.
|
||||||
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
|
||||||
// shall be specified.
|
|
||||||
//
|
//
|
||||||
// PDFJS.workerSrc = '../../build/pdf.worker.js';
|
PDFJS.workerSrc = '../../build/pdf.worker.js';
|
||||||
|
|
||||||
// Some PDFs need external cmaps.
|
// Some PDFs need external cmaps.
|
||||||
//
|
//
|
||||||
|
@ -30,11 +30,9 @@
|
|||||||
// PDFJS.disableWorker = true;
|
// PDFJS.disableWorker = true;
|
||||||
|
|
||||||
//
|
//
|
||||||
// In cases when the pdf.worker.js is located at the different folder than the
|
// The workerSrc property shall be specified.
|
||||||
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
|
||||||
// shall be specified.
|
|
||||||
//
|
//
|
||||||
// PDFJS.workerSrc = '../../build/pdf.worker.js';
|
PDFJS.workerSrc = '../../build/pdf.worker.js';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Asynchronous download PDF
|
// Asynchronous download PDF
|
||||||
|
@ -40,11 +40,10 @@
|
|||||||
//
|
//
|
||||||
// PDFJS.disableWorker = true;
|
// PDFJS.disableWorker = true;
|
||||||
|
|
||||||
// In cases when the pdf.worker.js is located at the different folder than the
|
|
||||||
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
|
|
||||||
// shall be specified.
|
|
||||||
//
|
//
|
||||||
// PDFJS.workerSrc = '../../build/pdf.worker.js';
|
// The workerSrc property shall be specified.
|
||||||
|
//
|
||||||
|
PDFJS.workerSrc = '../../build/pdf.worker.js';
|
||||||
|
|
||||||
// Opening PDF by passing its binary data as a string. It is still preferable
|
// Opening PDF by passing its binary data as a string. It is still preferable
|
||||||
// to use Uint8Array, but string or array-like structure will work too.
|
// to use Uint8Array, but string or array-like structure will work too.
|
||||||
|
@ -18,6 +18,8 @@ var PAGE_NUMBER = 1;
|
|||||||
var PAGE_SCALE = 1.5;
|
var PAGE_SCALE = 1.5;
|
||||||
var SVG_NS = 'http://www.w3.org/2000/svg';
|
var SVG_NS = 'http://www.w3.org/2000/svg';
|
||||||
|
|
||||||
|
PDFJS.workerSrc = '../../build/pdf.worker.js';
|
||||||
|
|
||||||
function buildSVG(viewport, textContent) {
|
function buildSVG(viewport, textContent) {
|
||||||
// Building SVG with size of the viewport (for simplicity)
|
// Building SVG with size of the viewport (for simplicity)
|
||||||
var svg = document.createElementNS(SVG_NS, 'svg:svg');
|
var svg = document.createElementNS(SVG_NS, 'svg:svg');
|
||||||
|
@ -75,7 +75,9 @@ PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
|
|||||||
/**
|
/**
|
||||||
* Path and filename of the worker file. Required when the worker is enabled in
|
* Path and filename of the worker file. Required when the worker is enabled in
|
||||||
* development mode. If unspecified in the production build, the worker will be
|
* development mode. If unspecified in the production build, the worker will be
|
||||||
* loaded based on the location of the pdf.js file.
|
* loaded based on the location of the pdf.js file. It is recommended that
|
||||||
|
* the workerSrc is set in a custom application to prevent issues caused by
|
||||||
|
* third-party frameworks and libraries.
|
||||||
* @var {string}
|
* @var {string}
|
||||||
*/
|
*/
|
||||||
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
||||||
|
@ -42,10 +42,8 @@ if (!PDFJS.workerSrc && typeof document !== 'undefined') {
|
|||||||
// workerSrc is not set -- using last script url to define default location
|
// workerSrc is not set -- using last script url to define default location
|
||||||
PDFJS.workerSrc = (function () {
|
PDFJS.workerSrc = (function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
var scriptTagContainer = document.body ||
|
var pdfJsSrc = document.currentScript.src;
|
||||||
document.getElementsByTagName('head')[0];
|
return pdfJsSrc && pdfJsSrc.replace(/\.js$/i, '.worker.js');
|
||||||
var pdfjsSrc = scriptTagContainer.lastChild.src;
|
|
||||||
return pdfjsSrc && pdfjsSrc.replace(/\.js$/i, '.worker.js');
|
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
//#endif
|
//#endif
|
||||||
|
@ -577,3 +577,19 @@ if (typeof PDFJS === 'undefined') {
|
|||||||
PDFJS.disableFullscreen = true;
|
PDFJS.disableFullscreen = true;
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Provides document.currentScript support
|
||||||
|
// Support: IE, Chrome<29.
|
||||||
|
(function checkCurrentScript() {
|
||||||
|
if ('currentScript' in document) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object.defineProperty(document, 'currentScript', {
|
||||||
|
get: function () {
|
||||||
|
var scripts = document.getElementsByTagName('script');
|
||||||
|
return scripts[scripts.length - 1];
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user