Move the useOnlyCssZoom
option to a BaseViewer
/PDFPageView
option
This removes the `PDFJS.useOnlyCssZoom` dependency from the viewer components, but please note that as a *temporary* solution the default viewer still uses it.
This commit is contained in:
parent
9e0a31f662
commit
f4280368f7
@ -21,7 +21,7 @@ if (typeof PDFJS === 'undefined' || !PDFJS.PDFViewer || !PDFJS.getDocument) {
|
|||||||
' `gulp dist-install`');
|
' `gulp dist-install`');
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFJS.useOnlyCssZoom = true;
|
var USE_ONLY_CSS_ZOOM = true;
|
||||||
PDFJS.disableTextLayer = true;
|
PDFJS.disableTextLayer = true;
|
||||||
PDFJS.maxImageSize = 1024 * 1024;
|
PDFJS.maxImageSize = 1024 * 1024;
|
||||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||||
@ -298,6 +298,7 @@ var PDFViewerApplication = {
|
|||||||
container: container,
|
container: container,
|
||||||
linkService: linkService,
|
linkService: linkService,
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
|
useOnlyCssZoom: USE_ONLY_CSS_ZOOM,
|
||||||
});
|
});
|
||||||
this.pdfViewer = pdfViewer;
|
this.pdfViewer = pdfViewer;
|
||||||
linkService.setViewer(pdfViewer);
|
linkService.setViewer(pdfViewer);
|
||||||
|
@ -398,6 +398,7 @@ let PDFViewerApplication = {
|
|||||||
enhanceTextSelection: viewerPrefs['enhanceTextSelection'],
|
enhanceTextSelection: viewerPrefs['enhanceTextSelection'],
|
||||||
renderInteractiveForms: viewerPrefs['renderInteractiveForms'],
|
renderInteractiveForms: viewerPrefs['renderInteractiveForms'],
|
||||||
enablePrintAutoRotate: viewerPrefs['enablePrintAutoRotate'],
|
enablePrintAutoRotate: viewerPrefs['enablePrintAutoRotate'],
|
||||||
|
useOnlyCssZoom: PDFJS.useOnlyCssZoom,
|
||||||
});
|
});
|
||||||
pdfRenderingQueue.setViewer(this.pdfViewer);
|
pdfRenderingQueue.setViewer(this.pdfViewer);
|
||||||
pdfLinkService.setViewer(this.pdfViewer);
|
pdfLinkService.setViewer(this.pdfViewer);
|
||||||
|
@ -48,6 +48,8 @@ const DEFAULT_CACHE_SIZE = 10;
|
|||||||
* rotation of pages whose orientation differ from the first page upon
|
* rotation of pages whose orientation differ from the first page upon
|
||||||
* printing. The default is `false`.
|
* printing. The default is `false`.
|
||||||
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
|
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
|
||||||
|
* @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.
|
||||||
|
* The default value is `false`.
|
||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -111,6 +113,7 @@ class BaseViewer {
|
|||||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||||
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
||||||
this.renderer = options.renderer || RendererType.CANVAS;
|
this.renderer = options.renderer || RendererType.CANVAS;
|
||||||
|
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||||
this.l10n = options.l10n || NullL10n;
|
this.l10n = options.l10n || NullL10n;
|
||||||
|
|
||||||
this.defaultRenderingQueue = !options.renderingQueue;
|
this.defaultRenderingQueue = !options.renderingQueue;
|
||||||
@ -377,6 +380,7 @@ class BaseViewer {
|
|||||||
enhanceTextSelection: this.enhanceTextSelection,
|
enhanceTextSelection: this.enhanceTextSelection,
|
||||||
renderInteractiveForms: this.renderInteractiveForms,
|
renderInteractiveForms: this.renderInteractiveForms,
|
||||||
renderer: this.renderer,
|
renderer: this.renderer,
|
||||||
|
useOnlyCssZoom: this.useOnlyCssZoom,
|
||||||
l10n: this.l10n,
|
l10n: this.l10n,
|
||||||
});
|
});
|
||||||
bindOnAfterAndBeforeDraw(pageView);
|
bindOnAfterAndBeforeDraw(pageView);
|
||||||
|
@ -38,6 +38,8 @@ import { RenderingStates } from './pdf_rendering_queue';
|
|||||||
* @property {boolean} renderInteractiveForms - Turns on rendering of
|
* @property {boolean} renderInteractiveForms - Turns on rendering of
|
||||||
* interactive form elements. The default is `false`.
|
* interactive form elements. The default is `false`.
|
||||||
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
|
* @property {string} renderer - 'canvas' or 'svg'. The default is 'canvas'.
|
||||||
|
* @property {boolean} useOnlyCssZoom - (optional) Enables CSS only zooming.
|
||||||
|
* The default value is `false`.
|
||||||
* @property {IL10n} l10n - Localization service.
|
* @property {IL10n} l10n - Localization service.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -64,6 +66,7 @@ class PDFPageView {
|
|||||||
this.hasRestrictedScaling = false;
|
this.hasRestrictedScaling = false;
|
||||||
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
||||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||||
|
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||||
|
|
||||||
this.eventBus = options.eventBus || getGlobalEventBus();
|
this.eventBus = options.eventBus || getGlobalEventBus();
|
||||||
this.renderingQueue = options.renderingQueue;
|
this.renderingQueue = options.renderingQueue;
|
||||||
@ -218,7 +221,7 @@ class PDFPageView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.canvas) {
|
if (this.canvas) {
|
||||||
if (PDFJS.useOnlyCssZoom ||
|
if (this.useOnlyCssZoom ||
|
||||||
(this.hasRestrictedScaling && isScalingRestricted)) {
|
(this.hasRestrictedScaling && isScalingRestricted)) {
|
||||||
this.cssTransform(this.canvas, true);
|
this.cssTransform(this.canvas, true);
|
||||||
|
|
||||||
@ -517,7 +520,7 @@ class PDFPageView {
|
|||||||
let outputScale = getOutputScale(ctx);
|
let outputScale = getOutputScale(ctx);
|
||||||
this.outputScale = outputScale;
|
this.outputScale = outputScale;
|
||||||
|
|
||||||
if (PDFJS.useOnlyCssZoom) {
|
if (this.useOnlyCssZoom) {
|
||||||
let actualSizeViewport = viewport.clone({ scale: CSS_UNITS, });
|
let actualSizeViewport = viewport.clone({ scale: CSS_UNITS, });
|
||||||
// Use a scale that makes the canvas have the originally intended size
|
// Use a scale that makes the canvas have the originally intended size
|
||||||
// of the page.
|
// of the page.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user