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`');
|
||||
}
|
||||
|
||||
PDFJS.useOnlyCssZoom = true;
|
||||
var USE_ONLY_CSS_ZOOM = true;
|
||||
PDFJS.disableTextLayer = true;
|
||||
PDFJS.maxImageSize = 1024 * 1024;
|
||||
PDFJS.workerSrc = '../../node_modules/pdfjs-dist/build/pdf.worker.js';
|
||||
@ -298,6 +298,7 @@ var PDFViewerApplication = {
|
||||
container: container,
|
||||
linkService: linkService,
|
||||
l10n: this.l10n,
|
||||
useOnlyCssZoom: USE_ONLY_CSS_ZOOM,
|
||||
});
|
||||
this.pdfViewer = pdfViewer;
|
||||
linkService.setViewer(pdfViewer);
|
||||
|
@ -398,6 +398,7 @@ let PDFViewerApplication = {
|
||||
enhanceTextSelection: viewerPrefs['enhanceTextSelection'],
|
||||
renderInteractiveForms: viewerPrefs['renderInteractiveForms'],
|
||||
enablePrintAutoRotate: viewerPrefs['enablePrintAutoRotate'],
|
||||
useOnlyCssZoom: PDFJS.useOnlyCssZoom,
|
||||
});
|
||||
pdfRenderingQueue.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
|
||||
* printing. The default is `false`.
|
||||
* @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.
|
||||
*/
|
||||
|
||||
@ -111,6 +113,7 @@ class BaseViewer {
|
||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
||||
this.renderer = options.renderer || RendererType.CANVAS;
|
||||
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||
this.l10n = options.l10n || NullL10n;
|
||||
|
||||
this.defaultRenderingQueue = !options.renderingQueue;
|
||||
@ -377,6 +380,7 @@ class BaseViewer {
|
||||
enhanceTextSelection: this.enhanceTextSelection,
|
||||
renderInteractiveForms: this.renderInteractiveForms,
|
||||
renderer: this.renderer,
|
||||
useOnlyCssZoom: this.useOnlyCssZoom,
|
||||
l10n: this.l10n,
|
||||
});
|
||||
bindOnAfterAndBeforeDraw(pageView);
|
||||
|
@ -38,6 +38,8 @@ import { RenderingStates } from './pdf_rendering_queue';
|
||||
* @property {boolean} renderInteractiveForms - Turns on rendering of
|
||||
* interactive form elements. The default is `false`.
|
||||
* @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.
|
||||
*/
|
||||
|
||||
@ -64,6 +66,7 @@ class PDFPageView {
|
||||
this.hasRestrictedScaling = false;
|
||||
this.enhanceTextSelection = options.enhanceTextSelection || false;
|
||||
this.renderInteractiveForms = options.renderInteractiveForms || false;
|
||||
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||
|
||||
this.eventBus = options.eventBus || getGlobalEventBus();
|
||||
this.renderingQueue = options.renderingQueue;
|
||||
@ -218,7 +221,7 @@ class PDFPageView {
|
||||
}
|
||||
|
||||
if (this.canvas) {
|
||||
if (PDFJS.useOnlyCssZoom ||
|
||||
if (this.useOnlyCssZoom ||
|
||||
(this.hasRestrictedScaling && isScalingRestricted)) {
|
||||
this.cssTransform(this.canvas, true);
|
||||
|
||||
@ -517,7 +520,7 @@ class PDFPageView {
|
||||
let outputScale = getOutputScale(ctx);
|
||||
this.outputScale = outputScale;
|
||||
|
||||
if (PDFJS.useOnlyCssZoom) {
|
||||
if (this.useOnlyCssZoom) {
|
||||
let actualSizeViewport = viewport.clone({ scale: CSS_UNITS, });
|
||||
// Use a scale that makes the canvas have the originally intended size
|
||||
// of the page.
|
||||
|
Loading…
x
Reference in New Issue
Block a user