Dispatch a "Doc/WillClose" event, when scripting is enabled, when closing the document

This event is mentioned in the specification, see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf#G5.1963176, and it's also listed as a valid type in fb87704b38/src/shared/util.js (L164-L170)

Since we're already dispatching a "PageClose" event in this case, it seems reasonable to *also* dispatch a "Doc/WillClose" event as well.
This commit is contained in:
Jonas Jenwald 2021-03-06 18:21:34 +01:00
parent 17c0bf0473
commit 412f01aeaf

View File

@ -128,6 +128,11 @@ class PDFScriptingManager {
this._internalEvents.set("pagesdestroy", async event => {
await this._dispatchPageClose(this._pdfViewer.currentPageNumber);
await this._scripting?.dispatchEventInSandbox({
id: "doc",
name: "WillClose",
});
this._closeCapability?.resolve();
});