Skip to content

JS - Implement few possibilities with app.execMenuItem (bug 1724399) #14038

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/scripting_api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,24 @@ class App extends PDFObject {
/* Not implemented */
}

execMenuItem() {
/* Not implemented */
execMenuItem(item) {
switch (item) {
case "SaveAs":
case "FirstPage":
case "LastPage":
case "NextPage":
case "PrevPage":
case "ZoomViewIn":
case "ZoomViewOut":
this._send({ command: item });
break;
case "FitPage":
this._send({ command: "zoom", value: "page-fit" });
break;
case "Print":
this._send({ command: "print" });
break;
}
}

getNthPlugInName() {
Expand Down
27 changes: 27 additions & 0 deletions web/pdf_scripting_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,33 @@ class PDFScriptingManager {
}
this._pdfViewer.currentScaleValue = value;
break;
case "SaveAs":
this._eventBus.dispatch("save", { source: this });
break;
case "FirstPage":
this._pdfViewer.currentPageNumber = 1;
break;
case "LastPage":
this._pdfViewer.currentPageNumber = this._pdfViewer.pagesCount;
break;
case "NextPage":
this._pdfViewer.nextPage();
break;
case "PrevPage":
this._pdfViewer.previousPage();
break;
case "ZoomViewIn":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the "zoom"-case in the existing code, please add the following check to prevent issues:

if (isInPresentationMode) {
  return;
}

if (isInPresentationMode) {
return;
}
this._eventBus.dispatch("zoomin", { source: this });
break;
case "ZoomViewOut":
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

if (isInPresentationMode) {
return;
}
this._eventBus.dispatch("zoomout", { source: this });
break;
}
return;
}
Expand Down