From b3d7d1c6144ff15e2edf4d63f374239889a3852d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 15 Mar 2020 14:25:59 +0100 Subject: [PATCH] Ensure that the JavaScript-warning is always displayed, in the viewer, regardless of browser printing support The viewer doesn't currently support executing of any JavaScript, as found in some PDF documents, for security reasons. (Although there's a small hack to at least provide basic support for automatic printing on document load, without running scripts.) However, in the event that the browser doesn't support printing we're not run *any* of this code. In particular that means that we're also not displaying the "Warning: JavaScript is not supported" message, which seems strange since JavaScript found in a PDF document can really contain *anything* (and not only printing instructions). It thus seem reasonable, as far as I'm concerned, to always display the JavaScript-warning *even* if printing happens to be unsupported. --- web/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web/app.js b/web/app.js index fe557a77f..0c35c5719 100644 --- a/web/app.js +++ b/web/app.js @@ -1225,9 +1225,6 @@ const PDFViewerApplication = { }); pagesPromise.then(async () => { - if (!this.supportsPrinting) { - return; - } const [openAction, javaScript] = await Promise.all([ openActionPromise, pdfDocument.getJavaScript(), @@ -1259,6 +1256,9 @@ const PDFViewerApplication = { } } + if (!this.supportsPrinting) { + return; + } if (triggerAutoPrint) { setTimeout(function() { window.print();