mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Move the maxImageSize
option from the global PDFJS
object and into getDocument
instead
This commit is contained in:
parent
b0956a5d91
commit
b674409397
6 changed files with 21 additions and 17 deletions
|
@ -614,7 +614,7 @@ var WorkerMessageHandler = {
|
|||
|
||||
var evaluatorOptions = {
|
||||
forceDataSchema: data.disableCreateObjectURL,
|
||||
maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
|
||||
maxImageSize: data.maxImageSize,
|
||||
disableFontFace: data.disableFontFace,
|
||||
nativeImageDecoderSupport: data.nativeImageDecoderSupport,
|
||||
ignoreErrors: data.ignoreErrors,
|
||||
|
|
|
@ -150,6 +150,9 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
|||
* `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated
|
||||
* PDF data cannot be successfully parsed, instead of attempting to recover
|
||||
* whatever possible of the data. The default value is `false`.
|
||||
* @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.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -195,7 +198,7 @@ function getDocument(src) {
|
|||
source = src;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
let params = Object.create(null);
|
||||
var rangeTransport = null;
|
||||
let worker = null;
|
||||
var CMapReaderFactory = DOMCMapReaderFactory;
|
||||
|
@ -237,11 +240,14 @@ function getDocument(src) {
|
|||
params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
|
||||
params.ignoreErrors = params.stopAtErrors !== true;
|
||||
|
||||
const nativeImageDecoderValues = Object.values(NativeImageDecoding);
|
||||
const NativeImageDecoderValues = Object.values(NativeImageDecoding);
|
||||
if (params.nativeImageDecoderSupport === undefined ||
|
||||
!nativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
||||
!NativeImageDecoderValues.includes(params.nativeImageDecoderSupport)) {
|
||||
params.nativeImageDecoderSupport = NativeImageDecoding.DECODE;
|
||||
}
|
||||
if (!Number.isInteger(params.maxImageSize)) {
|
||||
params.maxImageSize = -1;
|
||||
}
|
||||
|
||||
// Set the main-thread verbosity level.
|
||||
setVerbosityLevel(params.verbosity);
|
||||
|
@ -327,7 +333,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||
rangeChunkSize: source.rangeChunkSize,
|
||||
length: source.length,
|
||||
},
|
||||
maxImageSize: getDefaultSetting('maxImageSize'),
|
||||
maxImageSize: source.maxImageSize,
|
||||
disableFontFace: getDefaultSetting('disableFontFace'),
|
||||
disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
|
||||
postMessageTransfers: worker.postMessageTransfers,
|
||||
|
|
|
@ -349,8 +349,6 @@ function getDefaultSetting(id) {
|
|||
return globalSettings ? globalSettings.cMapUrl : null;
|
||||
case 'cMapPacked':
|
||||
return globalSettings ? globalSettings.cMapPacked : false;
|
||||
case 'maxImageSize':
|
||||
return globalSettings ? globalSettings.maxImageSize : -1;
|
||||
case 'isEvalSupported':
|
||||
return globalSettings ? globalSettings.isEvalSupported : true;
|
||||
default:
|
||||
|
|
|
@ -65,14 +65,6 @@ PDFJS.Util = Util;
|
|||
PDFJS.PageViewport = PageViewport;
|
||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||
|
||||
/**
|
||||
* The maximum allowed image size in total pixels e.g. width * height. Images
|
||||
* above this value will not be drawn. Use -1 for no limit.
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
|
||||
-1 : PDFJS.maxImageSize);
|
||||
|
||||
/**
|
||||
* The url of where the predefined Adobe CMaps are located. Include trailing
|
||||
* slash.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue