1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

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

This commit is contained in:
Jonas Jenwald 2018-02-17 22:22:10 +01:00
parent 69d7191034
commit b69abf1111
6 changed files with 19 additions and 16 deletions

View file

@ -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,
});
},

View file

@ -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:

View file

@ -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.