Move the disableRange
option from the global PDFJS
object and into getDocument
instead
This commit is contained in:
parent
69d7191034
commit
b69abf1111
@ -26,6 +26,7 @@ import {
|
||||
RenderingCancelledException, StatTimer
|
||||
} from './dom_utils';
|
||||
import { FontFaceObject, FontLoader } from './font_loader';
|
||||
import { apiCompatibilityParams } from './api_compatibility';
|
||||
import { CanvasGraphics } from './canvas';
|
||||
import globalScope from '../shared/global_scope';
|
||||
import { GlobalWorkerOptions } from './worker_options';
|
||||
@ -164,6 +165,10 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
||||
* converted to OpenType fonts and loaded via font face rules. If disabled,
|
||||
* fonts will be rendered using a built-in font renderer that constructs the
|
||||
* glyphs with primitive path commands. The default value is `false`.
|
||||
* @property {boolean} disableRange - (optional) Disable range request loading
|
||||
* 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} 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.
|
||||
@ -272,6 +277,9 @@ function getDocument(src) {
|
||||
params.disableFontFace = false;
|
||||
}
|
||||
|
||||
if (typeof params.disableRange !== 'boolean') {
|
||||
params.disableRange = apiCompatibilityParams.disableRange || false;
|
||||
}
|
||||
if (typeof params.disableAutoFetch !== 'boolean') {
|
||||
params.disableAutoFetch = false;
|
||||
}
|
||||
@ -342,7 +350,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
let apiVersion =
|
||||
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
||||
|
||||
source.disableRange = getDefaultSetting('disableRange');
|
||||
source.disableStream = getDefaultSetting('disableStream');
|
||||
if (pdfDataRangeTransport) {
|
||||
source.length = pdfDataRangeTransport.length;
|
||||
@ -2133,6 +2140,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
||||
get loadingParams() {
|
||||
let params = this._params;
|
||||
return shadow(this, 'loadingParams', {
|
||||
disableRange: params.disableRange,
|
||||
disableAutoFetch: params.disableAutoFetch,
|
||||
});
|
||||
},
|
||||
|
@ -338,8 +338,6 @@ function getDefaultSetting(id) {
|
||||
return globalSettings ? globalSettings.pdfBug : false;
|
||||
case 'disableStream':
|
||||
return globalSettings ? globalSettings.disableStream : false;
|
||||
case 'disableRange':
|
||||
return globalSettings ? globalSettings.disableRange : false;
|
||||
case 'disableCreateObjectURL':
|
||||
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||
default:
|
||||
|
@ -65,15 +65,6 @@ PDFJS.Util = Util;
|
||||
PDFJS.PageViewport = PageViewport;
|
||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||
|
||||
/**
|
||||
* Disable range request loading of PDF files. When enabled and if the server
|
||||
* supports partial content requests then the PDF will be fetched in chunks.
|
||||
* Enabled (false) by default.
|
||||
* @var {boolean}
|
||||
*/
|
||||
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
||||
false : PDFJS.disableRange);
|
||||
|
||||
/**
|
||||
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
||||
* in chunks. This default behavior can be disabled.
|
||||
|
@ -359,7 +359,6 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
|
||||
this._log('Loading file "' + task.file + '"\n');
|
||||
|
||||
let absoluteUrl = new URL(task.file, window.location).href;
|
||||
PDFJS.disableRange = task.disableRange;
|
||||
try {
|
||||
PDFJS.getDocument({
|
||||
url: absoluteUrl,
|
||||
@ -367,6 +366,7 @@ var Driver = (function DriverClosure() { // eslint-disable-line no-unused-vars
|
||||
nativeImageDecoderSupport: task.nativeImageDecoderSupport,
|
||||
cMapUrl: CMAP_URL,
|
||||
cMapPacked: CMAP_PACKED,
|
||||
disableRange: task.disableRange,
|
||||
disableAutoFetch: !task.enableAutoFetch,
|
||||
}).then((doc) => {
|
||||
task.pdfDoc = doc;
|
||||
|
@ -195,10 +195,10 @@ let PDFViewerApplication = {
|
||||
AppOptions.set('textLayerMode', value);
|
||||
}),
|
||||
preferences.get('disableRange').then(function resolved(value) {
|
||||
if (PDFJS.disableRange === true) {
|
||||
if (AppOptions.get('disableRange') === true) {
|
||||
return;
|
||||
}
|
||||
PDFJS.disableRange = value;
|
||||
AppOptions.set('disableRange', value);
|
||||
}),
|
||||
preferences.get('disableStream').then(function resolved(value) {
|
||||
if (PDFJS.disableStream === true) {
|
||||
@ -260,7 +260,7 @@ let PDFViewerApplication = {
|
||||
waitOn.push(loadFakeWorker());
|
||||
}
|
||||
if ('disablerange' in hashParams) {
|
||||
PDFJS.disableRange = (hashParams['disablerange'] === 'true');
|
||||
AppOptions.set('disableRange', hashParams['disablerange'] === 'true');
|
||||
}
|
||||
if ('disablestream' in hashParams) {
|
||||
PDFJS.disableStream = (hashParams['disablestream'] === 'true');
|
||||
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { apiCompatibilityParams } from 'pdfjs-lib';
|
||||
import { viewerCompatibilityParams } from './viewer_compatibility';
|
||||
|
||||
const OptionKind = {
|
||||
@ -149,6 +150,11 @@ const defaultOptions = {
|
||||
value: false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
disableRange: {
|
||||
/** @type {boolean} */
|
||||
value: apiCompatibilityParams.disableRange || false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
isEvalSupported: {
|
||||
/** @type {boolean} */
|
||||
value: true,
|
||||
|
Loading…
Reference in New Issue
Block a user