Search code examples
swingicepdf

Icepdf change annotation position?


In Icepdf, how do I display SquareAnnotationComponent at the position shown in the image below? enter image description here


Solution

  • There are a couple of ways to do this. The first way is similar to this example ViewerComponentExample. The idea is you get an instance of the ViewerPropertiesManager and set the desired property. In your case you would set the following property.

    properties.getPreferences().putBoolean(ViewerPropertiesManager.PROPERTY_SHOW_TOOLBAR_ANNOTATION_RECTANGLE, true);
    

    Second option is to update the key value of application.toolbar.annotation.rectangle.enabled in the ICEpdfDefaults.properties file and rebuild the viewer jar.

    There are newer versions of the library available, I'd recommend giving 7.1.3 a try.