From 695523712c7e8c5aef62fe0e6165f988b3a11f4e Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 1 Sep 2020 08:54:07 +0200 Subject: [PATCH] Add support for /Print and /SaveAs named actions in the viewer (issue 12308) All of the core/display functionality needed to support this already exists, we simply need to handle these named actions in the viewer and the buttons will "just" work. Unfortunately there's not really any good way of testing this, but given the size and scope of the patch that's hopefully OK. --- web/app.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/web/app.js b/web/app.js index 1dae72e18f4f3..43c1c49f6f4f9 100644 --- a/web/app.js +++ b/web/app.js @@ -2210,10 +2210,9 @@ function webViewerPageMode({ mode }) { } function webViewerNamedAction(evt) { - // Processing couple of named actions that might be useful. - // See also PDFLinkService.executeNamedAction - const action = evt.action; - switch (action) { + // Processing a couple of named actions that might be useful, see also + // `PDFLinkService.executeNamedAction`. + switch (evt.action) { case "GoToPage": PDFViewerApplication.appConfig.toolbar.pageNumber.select(); break; @@ -2223,6 +2222,16 @@ function webViewerNamedAction(evt) { PDFViewerApplication.findBar.toggle(); } break; + + case "Print": + if (PDFViewerApplication.supportsPrinting) { + webViewerPrint(); + } + break; + + case "SaveAs": + webViewerSave(); + break; } }