Add Text Field Annotation

How to add Text Field Annotation in Java

Text field annotation adds rectangle with a text inside, like shown at the picture below. 

There is an ability to specify the next fields for TextFieldAnnotation type:

  • BackgroundColor - describes area background color;
  • Box - defines annotation position at document page;
  • Text - text that will be appear in rectangle
  • FontColor - color of the text
  • FontFamily - name of text font;
  • FontSize  - size of text font;
  • Opacity - allows to set annotation opacity;
  • PenColor - defines frame color;
  • PenStyle - defines frame line style (solid, dash, dot etc.);
  • PenWidth -  defines frame line width in pixels.

Follow these steps to add TextField annotation to document:

  • Instantiate Annotator object with input document path or stream;
  • Instantiate TextFieldAnnotation object with desired properties (position, page number, etc);
  • Call add method and pass TextFieldAnnotation object;
  • Call save method with resultant document path or stream.

The following code demonstrates how to add TextFieldAnnotation to the document:

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples: