View Source

ICEpdf can optionally be configured to support interacting with link annotations. The Viewer RI and Pilot RI, by default, come configured with their own implementations of the {{{*}org.icepdf.core.AnnotationCallback{*}}}. They differ only by how they handle external URI Actions. The Viewer RI will load an external URI with the Operating System's default web browser, while the Pilot RI will load external URI links in a new ICEbrowser viewport.

ICEpdf only supports annotations via the mouse pointer; there is no keyboard support at this time. When the mouse is moved over a portion of a PDF document which is marked as an annotation, the mouse cursor will change into a hand with a pointing finger. When a user clicks on the annotation, ICEpdf will draw any effect specified by the selected annotation, but it will not execute the annotation action; it instead passes the selected annotation to the AnnotationCallback. It is up to the AnnotationCallback implementation to process the annotation's actions.

A default implementation of an AnnotationCallback can be found in {{{*}org.icepdf.core.ri.common.MyAnnotationCallback{*}}}.

The following code snippet shows how to configure the SwingController with an AnnotationCallback that would allow the user to interact with annotations in a PDF document.

// build a component controller
SwingController controller = new SwingController();

SwingViewBuilder factory = new SwingViewBuilder(controller);

JPanel viewerComponentPanel = factory.buildViewerPanel();

// add interactive mouse link annotation support via callback
new org.icepdf.ri.common.MyAnnotationCallback(

JFrame applicationFrame = new JFrame();

// Now that the GUI is all in place, we can try openning a PDF