-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add new "pageopen"/"pageclose" events for usage with JavaScript actions #12747
Add new "pageopen"/"pageclose" events for usage with JavaScript actions #12747
Conversation
Having looked at the Acrobat JavaScript specification, see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf#G5.1963437, I suppose that introducing these two new events is probably the easiest solution overall. However there's a number of things that, as far as I'm concerned, will help the overall implementation: - Only dispatch these new events when `enableScripting = true` is set. - Handle them *separately* from the existing "pagechanging" event dispatching, to avoid too much clutter. - Don't dispatch either of the events if the page didn't actually change. - When waiting for pages to render, don't dispatch "pageopen" if the page is no longer active when rendering finishes. - Ensure that we only use *one* "pagerendered" event listener. - Ensure that "pageopen" is actually dispatched when the document loads. I suppose that we *could* avoid adding the "pageclose" event, and use the existing "pagechanging" event instead, however having a separate event might allow more flexibility in the future. (E.g. I don't know if we'll possibly want to dispatch "pageclose" on document close, as mentioned briefly in the specification.)
…removes an existing document This new event essentially mirrors the existing "pagesinit" event, and will allow e.g. a custom implementation of the viewer to be notified before the current PDF document is removed from the viewer. By using this new event, we're thus able to dispatch a "pageclose" event for JavaScript actions when closing the existing document.
/botio-linux preview |
From: Bot.io (Linux m4)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://54.67.70.0:8877/52c1fc1f4b5820e/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/52c1fc1f4b5820e/output.txt Total script time: 4.19 mins Published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFM, thanks a lot.
I'll add an integration test in a followup.
Looks like a good solution to me too! |
Please refer to the individual commit messages for additional information.
https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/AcrobatDC_js_api_reference.pdf#G5.1963437
@timvandermeij I really hoped to be able to use e.g. the existing "pagechanging" events, but based on the requirements outlined in the specification I just don't see a better way than adding new events here; please let me know if you have a better idea!