public class

FreeTextAnnotation

extends Annotation
java.lang.Object
   ↳ com.pspdfkit.annotations.Annotation
     ↳ com.pspdfkit.annotations.FreeTextAnnotation

Class Overview

Represents a free text annotation on the page. The annotation’s text color comes from the color property of Annotation.

Summary

Nested Classes
enum FreeTextAnnotation.FreeTextAnnotationIntent Possible styles of free text annotation. 
enum FreeTextAnnotation.FreeTextTextJustification Possible values for the alignment of the text. 
[Expand]
Inherited Constants
From class com.pspdfkit.annotations.Annotation
[Expand]
Inherited Fields
From class com.pspdfkit.annotations.Annotation
Public Constructors
FreeTextAnnotation(int pageIndex, RectF rect, String contents)
Creates a new FreeText annotation.
Public Methods
void adjustBoundsForRotation()
This adjusts the annotations bounding box to the smallest possible size that will encompass the rotated annotations at it's default size.
List<PointF> getCallOutPoints()
Gets the points used to describe the call out line.
String getContents()
Returns text contents of the annotation.
String getFontName()
FreeTextAnnotation.FreeTextAnnotationIntent getIntent()
Returns type (also called intent) of the free text annotation.
LineEndType getLineEnd()
The line end for the call out line.
Size getMinimumSize()
Returns the minimum size of the annotation.
int getRotation()
Returns the clockwise rotation of this free text annotation in degrees.
EdgeInsets getTextInsets()
Gets the insets that are applied to the text.
FreeTextAnnotation.FreeTextTextJustification getTextJustification()
Returns the text justification used by this free text annotation.
float getTextSize()
Returns the text size set to this annotation.
int getTextStrokeColor()
Returns text stroke color of this annotation.
AnnotationType getType()
Gets the annotation type of the annotation.
boolean isResizable()
Check if the annotation is resizable, or if this is a non-resizable annotation.
void setCallOutPoints(List<PointF> points)
Sets the call out points for this free text annotation.
void setContents(String contents)
Sets text contents of the annotation.
void setFontName(String fontName)
Sets the font name to be used by this FreeTextAnnotation.
void setIntent(FreeTextAnnotation.FreeTextAnnotationIntent intent)
Sets the type (also called intent) of the free text annotations.
void setLineEnd(LineEndType lineEnd)
Sets the line end for the call out line.
void setRotation(int rotation, boolean adjustBounds)
Sets the rotation of this free text annotation.
void setRotation(int rotation, Size contentSize)
Sets the rotation of this free text annotation.
void setRotation(int rotation, Size contentSize, boolean adjustBounds)
Sets the rotation of this free text annotation.
void setRotation(int rotation)
Sets the rotation of this free text annotation.
void setTextInsets(EdgeInsets edgeInsets)
Sets the insets that are applied to the text.
void setTextJustification(FreeTextAnnotation.FreeTextTextJustification justification)
Sets the text justification to use.
void setTextSize(float textSize)
Sets the text size of this annotation.
void setTextStrokeColor(int color)
Sets the color of annotations text stroke.
void updateTransformationProperties(RectF newBoundingBox, RectF oldBoundingBox)
Annotations may override this method to transform their properties (i.e.
[Expand]
Inherited Methods
From class com.pspdfkit.annotations.Annotation
From class java.lang.Object

Public Constructors

public FreeTextAnnotation (int pageIndex, RectF rect, String contents)

Creates a new FreeText annotation.

Parameters
pageIndex Page to which this annotation will be attached to.
rect Bounding rectangle for this annotation's text.
contents Text of the annotation.

Public Methods

public void adjustBoundsForRotation ()

This adjusts the annotations bounding box to the smallest possible size that will encompass the rotated annotations at it's default size.

public List<PointF> getCallOutPoints ()

Gets the points used to describe the call out line.

Returns
  • The points describing the call out line.

public String getContents ()

Returns text contents of the annotation. This is usually the displayed text for annotations that display text or accessibility label for annotations that don't.

Returns
  • Annotation contents string or null if it's not set.

public String getFontName ()

Returns
  • The name of the font family used by this FreeTextAnnotation or null if no custom font is set.

public FreeTextAnnotation.FreeTextAnnotationIntent getIntent ()

Returns type (also called intent) of the free text annotation.

public LineEndType getLineEnd ()

The line end for the call out line.

Returns
  • The line end for the call out line.

public Size getMinimumSize ()

Returns the minimum size of the annotation.

Returns
  • The minimum annotation size in PDF points.

public int getRotation ()

Returns the clockwise rotation of this free text annotation in degrees.

Returns
  • The clockwise rotation of this free text annotation in degrees.

public EdgeInsets getTextInsets ()

Gets the insets that are applied to the text. This describes the offset of the inner rect containing the text, to the bounding box.

Returns
  • The inset of the text rect to the bounds.

public FreeTextAnnotation.FreeTextTextJustification getTextJustification ()

Returns the text justification used by this free text annotation.

public float getTextSize ()

Returns the text size set to this annotation.

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

public int getTextStrokeColor ()

Returns text stroke color of this annotation. For the main text color use getColor().

Returns
  • Text stroke color of this annotations or 0 if no color was set.

public AnnotationType getType ()

Gets the annotation type of the annotation.

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

public boolean isResizable ()

Check if the annotation is resizable, or if this is a non-resizable annotation.

Returns
  • true if the annotation can be resized (e.g. ink annotation) or false if it is a non-resizable one (e.g. note annotation).

public void setCallOutPoints (List<PointF> points)

Sets the call out points for this free text annotation. This needs to be either 2 or 3 points, with the first point also having a line end.

Parameters
points The points for the call out line.

public void setContents (String contents)

Sets text contents of the annotation. This is usually the displayed text for annotations that display text or accessibility label for annotations that don't.

Parameters
contents Contents string or null to clear the field.

public void setFontName (String fontName)

Sets the font name to be used by this FreeTextAnnotation.

Parameters
fontName The name of the font family to use, shouldn't include font weight e.g. 'Roboto' not 'Roboto-Thin'.

public void setIntent (FreeTextAnnotation.FreeTextAnnotationIntent intent)

Sets the type (also called intent) of the free text annotations.

public void setLineEnd (LineEndType lineEnd)

Sets the line end for the call out line.

Parameters
lineEnd One of LineEndType.

public void setRotation (int rotation, boolean adjustBounds)

Sets the rotation of this free text annotation. See also adjustBoundsForRotation()

Parameters
rotation The clockwise rotation in degrees.
adjustBounds If true will also adjust the bounding box to match the new rotation.

public void setRotation (int rotation, Size contentSize)

Sets the rotation of this free text annotation. This will adjust the bounding box so rotating the annotation will cause the bounds to change. See also setRotation(int). See also setRotation(int, Size, boolean).

Parameters
rotation The clockwise rotation in degrees.
contentSize The size of the annotation content, it will be rotated and scaled to fit inside the actual bounding box.

public void setRotation (int rotation, Size contentSize, boolean adjustBounds)

Sets the rotation of this free text annotation. See also adjustBoundsForRotation().

Parameters
rotation The clockwise rotation in degrees.
contentSize The size of the annotation content, it will be rotated and scaled to fit inside the actual bounding box.
adjustBounds If true will also adjust the bounding box to match the new rotation.

public void setRotation (int rotation)

Sets the rotation of this free text annotation. This will adjust the bounding box so rotating the annotation will cause the bounds to change. See also setRotation(int, Size). See also setRotation(int, boolean).

Parameters
rotation The clockwise rotation in degrees.

public void setTextInsets (EdgeInsets edgeInsets)

Sets the insets that are applied to the text.

Parameters
edgeInsets The amount to inset the text in the bounding box.

public void setTextJustification (FreeTextAnnotation.FreeTextTextJustification justification)

Sets the text justification to use. One of FreeTextAnnotation.FreeTextTextJustification.

Parameters
justification The justification to use for text of this annotation.

public void setTextSize (float textSize)

Sets the text size of this annotation.

Parameters
textSize Text size to be set (in PDF points).

public void setTextStrokeColor (int color)

Sets the color of annotations text stroke. For the main text color use setColor(int).

Parameters
color Text stroke color of this annotation or 0 to clear the value.

public void updateTransformationProperties (RectF newBoundingBox, RectF oldBoundingBox)

Annotations may override this method to transform their properties (i.e. points, rects, sizes) whenever the bounding box of the annotation changed.

Parameters
newBoundingBox New bounding box of the annotation (in PDF points).
oldBoundingBox Old bounding box of the annotation (in PDF points).