Skip to content

Commit

Permalink
Add support for /Print and /SaveAs named actions in the viewer (issue…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Snuffleupagus committed Sep 1, 2020
1 parent 60ffac0 commit 3ab8ddb
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -2223,6 +2222,17 @@ function webViewerNamedAction(evt) {
PDFViewerApplication.findBar.toggle();
}
break;

case "Print":
if (!PDFViewerApplication.supportsPrinting) {
break;
}
webViewerPrint();
break;

case "SaveAs":
webViewerDownloadOrSave("save");
break;
}
}

Expand Down

0 comments on commit 3ab8ddb

Please sign in to comment.