Top Fields Constructors Methods
org.apache.pdfbox.pdmodel.interactive.annotation

public Class PDAnnotationFreeText

extends PDAnnotationMarkup
Class Inheritance
Imports
org.apache.pdfbox.cos.COSArray, .COSDictionary, .COSFloat, .COSName, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDAppearanceHandler, .PDFreeTextAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.form.PDVariableText

Author
Paul King

Field Summary

Modifier and TypeField and Description
private PDAppearanceHandler
public static final String
IT_FREE_TEXT

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

public static final String
IT_FREE_TEXT_CALLOUT

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

public static final String
IT_FREE_TEXT_TYPE_WRITER

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

public static final String
SUB_TYPE

The type of annotation.

Inherited from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup:
RT_GROUPRT_REPLY

Constructor Summary

AccessConstructor and Description
public
public
PDAnnotationFreeText(COSDictionary
the PDF object to represent as a field.
field
)

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

Method Summary

Modifier and TypeMethod and Description
public void
public void
constructAppearances(PDDocument
the related document
document
)

Overrides org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.constructAppearances.

Create the appearance entry for this annotation.

public PDBorderEffectDictionary

Returns:

The border effect dictionary
getBorderEffect
()

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

public float[]

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.
getCallout
()

This will get the coordinates of the callout line.

public String

Returns:

a string describing the default appearance.
getDefaultAppearance
()

Get the default appearance.

public String

Returns:

the DS element of the dictionary object
getDefaultStyleString
()

Get the default style string.

public String

Returns:

The line ending style, possible values shown in the LE_ constants section, LE_NONE if missing, never null.
getLineEndingStyle
()

This will retrieve the line ending style.

public int

Returns:

The justification of the text strings.
getQ
()

This will get the 'quadding' or justification of the text to be displayed.

public PDRectangle

Returns:

the rectangle difference
getRectDifference
()

This will get the rectangle difference rectangle.

public float[]

Returns:

the differences. If the entry hasn't been set am empty array is returned.
getRectDifferences
()

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

public void
setBorderEffect(PDBorderEffectDictionary
The border effect dictionary to set.
be
)

This will set the border effect dictionary, specifying effects to be applied when drawing the line.

public final void
setCallout(float[]
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.
callout
)

This will set the coordinates of the callout line.

public void
setCustomAppearanceHandler(PDAppearanceHandler
custom appearance handler
appearanceHandler
)

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

public void
setDefaultAppearance(String
a string describing the default appearance.
daValue
)

Set the default appearance.

public void
setDefaultStyleString(String
a string describing the default style.
defaultStyleString
)

Set the default style string.

public final void
setLineEndingStyle(String
The new style.
style
)

This will set the line ending style.

public void
setQ(int
The new text justification.
q
)

This will set the quadding/justification of the text.

public void
setRectDifference(PDRectangle
the rectangle difference
rd
)

This will set the rectangle difference rectangle.

public void
setRectDifferences(float
from the annotations /Rect entry
difference
)

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

public void
setRectDifferences(float
left difference from the annotations /Rect entry
differenceLeft
,
float
top difference from the annotations /Rect entry
differenceTop
,
float
right difference from the annotations /Rect entry
differenceRight
,
float
bottom difference from the annotations /Rect entry
differenceBottom
)

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

Inherited from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup:
getBorderStylegetConstantOpacitygetCreationDategetExternalDatagetInReplyTogetIntentgetPopupgetReplyTypegetRichContentsgetSubjectgetTitlePopupsetBorderStylesetConstantOpacitysetCreationDatesetExternalDatasetInReplyTosetIntentsetPopupsetReplyTypesetRichContentssetSubjectsetTitlePopup

Field Detail

customAppearanceHandlerback to summary
private PDAppearanceHandler customAppearanceHandler
IT_FREE_TEXTback to summary
public static final String IT_FREE_TEXT

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

IT_FREE_TEXT_CALLOUTback to summary
public static final String IT_FREE_TEXT_CALLOUT

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

IT_FREE_TEXT_TYPE_WRITERback to summary
public static final String IT_FREE_TEXT_TYPE_WRITER

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

SUB_TYPEback to summary
public static final String SUB_TYPE

The type of annotation.

Constructor Detail

PDAnnotationFreeTextback to summary
public PDAnnotationFreeText()
PDAnnotationFreeTextback to summary
public PDAnnotationFreeText(COSDictionary field)

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

Parameters
field:COSDictionary

the PDF object to represent as a field.

Method Detail

constructAppearancesback to summary
public void constructAppearances()

Overrides org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.constructAppearances.

Doc from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.constructAppearances.

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.

Annotations
@Override
constructAppearancesback to summary
public void constructAppearances(PDDocument document)

Overrides org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.constructAppearances.

Doc from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation.constructAppearances.

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.

Parameters
document:PDDocument

the related document

Annotations
@Override
getBorderEffectback to summary
public PDBorderEffectDictionary getBorderEffect()

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

Returns:PDBorderEffectDictionary

The border effect dictionary

getCalloutback to summary
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:float[]

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.

getDefaultAppearanceback to summary
public String getDefaultAppearance()

Get the default appearance.

Returns:String

a string describing the default appearance.

getDefaultStyleStringback to summary
public String getDefaultStyleString()

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

Returns:String

the DS element of the dictionary object

getLineEndingStyleback to summary
public String getLineEndingStyle()

This will retrieve the line ending style.

Returns:String

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

getQback to summary
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:int

The justification of the text strings.

getRectDifferenceback to summary
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:PDRectangle

the rectangle difference

getRectDifferencesback to summary
public float[] getRectDifferences()

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

Returns:float[]

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

setBorderEffectback to summary
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:PDBorderEffectDictionary

The border effect dictionary to set.

setCalloutback to summary
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:float[]

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.

setCustomAppearanceHandlerback to summary
public void setCustomAppearanceHandler(PDAppearanceHandler appearanceHandler)

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

Parameters
appearanceHandler:PDAppearanceHandler

custom appearance handler

setDefaultAppearanceback to summary
public void setDefaultAppearance(String daValue)

Set the default appearance.

Parameters
daValue:String

a string describing the default appearance.

setDefaultStyleStringback to summary
public void setDefaultStyleString(String defaultStyleString)

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

Parameters
defaultStyleString:String

a string describing the default style.

setLineEndingStyleback to summary
public final void setLineEndingStyle(String style)

This will set the line ending style.

Parameters
style:String

The new style.

setQback to summary
public void setQ(int q)

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

Parameters
q:int

The new text justification.

setRectDifferenceback to summary
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:PDRectangle

the rectangle difference

setRectDifferencesback to summary
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:float

from the annotations /Rect entry

setRectDifferencesback to summary
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:float

left difference from the annotations /Rect entry

differenceTop:float

top difference from the annotations /Rect entry

differenceRight:float

right difference from the annotations /Rect entry

differenceBottom:float

bottom difference from the annotations /Rect entry