public class

WidgetAnnotation

extends LinkAnnotation
java.lang.Object
   ↳ com.pspdfkit.annotations.Annotation
     ↳ com.pspdfkit.annotations.LinkAnnotation
       ↳ com.pspdfkit.annotations.WidgetAnnotation

Class Overview

Represents the appearance of a field in interactive forms. For form elements with text, the text color comes from the color property of Annotation. Use getFormElement() to access associated FormElement.

Summary

Constants
float FONT_SIZE_AUTO The font size value used by setFontSize(float) and getFontSize() to represent automatic font sizing of text form elements.
[Expand]
Inherited Constants
From class com.pspdfkit.annotations.Annotation
[Expand]
Inherited Fields
From class com.pspdfkit.annotations.Annotation
Public Methods
Action getAdditionalAction(AnnotationTriggerEvent triggerEvent)
Returns the action that should be executed on annotation trigger event.
Map<AnnotationTriggerEventAction> getAdditionalActions()
Returns a map of additional actions keyed by their trigger events.
int getBorderColor()
Returns the border color of this annotation or Color#TRANSPARENT if no color is set.
float getFontSize()
Returns the font size of this widget annotation in PDF points.
FormElement getFormElement()
Returns a form element for widget annotation.
Maybe<FormElement> getFormElementAsync()
Returns a form element for widget annotation, asynchronously.
float getTextSize()
This method is deprecated. This method was renamed to getFontSize(). This method will be removed with PSPDFKit 7.
AnnotationType getType()
Gets the annotation type of the annotation.
VerticalTextAlignment getVerticalTextAlignment()
Returns the vertical text alignment used by this widget annotation.
void setAdditionalAction(AnnotationTriggerEvent triggerEvent, Action action)
Sets the action that should be executed for the given annotation trigger event.
void setBorderColor(int color)
Sets the border color for this annotation.
void setFontSize(float fontSize)
Sets the font size for this widget annotation in PDF points.
void setVerticalTextAlignment(VerticalTextAlignment verticalAlignment)
Sets the vertical text alignment to use in this widget annotation.
[Expand]
Inherited Methods
From class com.pspdfkit.annotations.LinkAnnotation
From class com.pspdfkit.annotations.Annotation
From class java.lang.Object

Constants

public static final float FONT_SIZE_AUTO

The font size value used by setFontSize(float) and getFontSize() to represent automatic font sizing of text form elements. If set, PSPDFKit will automatically grow and shrink the content of the form element to fit the annotation's bounding box.

Constant Value: 0.0

Public Methods

public Action getAdditionalAction (AnnotationTriggerEvent triggerEvent)

Returns the action that should be executed on annotation trigger event.

Returns
  • Action to be performed once the trigger event occurs.

public Map<AnnotationTriggerEventAction> getAdditionalActions ()

Returns a map of additional actions keyed by their trigger events.

Returns
  • Additional actions dictionary or null if no additional actions are set.

public int getBorderColor ()

Returns the border color of this annotation or Color#TRANSPARENT if no color is set. Note that alpha channel is not taken into account as per PDF specifications.

Returns
  • Color of annotations border or Color#TRANSPARENT if no color is set.

public float getFontSize ()

Returns the font size of this widget annotation in PDF points. If set to FONT_SIZE_AUTO, PSPDFKit will automatically adjust the font size of the annotation, so that the content fills the bounding box.

Returns
  • The font size of this widget annotation, or FONT_SIZE_AUTO if auto-sizing of the annotation's content is enabled.

public FormElement getFormElement ()

Returns a form element for widget annotation.

Note: this call may block for a while and should not be invoked on the main thread.

Note: This call requires forms feature in your license.

Returns
  • A form element value or null if it doesn't exist.

public Maybe<FormElement> getFormElementAsync ()

Returns a form element for widget annotation, asynchronously.

Note: This call requires forms feature in your license.

Returns
  • Maybe emitting the FormElement or just completing in case the form element is null.

public float getTextSize ()

This method is deprecated.
This method was renamed to getFontSize(). This method will be removed with PSPDFKit 7.

Returns the text size set to this annotation.

Returns
  • Text size for this annotation (in PDF points).

public AnnotationType getType ()

Gets the annotation type of the annotation.

Returns
  • The type of the annotation. Makes down casting easier.

public VerticalTextAlignment getVerticalTextAlignment ()

Returns the vertical text alignment used by this widget annotation.

Returns

public void setAdditionalAction (AnnotationTriggerEvent triggerEvent, Action action)

Sets the action that should be executed for the given annotation trigger event.

Parameters
triggerEvent Event for which to set the action.
action Action to be executed when triggerEvent occurs, null to remove existing action.

public void setBorderColor (int color)

Sets the border color for this annotation. Border color usually redirects to color, unless overridden to have a real backing store (this is the case for WidgetAnnotation).

Note: The annotation will only store the RGB part and discard the alpha channel set here. Annotation opacity is set via the setAlpha(float) property.

Parameters
color The border color or Color#TRANSPARENT to clear the field.

public void setFontSize (float fontSize)

Sets the font size for this widget annotation in PDF points. If set to FONT_SIZE_AUTO, PSPDFKit will automatically adjust the font size of the widget annotation so that its content fills the annotation's bounding box.

// Set a font size of 14 points to a widget annotation.
 widgetAnnotation.setFontSize(14.0f);

 // Enable auto-sizing of the annotation's content.
 widgetAnnotation.setFontSize(WidgetAnnotation.FONT_SIZE_AUTO);
 

Parameters
fontSize The font size to set for this annotation. If set to FONT_SIZE_AUTO, PSPDFKit will enable automatic sizing of the content, to fill the bounding box of this annotation.
See Also

public void setVerticalTextAlignment (VerticalTextAlignment verticalAlignment)

Sets the vertical text alignment to use in this widget annotation. One of VerticalTextAlignment.

Parameters
verticalAlignment The vertical alignment to use for the text of this widget annotation.