How to capture events with PDFViewCtrl on Android

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.

  • DocumentClosed
    Allow host to register for event notification of PDF file close event.

  • PageDisplayed
    Allow host to register for event notification of PDF page view changed event.

  • LinkClicked
    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:

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.

Update:

Starting with version 6.1.0 of the Android PDFNet SDK, the Tools library is now shipped as an Android Library, and its source code can be found in the samples folder. The package does not include the Tools.jar anymore, and you now have the flexibility to include the source directly into your project or create a separate library for your projects.