Class WidgetAnnotation
-
- All Implemented Interfaces:
public class WidgetAnnotation extends LinkAnnotation
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.
-
-
Field Summary
Fields Modifier and Type Field Description public final static float
FONT_SIZE_AUTO
-
Constructor Summary
Constructors Constructor Description WidgetAnnotation(AnnotationPropertyManager properties, boolean markDirty, String imageResourceId)
Intended for internal usage only WidgetAnnotation(int pageIndex, RectF boundingBox)
Intended for internal usage only
-
Method Summary
Modifier and Type Method Description AnnotationType
getType()
Gets the annotation type of the annotation. float
getFontSize()
Returns the font size of this widget annotation in PDF points. void
setFontSize(float fontSize)
Sets the font size for this widget annotation in PDF points. void
setVerticalTextAlignment(@NonNull() VerticalTextAlignment verticalAlignment)
Sets the vertical text alignment to use in this widget annotation. VerticalTextAlignment
getVerticalTextAlignment()
Returns the vertical text alignment used by this widget annotation. FormElement
getFormElement()
Returns a form element for widget annotation. Maybe<FormElement>
getFormElementAsync()
Returns a form element for widget annotation, asynchronously. void
setAdditionalAction(@NonNull() AnnotationTriggerEvent triggerEvent, @Nullable() Action action)
Sets the action that should be executed for the given annotation trigger event. Action
getAdditionalAction(@NonNull() AnnotationTriggerEvent triggerEvent)
Returns the action that should be executed on annotation trigger event. Map<AnnotationTriggerEvent, Action>
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.void
setBorderColor(@ColorInt() int color)
Sets the border color for this annotation. -
-
Method Detail
-
getType
@NonNull() AnnotationType getType()
Gets the annotation type of the annotation.
- Returns:
The type of the annotation. Makes down casting easier.
-
getFontSize
@FloatRange(from = 0.0) 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.
-
setFontSize
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.
-
setVerticalTextAlignment
void setVerticalTextAlignment(@NonNull() VerticalTextAlignment verticalAlignment)
Sets the vertical text alignment to use in this widget annotation. One of .
- Parameters:
verticalAlignment
- The vertical alignment to use for the text of this widget annotation.
-
getVerticalTextAlignment
@NonNull() VerticalTextAlignment getVerticalTextAlignment()
Returns the vertical text alignment used by this widget annotation.
- Returns:
One of VerticalTextAlignment.
-
getFormElement
@Nullable() 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.
-
getFormElementAsync
@NonNull() 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.
-
setAdditionalAction
void setAdditionalAction(@NonNull() AnnotationTriggerEvent triggerEvent, @Nullable() 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 whentriggerEvent
occurs,null
to remove existing action.
-
getAdditionalAction
@Nullable() Action getAdditionalAction(@NonNull() AnnotationTriggerEvent triggerEvent)
Returns the action that should be executed on annotation trigger event.
- Returns:
Action to be performed once the trigger event occurs.
-
getAdditionalActions
@Nullable() Map<AnnotationTriggerEvent, Action> getAdditionalActions()
Returns a map of additional actions keyed by their trigger events.
- Returns:
Additional actions dictionary or
null
if no additional actions are set.
-
getBorderColor
@ColorInt() 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.
-
setBorderColor
void setBorderColor(@ColorInt() 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 property.
- Parameters:
color
- The border color orColor#TRANSPARENT
to clear the field.
-
-
-
-