Skip to content

Commit

Permalink
Merge pull request #12765 from Snuffleupagus/_initializeAutoPrint-scr…
Browse files Browse the repository at this point in the history
…ipting-tweaks

Avoid the `getJavaScript` API-call in `PDFViewerApplication._initializeAutoPrint` when "enableScripting" is set
  • Loading branch information
brendandahl authored Dec 21, 2020
2 parents 3ea1c43 + 7bab835 commit 9c99df7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -1652,18 +1652,18 @@ const PDFViewerApplication = {
async _initializeAutoPrint(pdfDocument, openActionPromise) {
const [openAction, javaScript] = await Promise.all([
openActionPromise,
pdfDocument.getJavaScript(),
!AppOptions.get("enableScripting") ? pdfDocument.getJavaScript() : null,
]);

if (pdfDocument !== this.pdfDocument) {
return; // The document was closed while the auto print data resolved.
}
let triggerAutoPrint = false;

if (openAction && openAction.action === "Print") {
if (openAction?.action === "Print") {
triggerAutoPrint = true;
}
if (javaScript && !AppOptions.get("enableScripting")) {
if (javaScript) {
javaScript.some(js => {
if (!js) {
// Don't warn/fallback for empty JavaScript actions.
Expand All @@ -1686,9 +1686,7 @@ const PDFViewerApplication = {
}

if (triggerAutoPrint) {
setTimeout(() => {
this.triggerPrinting();
});
this.triggerPrinting();
}
},

Expand Down

0 comments on commit 9c99df7

Please sign in to comment.