org.apache.pdfbox.pdmodel.interactive.annotation

## Class PDAnnotationFreeText

- java.lang.Object
- - org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation
  - - org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup
    - - org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationFreeText

All Implemented Interfaces:
  COSObjectable

    public class PDAnnotationFreeText
    extends PDAnnotationMarkup

Author:
  Paul King

### Field Summary

Fields
`static String` `IT_FREE_TEXT` A plain free-text annotation, also known as a text box comment.
`static String` `IT_FREE_TEXT_CALLOUT` A callout, associated with an area on the page through the callout line specified.
`static String` `IT_FREE_TEXT_TYPE_WRITER` The annotation is intended to function as a click-to-type or typewriter object.
`static String` `SUB_TYPE` The type of annotation.

### Fields inherited from class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup

`RT_GROUP, RT_REPLY`

### Constructor Summary

Constructors
Constructor and Description
`PDAnnotationFreeText()`
`PDAnnotationFreeText(COSDictionary field)` Creates a FreeText annotation from a COSDictionary, expected to be a correct object definition.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `constructAppearances()` Create the appearance entry for this annotation.
`void` `constructAppearances(PDDocument document)` Create the appearance entry for this annotation.
`PDBorderEffectDictionary` `getBorderEffect()` This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.
`float[]` `getCallout()` This will get the coordinates of the callout line.
`String` `getDefaultAppearance()` Get the default appearance.
`String` `getDefaultStyleString()` Get the default style string.
`String` `getLineEndingStyle()` This will retrieve the line ending style.
`int` `getQ()` This will get the 'quadding' or justification of the text to be displayed.
`PDRectangle` `getRectDifference()` This will get the rectangle difference rectangle.
`float[]` `getRectDifferences()` This will get the margin between the annotations "outer" rectangle defined by /Rect and the border.
`void` `setBorderEffect(PDBorderEffectDictionary be)` This will set the border effect dictionary, specifying effects to be applied when drawing the line.
`void` `setCallout(float[] callout)` This will set the coordinates of the callout line.
`void` `setCustomAppearanceHandler(PDAppearanceHandler appearanceHandler)` Set a custom appearance handler for generating the annotations appearance streams.
`void` `setDefaultAppearance(String daValue)` Set the default appearance.
`void` `setDefaultStyleString(String defaultStyleString)` Set the default style string.
`void` `setLineEndingStyle(String style)` This will set the line ending style.
`void` `setQ(int q)` This will set the quadding/justification of the text.
`void` `setRectDifference(PDRectangle rd)` This will set the rectangle difference rectangle.
`void` `setRectDifferences(float difference)` This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.
`void` `setRectDifferences(float differenceLeft, float differenceTop, float differenceRight, float differenceBottom)` This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.

### Methods inherited from class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup

`getBorderStyle, getConstantOpacity, getCreationDate, getExternalData, getInReplyTo, getIntent, getPopup, getReplyType, getRichContents, getSubject, getTitlePopup, setBorderStyle, setConstantOpacity, setCreationDate, setExternalData, setInReplyTo, setIntent, setPopup, setReplyType, setRichContents, setSubject, setTitlePopup`

### Methods inherited from class org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation

`createAnnotation, equals, getAnnotationFlags, getAnnotationName, getAppearance, getAppearanceState, getBorder, getColor, getColor, getContents, getCOSObject, getModifiedDate, getNormalAppearanceStream, getOptionalContent, getPage, getRectangle, getStructParent, getSubtype, hashCode, isHidden, isInvisible, isLocked, isLockedContents, isNoRotate, isNoView, isNoZoom, isPrinted, isReadOnly, isToggleNoView, setAnnotationFlags, setAnnotationName, setAppearance, setAppearanceState, setBorder, setColor, setContents, setHidden, setInvisible, setLocked, setLockedContents, setModifiedDate, setModifiedDate, setNoRotate, setNoView, setNoZoom, setOptionalContent, setPage, setPrinted, setReadOnly, setRectangle, setStructParent, setSubtype, setToggleNoView`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SUB_TYPE

    public static final String SUB_TYPE

The type of annotation.

See Also:
  Constant Field Values

#### IT_FREE_TEXT

    public static final String IT_FREE_TEXT

A plain free-text annotation, also known as a text box comment.

See Also:
  Constant Field Values

#### IT_FREE_TEXT_CALLOUT

    public static final String IT_FREE_TEXT_CALLOUT

A callout, associated with an area on the page through the callout line specified.

See Also:
  Constant Field Values

#### IT_FREE_TEXT_TYPE_WRITER

    public static final String IT_FREE_TEXT_TYPE_WRITER

The annotation is intended to function as a click-to-type or typewriter object.

See Also:
  Constant Field Values

### Constructor Detail

#### PDAnnotationFreeText

    public PDAnnotationFreeText()

#### PDAnnotationFreeText

    public PDAnnotationFreeText(COSDictionary field)

Creates a FreeText annotation from a COSDictionary, expected to be a correct object definition.

Parameters:
  `field` - the PDF object to represent as a field.

### Method Detail

#### getDefaultAppearance

    public String getDefaultAppearance()

Get the default appearance.

Returns:
  a string describing the default appearance.

#### setDefaultAppearance

    public void setDefaultAppearance(String daValue)

Set the default appearance.

Parameters:
  `daValue` - a string describing the default appearance.

#### getDefaultStyleString

    public String getDefaultStyleString()

Get the default style string. The default style string defines the default style for rich text fields.

Returns:
  the DS element of the dictionary object

#### setDefaultStyleString

    public void setDefaultStyleString(String defaultStyleString)

Set the default style string. Providing null as the value will remove the default style string.

Parameters:
  `defaultStyleString` - a string describing the default style.

#### getQ

    public int getQ()

This will get the 'quadding' or justification of the text to be displayed.
0 - Left (default)
1 - Centered
2 - Right
Please see the QUADDING_CONSTANTS in `PDVariableText`.

Returns:
  The justification of the text strings.

#### setQ

    public void setQ(int q)

This will set the quadding/justification of the text. Please see the QUADDING_CONSTANTS in `PDVariableText`.

Parameters:
  `q` - The new text justification.

#### setRectDifferences

    public void setRectDifferences(float difference)

This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.

This will set an equal difference for all sides

Parameters:
  `difference` - from the annotations /Rect entry

#### setRectDifferences

    public void setRectDifferences(float differenceLeft,
                                   float differenceTop,
                                   float differenceRight,
                                   float differenceBottom)

This will set the difference between the annotations "outer" rectangle defined by /Rect and the border.

Parameters:
  `differenceLeft` - left difference from the annotations /Rect entry
  `differenceTop` - top difference from the annotations /Rect entry
  `differenceRight` - right difference from the annotations /Rect entry
  `differenceBottom` - bottom difference from the annotations /Rect entry

#### getRectDifferences

    public float[] getRectDifferences()

This will get the margin between the annotations "outer" rectangle defined by /Rect and the border.

Returns:
  the differences. If the entry hasn't been set am empty array is returned.

#### setCallout

    public final void setCallout(float[] callout)

This will set the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.

Parameters:
  `callout` - An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.

#### getCallout

    public float[] getCallout()

This will get the coordinates of the callout line. (PDF 1.6 and higher) Only relevant if the intent is FreeTextCallout.

Returns:
  An array of four or six numbers specifying a callout line attached to the free text annotation. Six numbers [ x1 y1 x2 y2 x3 y3 ] represent the starting, knee point, and ending coordinates of the line in default user space, four numbers [ x1 y1 x2 y2 ] represent the starting and ending coordinates of the line.

#### setLineEndingStyle

    public final void setLineEndingStyle(String style)

This will set the line ending style.

Parameters:
  `style` - The new style.

#### getLineEndingStyle

    public String getLineEndingStyle()

This will retrieve the line ending style.

Returns:
  The line ending style, possible values shown in the LE_ constants section, LE_NONE if missing, never null.

#### setBorderEffect

    public void setBorderEffect(PDBorderEffectDictionary be)

This will set the border effect dictionary, specifying effects to be applied when drawing the line. This is supported by PDF 1.6 and higher.

Parameters:
  `be` - The border effect dictionary to set.

#### getBorderEffect

    public PDBorderEffectDictionary getBorderEffect()

This will retrieve the border effect dictionary, specifying effects to be applied used in drawing the line.

Returns:
  The border effect dictionary

#### setRectDifference

    public void setRectDifference(PDRectangle rd)

This will set the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)

Parameters:
  `rd` - the rectangle difference

#### getRectDifference

    public PDRectangle getRectDifference()

This will get the rectangle difference rectangle. Giving the difference between the annotations rectangle and where the drawing occurs. (To take account of any effects applied through the BE entry for example)

Returns:
  the rectangle difference

#### setCustomAppearanceHandler

    public void setCustomAppearanceHandler(PDAppearanceHandler appearanceHandler)

Set a custom appearance handler for generating the annotations appearance streams.

Parameters:
  `appearanceHandler` - custom appearance handler

#### constructAppearances

    public void constructAppearances()

Description copied from class: `PDAnnotation`
Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.

Overrides:
  `constructAppearances` in class `PDAnnotation`

#### constructAppearances

    public void constructAppearances(PDDocument document)

Description copied from class: `PDAnnotation`
Create the appearance entry for this annotation. Not having it may prevent display in some viewers. This method is for overriding in subclasses, the default implementation does nothing.

Overrides:
  `constructAppearances` in class `PDAnnotation`
Parameters:
  `document` - the related document