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
|
||||
* requests, then the PDF will be fetched in chunks.
|
||||
* 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
|
||||
* 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.
|
||||
@ -280,6 +283,9 @@ function getDocument(src) {
|
||||
if (typeof params.disableRange !== 'boolean') {
|
||||
params.disableRange = apiCompatibilityParams.disableRange || false;
|
||||
}
|
||||
if (typeof params.disableStream !== 'boolean') {
|
||||
params.disableStream = apiCompatibilityParams.disableStream || false;
|
||||
}
|
||||
if (typeof params.disableAutoFetch !== 'boolean') {
|
||||
params.disableAutoFetch = false;
|
||||
}
|
||||
@ -350,7 +356,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
let apiVersion =
|
||||
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
||||
|
||||
source.disableStream = getDefaultSetting('disableStream');
|
||||
if (pdfDataRangeTransport) {
|
||||
source.length = pdfDataRangeTransport.length;
|
||||
source.initialData = pdfDataRangeTransport.initialData;
|
||||
@ -2141,6 +2146,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
let params = this._params;
|
||||
return shadow(this, 'loadingParams', {
|
||||
disableRange: params.disableRange,
|
||||
disableStream: params.disableStream,
|
||||
disableAutoFetch: params.disableAutoFetch,
|
||||
});
|
||||
},
|
||||
|
@ -336,8 +336,6 @@ function getDefaultSetting(id) {
|
||||
switch (id) {
|
||||
case 'pdfBug':
|
||||
return globalSettings ? globalSettings.pdfBug : false;
|
||||
case 'disableStream':
|
||||
return globalSettings ? globalSettings.disableStream : false;
|
||||
case 'disableCreateObjectURL':
|
||||
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||
default:
|
||||
|
@ -65,14 +65,6 @@ PDFJS.Util = Util;
|
||||
PDFJS.PageViewport = PageViewport;
|
||||
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.
|
||||
* @var {boolean}
|
||||
|
@ -201,10 +201,10 @@ let PDFViewerApplication = {
|
||||
AppOptions.set('disableRange', value);
|
||||
}),
|
||||
preferences.get('disableStream').then(function resolved(value) {
|
||||
if (PDFJS.disableStream === true) {
|
||||
if (AppOptions.get('disableStream') === true) {
|
||||
return;
|
||||
}
|
||||
PDFJS.disableStream = value;
|
||||
AppOptions.set('disableStream', value);
|
||||
}),
|
||||
preferences.get('disableAutoFetch').then(function resolved(value) {
|
||||
AppOptions.set('disableAutoFetch', value);
|
||||
@ -263,7 +263,7 @@ let PDFViewerApplication = {
|
||||
AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
|
||||
}
|
||||
if ('disablestream' in hashParams) {
|
||||
PDFJS.disableStream = (hashParams['disablestream'] === 'true');
|
||||
AppOptions.set('disableStream', hashParams['disablestream'] === 'true');
|
||||
}
|
||||
if ('disableautofetch' in hashParams) {
|
||||
AppOptions.set('disableAutoFetch',
|
||||
|
@ -155,6 +155,11 @@ const defaultOptions = {
|
||||
value: apiCompatibilityParams.disableRange || false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
disableStream: {
|
||||
/** @type {boolean} */
|
||||
value: apiCompatibilityParams.disableStream || false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
isEvalSupported: {
|
||||
/** @type {boolean} */
|
||||
value: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user