Move the isEvalSupported option from the global PDFJS object and into getDocument instead

This commit is contained in:
Jonas Jenwald 2018-02-17 21:49:14 +01:00
parent 3c2fbdffe6
commit f3900c4e57
5 changed files with 27 additions and 31 deletions

View file

@ -157,6 +157,9 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
* @property {number} maxImageSize - (optional) The maximum allowed image size
* in total pixels, i.e. width * height. Images above this value will not be
* rendered. Use -1 for no limit, which is also the default value.
* @property {boolean} isEvalSupported - (optional) Determines if we can eval
* strings as JS. Primarily used to improve performance of font rendering,
* and when parsing PDF functions. The default value is `true`.
*/
/**
@ -252,6 +255,9 @@ function getDocument(src) {
if (!Number.isInteger(params.maxImageSize)) {
params.maxImageSize = -1;
}
if (typeof params.isEvalSupported !== 'boolean') {
params.isEvalSupported = true;
}
// Set the main-thread verbosity level.
setVerbosityLevel(params.verbosity);
@ -344,7 +350,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
docBaseUrl: source.docBaseUrl,
nativeImageDecoderSupport: source.nativeImageDecoderSupport,
ignoreErrors: source.ignoreErrors,
isEvalSupported: getDefaultSetting('isEvalSupported'),
isEvalSupported: source.isEvalSupported,
}).then(function (workerId) {
if (worker.destroyed) {
throw new Error('Worker was destroyed');
@ -1806,6 +1812,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
switch (type) {
case 'Font':
var exportedData = data[2];
let params = this._params;
if ('error' in exportedData) {
var exportedError = exportedData.error;
@ -1823,7 +1830,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
};
}
var font = new FontFaceObject(exportedData, {
isEvalSupported: getDefaultSetting('isEvalSupported'),
isEvalSupported: params.isEvalSupported,
disableFontFace: getDefaultSetting('disableFontFace'),
fontRegistry,
});