Move various viewer components options from PDFJS
/PDFViewerApplication.viewerPrefs
and into AppOptions
instead
This commit is contained in:
parent
09da99b8a0
commit
81c550903f
@ -19,11 +19,11 @@ import {
|
|||||||
PasswordResponses, removeNullCharacters, shadow, UnexpectedResponseException,
|
PasswordResponses, removeNullCharacters, shadow, UnexpectedResponseException,
|
||||||
UnknownErrorException, UNSUPPORTED_FEATURES, Util
|
UnknownErrorException, UNSUPPORTED_FEATURES, Util
|
||||||
} from '../shared/util';
|
} from '../shared/util';
|
||||||
import { DEFAULT_LINK_REL, getFilenameFromUrl, LinkTarget } from './dom_utils';
|
|
||||||
import {
|
import {
|
||||||
getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker
|
getDocument, LoopbackPort, PDFDataRangeTransport, PDFWorker
|
||||||
} from './api';
|
} from './api';
|
||||||
import { AnnotationLayer } from './annotation_layer';
|
import { AnnotationLayer } from './annotation_layer';
|
||||||
|
import { getFilenameFromUrl } from './dom_utils';
|
||||||
import globalScope from '../shared/global_scope';
|
import globalScope from '../shared/global_scope';
|
||||||
import { GlobalWorkerOptions } from './worker_options';
|
import { GlobalWorkerOptions } from './worker_options';
|
||||||
import { Metadata } from './metadata';
|
import { Metadata } from './metadata';
|
||||||
@ -137,27 +137,6 @@ PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
|
|||||||
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
||||||
false : PDFJS.disableCreateObjectURL);
|
false : PDFJS.disableCreateObjectURL);
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the |target| attribute for external links.
|
|
||||||
* The constants from {LinkTarget} should be used:
|
|
||||||
* - NONE [default]
|
|
||||||
* - SELF
|
|
||||||
* - BLANK
|
|
||||||
* - PARENT
|
|
||||||
* - TOP
|
|
||||||
* @var {number}
|
|
||||||
*/
|
|
||||||
PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ?
|
|
||||||
LinkTarget.NONE : PDFJS.externalLinkTarget);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the |rel| attribute for external links. Defaults to stripping
|
|
||||||
* the referrer.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
|
|
||||||
DEFAULT_LINK_REL : PDFJS.externalLinkRel);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if we can eval strings as JS. Primarily used to improve
|
* Determines if we can eval strings as JS. Primarily used to improve
|
||||||
* performance for font rendering.
|
* performance for font rendering.
|
||||||
|
116
web/app.js
116
web/app.js
@ -28,6 +28,7 @@ import {
|
|||||||
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
import { CursorTool, PDFCursorTools } from './pdf_cursor_tools';
|
||||||
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
import { PDFRenderingQueue, RenderingStates } from './pdf_rendering_queue';
|
||||||
import { PDFSidebar, SidebarView } from './pdf_sidebar';
|
import { PDFSidebar, SidebarView } from './pdf_sidebar';
|
||||||
|
import { AppOptions } from './app_options';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
import { getGlobalEventBus } from './dom_events';
|
||||||
import { OverlayManager } from './overlay_manager';
|
import { OverlayManager } from './overlay_manager';
|
||||||
import { PasswordPrompt } from './password_prompt';
|
import { PasswordPrompt } from './password_prompt';
|
||||||
@ -44,14 +45,12 @@ import { PDFThumbnailViewer } from './pdf_thumbnail_viewer';
|
|||||||
import { PDFViewer } from './pdf_viewer';
|
import { PDFViewer } from './pdf_viewer';
|
||||||
import { SecondaryToolbar } from './secondary_toolbar';
|
import { SecondaryToolbar } from './secondary_toolbar';
|
||||||
import { Toolbar } from './toolbar';
|
import { Toolbar } from './toolbar';
|
||||||
import { viewerCompatibilityParams } from './viewer_compatibility';
|
|
||||||
import { ViewHistory } from './view_history';
|
import { ViewHistory } from './view_history';
|
||||||
|
|
||||||
const DEFAULT_SCALE_DELTA = 1.1;
|
const DEFAULT_SCALE_DELTA = 1.1;
|
||||||
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
const DISABLE_AUTO_FETCH_LOADING_BAR_TIMEOUT = 5000;
|
||||||
|
|
||||||
function configure(PDFJS) {
|
function configure(PDFJS) {
|
||||||
PDFJS.imageResourcesPath = './images/';
|
|
||||||
if (typeof PDFJSDev !== 'undefined' &&
|
if (typeof PDFJSDev !== 'undefined' &&
|
||||||
PDFJSDev.test('FIREFOX || MOZCENTRAL || GENERIC || CHROME')) {
|
PDFJSDev.test('FIREFOX || MOZCENTRAL || GENERIC || CHROME')) {
|
||||||
GlobalWorkerOptions.workerSrc = '../build/pdf.worker.js';
|
GlobalWorkerOptions.workerSrc = '../build/pdf.worker.js';
|
||||||
@ -76,7 +75,7 @@ const DefaultExternalServices = {
|
|||||||
createPreferences() {
|
createPreferences() {
|
||||||
throw new Error('Not implemented: createPreferences');
|
throw new Error('Not implemented: createPreferences');
|
||||||
},
|
},
|
||||||
createL10n() {
|
createL10n(options) {
|
||||||
throw new Error('Not implemented: createL10n');
|
throw new Error('Not implemented: createL10n');
|
||||||
},
|
},
|
||||||
supportsIntegratedFind: false,
|
supportsIntegratedFind: false,
|
||||||
@ -138,19 +137,6 @@ let PDFViewerApplication = {
|
|||||||
l10n: null,
|
l10n: null,
|
||||||
isInitialViewSet: false,
|
isInitialViewSet: false,
|
||||||
downloadComplete: false,
|
downloadComplete: false,
|
||||||
viewerPrefs: {
|
|
||||||
enableWebGL: false,
|
|
||||||
sidebarViewOnLoad: SidebarView.NONE,
|
|
||||||
pdfBugEnabled: false,
|
|
||||||
showPreviousViewOnLoad: true,
|
|
||||||
defaultZoomValue: '',
|
|
||||||
disablePageMode: false,
|
|
||||||
disablePageLabels: false,
|
|
||||||
renderer: 'canvas',
|
|
||||||
textLayerMode: TextLayerMode.ENABLE,
|
|
||||||
renderInteractiveForms: false,
|
|
||||||
enablePrintAutoRotate: false,
|
|
||||||
},
|
|
||||||
isViewerEmbedded: (window.parent !== window),
|
isViewerEmbedded: (window.parent !== window),
|
||||||
url: '',
|
url: '',
|
||||||
baseUrl: '',
|
baseUrl: '',
|
||||||
@ -186,10 +172,10 @@ let PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (this.isViewerEmbedded &&
|
if (this.isViewerEmbedded &&
|
||||||
PDFJS.externalLinkTarget === LinkTarget.NONE) {
|
AppOptions.get('externalLinkTarget') === LinkTarget.NONE) {
|
||||||
// Prevent external links from "replacing" the viewer,
|
// Prevent external links from "replacing" the viewer,
|
||||||
// when it's embedded in e.g. an iframe or an object.
|
// when it's embedded in e.g. an iframe or an object.
|
||||||
PDFJS.externalLinkTarget = LinkTarget.TOP;
|
AppOptions.set('externalLinkTarget', LinkTarget.TOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
@ -200,29 +186,29 @@ let PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_readPreferences() {
|
_readPreferences() {
|
||||||
let { preferences, viewerPrefs, } = this;
|
let { preferences, } = this;
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
preferences.get('enableWebGL').then(function resolved(value) {
|
preferences.get('enableWebGL').then(function resolved(value) {
|
||||||
viewerPrefs['enableWebGL'] = value;
|
AppOptions.set('enableWebGL', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('sidebarViewOnLoad').then(function resolved(value) {
|
preferences.get('sidebarViewOnLoad').then(function resolved(value) {
|
||||||
viewerPrefs['sidebarViewOnLoad'] = value;
|
AppOptions.set('sidebarViewOnLoad', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('pdfBugEnabled').then(function resolved(value) {
|
preferences.get('pdfBugEnabled').then(function resolved(value) {
|
||||||
viewerPrefs['pdfBugEnabled'] = value;
|
AppOptions.set('pdfBugEnabled', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
|
preferences.get('showPreviousViewOnLoad').then(function resolved(value) {
|
||||||
viewerPrefs['showPreviousViewOnLoad'] = value;
|
AppOptions.set('showPreviousViewOnLoad', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('defaultZoomValue').then(function resolved(value) {
|
preferences.get('defaultZoomValue').then(function resolved(value) {
|
||||||
viewerPrefs['defaultZoomValue'] = value;
|
AppOptions.set('defaultZoomValue', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('textLayerMode').then(function resolved(value) {
|
preferences.get('textLayerMode').then(function resolved(value) {
|
||||||
if (viewerPrefs['textLayerMode'] === TextLayerMode.DISABLE) {
|
if (AppOptions.get('textLayerMode') === TextLayerMode.DISABLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
viewerPrefs['textLayerMode'] = value;
|
AppOptions.set('textLayerMode', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('disableRange').then(function resolved(value) {
|
preferences.get('disableRange').then(function resolved(value) {
|
||||||
if (PDFJS.disableRange === true) {
|
if (PDFJS.disableRange === true) {
|
||||||
@ -246,28 +232,28 @@ let PDFViewerApplication = {
|
|||||||
PDFJS.disableFontFace = value;
|
PDFJS.disableFontFace = value;
|
||||||
}),
|
}),
|
||||||
preferences.get('useOnlyCssZoom').then(function resolved(value) {
|
preferences.get('useOnlyCssZoom').then(function resolved(value) {
|
||||||
PDFJS.useOnlyCssZoom = value;
|
AppOptions.set('useOnlyCssZoom', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('externalLinkTarget').then(function resolved(value) {
|
preferences.get('externalLinkTarget').then(function resolved(value) {
|
||||||
if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
|
if (AppOptions.get('externalLinkTarget') !== LinkTarget.NONE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PDFJS.externalLinkTarget = value;
|
AppOptions.set('externalLinkTarget', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('renderer').then(function resolved(value) {
|
preferences.get('renderer').then(function resolved(value) {
|
||||||
viewerPrefs['renderer'] = value;
|
AppOptions.set('renderer', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('renderInteractiveForms').then(function resolved(value) {
|
preferences.get('renderInteractiveForms').then(function resolved(value) {
|
||||||
viewerPrefs['renderInteractiveForms'] = value;
|
AppOptions.set('renderInteractiveForms', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('disablePageMode').then(function resolved(value) {
|
preferences.get('disablePageMode').then(function resolved(value) {
|
||||||
viewerPrefs['disablePageMode'] = value;
|
AppOptions.set('disablePageMode', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('disablePageLabels').then(function resolved(value) {
|
preferences.get('disablePageLabels').then(function resolved(value) {
|
||||||
viewerPrefs['disablePageLabels'] = value;
|
AppOptions.set('disablePageLabels', value);
|
||||||
}),
|
}),
|
||||||
preferences.get('enablePrintAutoRotate').then(function resolved(value) {
|
preferences.get('enablePrintAutoRotate').then(function resolved(value) {
|
||||||
viewerPrefs['enablePrintAutoRotate'] = value;
|
AppOptions.set('enablePrintAutoRotate', value);
|
||||||
}),
|
}),
|
||||||
]).catch(function(reason) { });
|
]).catch(function(reason) { });
|
||||||
},
|
},
|
||||||
@ -276,11 +262,11 @@ let PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_parseHashParameters() {
|
_parseHashParameters() {
|
||||||
let { appConfig, viewerPrefs, } = this;
|
let { appConfig, } = this;
|
||||||
let waitOn = [];
|
let waitOn = [];
|
||||||
|
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ||
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ||
|
||||||
viewerPrefs['pdfBugEnabled']) {
|
AppOptions.get('pdfBugEnabled')) {
|
||||||
// Special debugging flags in the hash section of the URL.
|
// Special debugging flags in the hash section of the URL.
|
||||||
let hash = document.location.hash.substring(1);
|
let hash = document.location.hash.substring(1);
|
||||||
let hashParams = parseQueryString(hash);
|
let hashParams = parseQueryString(hash);
|
||||||
@ -302,13 +288,15 @@ let PDFViewerApplication = {
|
|||||||
PDFJS.disableFontFace = (hashParams['disablefontface'] === 'true');
|
PDFJS.disableFontFace = (hashParams['disablefontface'] === 'true');
|
||||||
}
|
}
|
||||||
if ('disablehistory' in hashParams) {
|
if ('disablehistory' in hashParams) {
|
||||||
PDFJS.disableHistory = (hashParams['disablehistory'] === 'true');
|
AppOptions.set('disableHistory',
|
||||||
|
hashParams['disablehistory'] === 'true');
|
||||||
}
|
}
|
||||||
if ('webgl' in hashParams) {
|
if ('webgl' in hashParams) {
|
||||||
viewerPrefs['enableWebGL'] = (hashParams['webgl'] === 'true');
|
AppOptions.set('enableWebGL', hashParams['webgl'] === 'true');
|
||||||
}
|
}
|
||||||
if ('useonlycsszoom' in hashParams) {
|
if ('useonlycsszoom' in hashParams) {
|
||||||
PDFJS.useOnlyCssZoom = (hashParams['useonlycsszoom'] === 'true');
|
AppOptions.set('useOnlyCssZoom',
|
||||||
|
hashParams['useonlycsszoom'] === 'true');
|
||||||
}
|
}
|
||||||
if ('verbosity' in hashParams) {
|
if ('verbosity' in hashParams) {
|
||||||
PDFJS.verbosity = hashParams['verbosity'] | 0;
|
PDFJS.verbosity = hashParams['verbosity'] | 0;
|
||||||
@ -321,7 +309,7 @@ let PDFViewerApplication = {
|
|||||||
if ('textlayer' in hashParams) {
|
if ('textlayer' in hashParams) {
|
||||||
switch (hashParams['textlayer']) {
|
switch (hashParams['textlayer']) {
|
||||||
case 'off':
|
case 'off':
|
||||||
viewerPrefs['textLayerMode'] = TextLayerMode.DISABLE;
|
AppOptions.set('textLayerMode', TextLayerMode.DISABLE);
|
||||||
break;
|
break;
|
||||||
case 'visible':
|
case 'visible':
|
||||||
case 'shadow':
|
case 'shadow':
|
||||||
@ -341,7 +329,7 @@ let PDFViewerApplication = {
|
|||||||
// It is not possible to change locale for Firefox extension builds.
|
// It is not possible to change locale for Firefox extension builds.
|
||||||
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ||
|
if ((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') ||
|
||||||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) && 'locale' in hashParams) {
|
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) && 'locale' in hashParams) {
|
||||||
PDFJS.locale = hashParams['locale'];
|
AppOptions.set('locale', hashParams['locale']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +341,7 @@ let PDFViewerApplication = {
|
|||||||
*/
|
*/
|
||||||
_initializeL10n() {
|
_initializeL10n() {
|
||||||
this.l10n = this.externalServices.createL10n({
|
this.l10n = this.externalServices.createL10n({
|
||||||
locale: PDFJS.locale,
|
locale: AppOptions.get('locale'),
|
||||||
});
|
});
|
||||||
return this.l10n.getDirection().then((dir) => {
|
return this.l10n.getDirection().then((dir) => {
|
||||||
document.getElementsByTagName('html')[0].dir = dir;
|
document.getElementsByTagName('html')[0].dir = dir;
|
||||||
@ -364,7 +352,7 @@ let PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_initializeViewerComponents() {
|
_initializeViewerComponents() {
|
||||||
let { appConfig, viewerPrefs, } = this;
|
let { appConfig, } = this;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.overlayManager = new OverlayManager();
|
this.overlayManager = new OverlayManager();
|
||||||
@ -378,8 +366,8 @@ let PDFViewerApplication = {
|
|||||||
|
|
||||||
let pdfLinkService = new PDFLinkService({
|
let pdfLinkService = new PDFLinkService({
|
||||||
eventBus,
|
eventBus,
|
||||||
externalLinkTarget: PDFJS.externalLinkTarget,
|
externalLinkTarget: AppOptions.get('externalLinkTarget'),
|
||||||
externalLinkRel: PDFJS.externalLinkRel,
|
externalLinkRel: AppOptions.get('externalLinkRel'),
|
||||||
});
|
});
|
||||||
this.pdfLinkService = pdfLinkService;
|
this.pdfLinkService = pdfLinkService;
|
||||||
|
|
||||||
@ -395,15 +383,15 @@ let PDFViewerApplication = {
|
|||||||
renderingQueue: pdfRenderingQueue,
|
renderingQueue: pdfRenderingQueue,
|
||||||
linkService: pdfLinkService,
|
linkService: pdfLinkService,
|
||||||
downloadManager,
|
downloadManager,
|
||||||
renderer: viewerPrefs['renderer'],
|
renderer: AppOptions.get('renderer'),
|
||||||
enableWebGL: viewerPrefs['enableWebGL'],
|
enableWebGL: AppOptions.get('enableWebGL'),
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
textLayerMode: viewerPrefs['textLayerMode'],
|
textLayerMode: AppOptions.get('textLayerMode'),
|
||||||
imageResourcesPath: PDFJS.imageResourcesPath,
|
imageResourcesPath: AppOptions.get('imageResourcesPath'),
|
||||||
renderInteractiveForms: viewerPrefs['renderInteractiveForms'],
|
renderInteractiveForms: AppOptions.get('renderInteractiveForms'),
|
||||||
enablePrintAutoRotate: viewerPrefs['enablePrintAutoRotate'],
|
enablePrintAutoRotate: AppOptions.get('enablePrintAutoRotate'),
|
||||||
useOnlyCssZoom: PDFJS.useOnlyCssZoom,
|
useOnlyCssZoom: AppOptions.get('useOnlyCssZoom'),
|
||||||
maxCanvasPixels: PDFJS.maxCanvasPixels,
|
maxCanvasPixels: AppOptions.get('maxCanvasPixels'),
|
||||||
});
|
});
|
||||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||||
pdfLinkService.setViewer(this.pdfViewer);
|
pdfLinkService.setViewer(this.pdfViewer);
|
||||||
@ -568,7 +556,7 @@ let PDFViewerApplication = {
|
|||||||
support = false;
|
support = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (support && viewerCompatibilityParams['disableFullscreen'] === true) {
|
if (support && AppOptions.get('disableFullscreen') === true) {
|
||||||
support = false;
|
support = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1013,10 +1001,10 @@ let PDFViewerApplication = {
|
|||||||
firstPagePromise.then((pdfPage) => {
|
firstPagePromise.then((pdfPage) => {
|
||||||
this.loadingBar.setWidth(this.appConfig.viewerContainer);
|
this.loadingBar.setWidth(this.appConfig.viewerContainer);
|
||||||
|
|
||||||
if (!PDFJS.disableHistory && !this.isViewerEmbedded) {
|
if (!AppOptions.get('disableHistory') && !this.isViewerEmbedded) {
|
||||||
// The browsing history is only enabled when the viewer is standalone,
|
// The browsing history is only enabled when the viewer is standalone,
|
||||||
// i.e. not when it is embedded in a web page.
|
// i.e. not when it is embedded in a web page.
|
||||||
let resetHistory = !this.viewerPrefs['showPreviousViewOnLoad'];
|
let resetHistory = !AppOptions.get('showPreviousViewOnLoad');
|
||||||
this.pdfHistory.initialize(id, resetHistory);
|
this.pdfHistory.initialize(id, resetHistory);
|
||||||
|
|
||||||
if (this.pdfHistory.initialBookmark) {
|
if (this.pdfHistory.initialBookmark) {
|
||||||
@ -1043,19 +1031,19 @@ let PDFViewerApplication = {
|
|||||||
Promise.all([storePromise, pageModePromise]).then(
|
Promise.all([storePromise, pageModePromise]).then(
|
||||||
([values = {}, pageMode]) => {
|
([values = {}, pageMode]) => {
|
||||||
// Initialize the default values, from user preferences.
|
// Initialize the default values, from user preferences.
|
||||||
let hash = this.viewerPrefs['defaultZoomValue'] ?
|
let hash = AppOptions.get('defaultZoomValue') ?
|
||||||
('zoom=' + this.viewerPrefs['defaultZoomValue']) : null;
|
('zoom=' + AppOptions.get('defaultZoomValue')) : null;
|
||||||
let rotation = null;
|
let rotation = null;
|
||||||
let sidebarView = this.viewerPrefs['sidebarViewOnLoad'];
|
let sidebarView = AppOptions.get('sidebarViewOnLoad');
|
||||||
|
|
||||||
if (values.exists && this.viewerPrefs['showPreviousViewOnLoad']) {
|
if (values.exists && AppOptions.get('showPreviousViewOnLoad')) {
|
||||||
hash = 'page=' + values.page +
|
hash = 'page=' + values.page +
|
||||||
'&zoom=' + (this.viewerPrefs['defaultZoomValue'] || values.zoom) +
|
'&zoom=' + (AppOptions.get('defaultZoomValue') || values.zoom) +
|
||||||
',' + values.scrollLeft + ',' + values.scrollTop;
|
',' + values.scrollLeft + ',' + values.scrollTop;
|
||||||
rotation = parseInt(values.rotation, 10);
|
rotation = parseInt(values.rotation, 10);
|
||||||
sidebarView = sidebarView || (values.sidebarView | 0);
|
sidebarView = sidebarView || (values.sidebarView | 0);
|
||||||
}
|
}
|
||||||
if (pageMode && !this.viewerPrefs['disablePageMode']) {
|
if (pageMode && !AppOptions.get('disablePageMode')) {
|
||||||
// Always let the user preference/history take precedence.
|
// Always let the user preference/history take precedence.
|
||||||
sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
|
sidebarView = sidebarView || apiPageModeToSidebarView(pageMode);
|
||||||
}
|
}
|
||||||
@ -1099,7 +1087,7 @@ let PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
|
|
||||||
pdfDocument.getPageLabels().then((labels) => {
|
pdfDocument.getPageLabels().then((labels) => {
|
||||||
if (!labels || this.viewerPrefs['disablePageLabels']) {
|
if (!labels || AppOptions.get('disablePageLabels')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let i = 0, numLabels = labels.length;
|
let i = 0, numLabels = labels.length;
|
||||||
@ -1177,7 +1165,7 @@ let PDFViewerApplication = {
|
|||||||
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
|
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
|
||||||
' / ' + (info.Creator || '-').trim() + ']' +
|
' / ' + (info.Creator || '-').trim() + ']' +
|
||||||
' (PDF.js: ' + (version || '-') +
|
' (PDF.js: ' + (version || '-') +
|
||||||
(this.viewerPrefs['enableWebGL'] ? ' [WebGL]' : '') + ')');
|
(AppOptions.get('enableWebGL') ? ' [WebGL]' : '') + ')');
|
||||||
|
|
||||||
let pdfTitle;
|
let pdfTitle;
|
||||||
if (metadata && metadata.has('dc:title')) {
|
if (metadata && metadata.has('dc:title')) {
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { viewerCompatibilityParams } from './viewer_compatibility';
|
||||||
|
|
||||||
const OptionKind = {
|
const OptionKind = {
|
||||||
VIEWER: 'viewer',
|
VIEWER: 'viewer',
|
||||||
API: 'api',
|
API: 'api',
|
||||||
@ -25,6 +27,101 @@ const OptionKind = {
|
|||||||
* compare with the format of `default_preferences.json`.
|
* compare with the format of `default_preferences.json`.
|
||||||
*/
|
*/
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
|
defaultZoomValue: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: '',
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
disableFullscreen: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: viewerCompatibilityParams.disableFullscreen || false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
disableHistory: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
disablePageLabels: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
disablePageMode: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
enablePrintAutoRotate: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
enableWebGL: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
externalLinkRel: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: 'noopener noreferrer nofollow',
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
externalLinkTarget: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 0,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
imageResourcesPath: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: './images/',
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
locale: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: (typeof navigator !== 'undefined' ? navigator.language : 'en-US'),
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
maxCanvasPixels: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: viewerCompatibilityParams.maxCanvasPixels || 16777216,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
pdfBugEnabled: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
renderer: {
|
||||||
|
/** @type {string} */
|
||||||
|
value: 'canvas',
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
renderInteractiveForms: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
showPreviousViewOnLoad: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: true,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
sidebarViewOnLoad: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 0,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
textLayerMode: {
|
||||||
|
/** @type {number} */
|
||||||
|
value: 1,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
|
useOnlyCssZoom: {
|
||||||
|
/** @type {boolean} */
|
||||||
|
value: false,
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const userOptions = Object.create(null);
|
const userOptions = Object.create(null);
|
||||||
|
@ -48,8 +48,8 @@ GenericExternalServices.createDownloadManager = function() {
|
|||||||
GenericExternalServices.createPreferences = function() {
|
GenericExternalServices.createPreferences = function() {
|
||||||
return new GenericPreferences();
|
return new GenericPreferences();
|
||||||
};
|
};
|
||||||
GenericExternalServices.createL10n = function(options) {
|
GenericExternalServices.createL10n = function({ locale = 'en-US', }) {
|
||||||
return new GenericL10n(options.locale);
|
return new GenericL10n(locale);
|
||||||
};
|
};
|
||||||
PDFViewerApplication.externalServices = GenericExternalServices;
|
PDFViewerApplication.externalServices = GenericExternalServices;
|
||||||
|
|
||||||
|
@ -78,10 +78,10 @@ class PDFOutlineViewer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
element.href = this.linkService.getDestinationHash(dest);
|
element.href = linkService.getDestinationHash(dest);
|
||||||
element.onclick = () => {
|
element.onclick = () => {
|
||||||
if (dest) {
|
if (dest) {
|
||||||
this.linkService.navigateTo(dest);
|
linkService.navigateTo(dest);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createPromiseCapability, PDFJS } from 'pdfjs-lib';
|
import { createPromiseCapability } from 'pdfjs-lib';
|
||||||
|
|
||||||
const CSS_UNITS = 96.0 / 72.0;
|
const CSS_UNITS = 96.0 / 72.0;
|
||||||
const DEFAULT_SCALE_VALUE = 'auto';
|
const DEFAULT_SCALE_VALUE = 'auto';
|
||||||
@ -71,39 +71,6 @@ let NullL10n = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables CSS only zooming.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
|
|
||||||
false : PDFJS.useOnlyCssZoom);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
|
||||||
* The default value is 4096 * 4096. Use -1 for no limit.
|
|
||||||
* @var {number}
|
|
||||||
*/
|
|
||||||
PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
|
||||||
16777216 : PDFJS.maxCanvasPixels);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables saving of the last position of the viewed PDF.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableHistory = (PDFJS.disableHistory === undefined ?
|
|
||||||
false : PDFJS.disableHistory);
|
|
||||||
|
|
||||||
if (typeof PDFJSDev === 'undefined' ||
|
|
||||||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
|
||||||
/**
|
|
||||||
* Interface locale settings.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.locale =
|
|
||||||
(PDFJS.locale === undefined && typeof navigator !== 'undefined' ?
|
|
||||||
navigator.language : PDFJS.locale) || 'en-US';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns scale factor for the canvas. It makes sense for the HiDPI displays.
|
* Returns scale factor for the canvas. It makes sense for the HiDPI displays.
|
||||||
* @return {Object} The object with horizontal (sx) and vertical (sy)
|
* @return {Object} The object with horizontal (sx) and vertical (sy)
|
||||||
|
Loading…
Reference in New Issue
Block a user