Move the disableStream
option from the global PDFJS
object and into getDocument
instead
This commit is contained in:
parent
b69abf1111
commit
05c05bdef5
@ -169,6 +169,9 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
|||||||
* of PDF files. When enabled, and if the server supports partial content
|
* of PDF files. When enabled, and if the server supports partial content
|
||||||
* requests, then the PDF will be fetched in chunks.
|
* requests, then the PDF will be fetched in chunks.
|
||||||
* The default value is `false`.
|
* The default value is `false`.
|
||||||
|
* @property {boolean} disableStream - (optional) Disable streaming of PDF file
|
||||||
|
* data. By default PDF.js attempts to load PDFs in chunks.
|
||||||
|
* The default value is `false`.
|
||||||
* @property {boolean} disableAutoFetch - (optional) Disable pre-fetching of PDF
|
* @property {boolean} disableAutoFetch - (optional) Disable pre-fetching of PDF
|
||||||
* file data. When range requests are enabled PDF.js will automatically keep
|
* file data. When range requests are enabled PDF.js will automatically keep
|
||||||
* fetching more data even if it isn't needed to display the current page.
|
* fetching more data even if it isn't needed to display the current page.
|
||||||
@ -280,6 +283,9 @@ function getDocument(src) {
|
|||||||
if (typeof params.disableRange !== 'boolean') {
|
if (typeof params.disableRange !== 'boolean') {
|
||||||
params.disableRange = apiCompatibilityParams.disableRange || false;
|
params.disableRange = apiCompatibilityParams.disableRange || false;
|
||||||
}
|
}
|
||||||
|
if (typeof params.disableStream !== 'boolean') {
|
||||||
|
params.disableStream = apiCompatibilityParams.disableStream || false;
|
||||||
|
}
|
||||||
if (typeof params.disableAutoFetch !== 'boolean') {
|
if (typeof params.disableAutoFetch !== 'boolean') {
|
||||||
params.disableAutoFetch = false;
|
params.disableAutoFetch = false;
|
||||||
}
|
}
|
||||||
@ -350,7 +356,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
let apiVersion =
|
let apiVersion =
|
||||||
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
||||||
|
|
||||||
source.disableStream = getDefaultSetting('disableStream');
|
|
||||||
if (pdfDataRangeTransport) {
|
if (pdfDataRangeTransport) {
|
||||||
source.length = pdfDataRangeTransport.length;
|
source.length = pdfDataRangeTransport.length;
|
||||||
source.initialData = pdfDataRangeTransport.initialData;
|
source.initialData = pdfDataRangeTransport.initialData;
|
||||||
@ -2141,6 +2146,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
let params = this._params;
|
let params = this._params;
|
||||||
return shadow(this, 'loadingParams', {
|
return shadow(this, 'loadingParams', {
|
||||||
disableRange: params.disableRange,
|
disableRange: params.disableRange,
|
||||||
|
disableStream: params.disableStream,
|
||||||
disableAutoFetch: params.disableAutoFetch,
|
disableAutoFetch: params.disableAutoFetch,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -336,8 +336,6 @@ function getDefaultSetting(id) {
|
|||||||
switch (id) {
|
switch (id) {
|
||||||
case 'pdfBug':
|
case 'pdfBug':
|
||||||
return globalSettings ? globalSettings.pdfBug : false;
|
return globalSettings ? globalSettings.pdfBug : false;
|
||||||
case 'disableStream':
|
|
||||||
return globalSettings ? globalSettings.disableStream : false;
|
|
||||||
case 'disableCreateObjectURL':
|
case 'disableCreateObjectURL':
|
||||||
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||||
default:
|
default:
|
||||||
|
@ -65,14 +65,6 @@ PDFJS.Util = Util;
|
|||||||
PDFJS.PageViewport = PageViewport;
|
PDFJS.PageViewport = PageViewport;
|
||||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
|
||||||
* in chunks. This default behavior can be disabled.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
|
||||||
false : PDFJS.disableStream);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables special hooks for debugging PDF.js.
|
* Enables special hooks for debugging PDF.js.
|
||||||
* @var {boolean}
|
* @var {boolean}
|
||||||
|
@ -201,10 +201,10 @@ let PDFViewerApplication = {
|
|||||||
AppOptions.set('disableRange', value);
|
AppOptions.set('disableRange', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('disableStream').then(function resolved(value) {
|
preferences.get('disableStream').then(function resolved(value) {
|
||||||
if (PDFJS.disableStream === true) {
|
if (AppOptions.get('disableStream') === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFJS.disableStream = value;
|
AppOptions.set('disableStream', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('disableAutoFetch').then(function resolved(value) {
|
preferences.get('disableAutoFetch').then(function resolved(value) {
|
||||||
AppOptions.set('disableAutoFetch', value);
|
AppOptions.set('disableAutoFetch', value);
|
||||||
@ -263,7 +263,7 @@ let PDFViewerApplication = {
|
|||||||
AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
|
AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
|
||||||
}
|
}
|
||||||
if ('disablestream' in hashParams) {
|
if ('disablestream' in hashParams) {
|
||||||
PDFJS.disableStream = (hashParams['disablestream'] === 'true');
|
AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
|
||||||
}
|
}
|
||||||
if ('disableautofetch' in hashParams) {
|
if ('disableautofetch' in hashParams) {
|
||||||
AppOptions.set('disableAutoFetch',
|
AppOptions.set('disableAutoFetch',
|
||||||
|
@ -155,6 +155,11 @@ const defaultOptions = {
|
|||||||
value: apiCompatibilityParams.disableRange || false,
|
value: apiCompatibilityParams.disableRange || false,
|
||||||
kind: OptionKind.API,
|
kind: OptionKind.API,
|
||||||
},
|
},
|
||||||
|
disableStream: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: apiCompatibilityParams.disableStream || false,
|
||||||
|
kind: OptionKind.API,
|
||||||
|
},
|
||||||
isEvalSupported: {
|
isEvalSupported: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: true,
|
value: true,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user