From ec9e29807aa8e2ca67c853483875b24d3a8f7d58 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 9 Apr 2021 14:20:47 +0200 Subject: [PATCH] Remove the `enableScripting` option from the `PDFPageView` constructor Scripting, as implemented, requires access to a complete document/viewer in order to work. Hence it doesn't really make sense to keep the `enableScripting`-option on `PDFPageView`-instances.[1] --- [1] Note that there's the `PDFSinglePageViewer`, which can be used in cases where you want access to all features/functionality of the viewer but only display *one* page at a time. --- web/base_viewer.js | 5 ++--- web/pdf_page_view.js | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/web/base_viewer.js b/web/base_viewer.js index b8ec64c54..389e3d542 100644 --- a/web/base_viewer.js +++ b/web/base_viewer.js @@ -552,7 +552,6 @@ class BaseViewer { useOnlyCssZoom: this.useOnlyCssZoom, maxCanvasPixels: this.maxCanvasPixels, l10n: this.l10n, - enableScripting: this.enableScripting, }); this._pages.push(pageView); } @@ -1296,7 +1295,7 @@ class BaseViewer { imageResourcesPath = "", renderInteractiveForms = false, l10n = NullL10n, - enableScripting = false, + enableScripting = null, hasJSActionsPromise = null, mouseState = null ) { @@ -1310,7 +1309,7 @@ class BaseViewer { linkService: this.linkService, downloadManager: this.downloadManager, l10n, - enableScripting, + enableScripting: enableScripting ?? this.enableScripting, hasJSActionsPromise: hasJSActionsPromise || this.pdfDocument?.hasJSActions(), mouseState: mouseState || this._scriptingManager?.mouseState, diff --git a/web/pdf_page_view.js b/web/pdf_page_view.js index 64ec61553..251b1f650 100644 --- a/web/pdf_page_view.js +++ b/web/pdf_page_view.js @@ -62,8 +62,6 @@ import { viewerCompatibilityParams } from "./viewer_compatibility.js"; * total pixels, i.e. width * height. Use -1 for no limit. The default value * is 4096 * 4096 (16 mega-pixels). * @property {IL10n} l10n - Localization service. - * @property {boolean} [enableScripting] - Enable embedded script execution. - * The default value is `false`. */ const MAX_CANVAS_PIXELS = viewerCompatibilityParams.maxCanvasPixels || 16777216; @@ -107,7 +105,6 @@ class PDFPageView { this.renderer = options.renderer || RendererType.CANVAS; this.enableWebGL = options.enableWebGL || false; this.l10n = options.l10n || NullL10n; - this.enableScripting = options.enableScripting === true; this.paintTask = null; this.paintedViewportMap = new WeakMap(); @@ -584,7 +581,7 @@ class PDFPageView { this.imageResourcesPath, this.renderInteractiveForms, this.l10n, - this.enableScripting, + /* enableScripting */ null, /* hasJSActionsPromise = */ null, /* mouseState = */ null );