Q: I am attempting to fulfill the following PDF viewing user activity hooks, and would like guidance regarding where to look in PDFNet to capture each of the four events described below:
- DocumentOpened Event
Allow host to register for event notification of PDF file open event.
Allow host to register for event notification of PDF file close event.
Allow host to register for event notification of PDF page view changed event.
Allow host to register for event notification of link clicked event.
A: The PDFViewCtrl class has some interfaces that can be used to get some of these notifications:
interface DocumentLoadListener: Called when the document is set and ready. It can be used to safely perform document related actions that need the document to be set, like setting the current page, etc. This is called after all the layout and measurements are done for the document after setting it.
interface PageChangeListener: Used for receiving notifications in UI thread when the current page changes.
Currently there is no specific events for when the document is closed or when a link is clicked through PDFViewCtrl itself. The close action is not needed since it can be easily done on the client side (e.g. when PDFViewCtrl is closed or disposed, or when PDFViewCtrl.closeDoc() is used).
The handling of annotations being clicked, moved, etc., is performed in the Tools.jar library, which in turn uses two interfaces of PDFViewCtrl: the ToolManager and Tool. Using these interfaces you can easily get gesture events and perform any event you need based on your requirements. For example, for clicking on a link you can take a look at this forum post: https://groups.google.com/forum/#!msg/pdfnet-sdk/fG-20n1gcPU/4Zslh603PZ8J. This post shows a basic implementation of the ToolManager interface which detects when a link annotation is clicked, and from this point on you could have your own LinkClicked notification.