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

public Class PDAnnotationWidget

extends PDAnnotation
Class Inheritance
Imports
org.apache.pdfbox.cos.COSDictionary, .COSName, org.apache.pdfbox.pdmodel.interactive.action.PDActionFactory, .PDAnnotationAdditionalActions, .PDAction, org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField

This is the class that represents a widget annotation. This represents the appearance of a field and manages user interactions. A field may have several widget annotations, which may be on several pages.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
public static final String
SUB_TYPE

The type of annotation.

Constructor Summary

AccessConstructor and Description
public
PDAnnotationWidget()

Constructor.

public
PDAnnotationWidget(COSDictionary
the PDF object to represent as a field.
field
)

Creates a PDWidget from a COSDictionary, expected to be a correct object definition for a field in PDF.

Method Summary

Modifier and TypeMethod and Description
public PDAction

Returns:

The action to be performed when this annotation is activated.
getAction
()

Get the action to be performed when this annotation is to be activated.

public PDAnnotationAdditionalActions

Returns:

The actions of the field.
getActions
()

Get the additional actions for this field.

public PDAppearanceCharacteristicsDictionary

Returns:

the appearance characteristics dictionary
getAppearanceCharacteristics
()

Returns the appearance characteristics dictionary.

public PDBorderStyleDictionary

Returns:

the border style dictionary.
getBorderStyle
()

This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.

public String

Returns:

the highlighting mode
getHighlightingMode
()

Returns the highlighting mode.

public void
setAction(PDAction
The annotation action.
action
)

Set the annotation action.

public void
setActions(PDAnnotationAdditionalActions
The field actions.
actions
)

Set the actions of the field.

public void
setAppearanceCharacteristics(PDAppearanceCharacteristicsDictionary
the appearance characteristics dictionary
appearanceCharacteristics
)

Sets the appearance characteristics dictionary.

public void
setBorderStyle(PDBorderStyleDictionary
the border style dictionary to set.
bs
)

This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.

public void
setHighlightingMode(String
the highlighting mode the defined values
highlightingMode
)

Sets the highlighting mode.

public void
setParent(PDTerminalField
the parent field.
field
)

Set the parent field of a widget annotation.

Inherited from org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation:
constructAppearancesconstructAppearancescreateAnnotationequalsgetAnnotationFlagsgetAnnotationNamegetAppearancegetAppearanceStategetBordergetColorgetColorgetContentsgetCOSObjectgetModifiedDategetNormalAppearanceStreamgetOptionalContentgetPagegetRectanglegetStructParentgetSubtypehashCodeisHiddenisInvisibleisLockedisLockedContentsisNoRotateisNoViewisNoZoomisPrintedisReadOnlyisToggleNoViewsetAnnotationFlagssetAnnotationNamesetAppearancesetAppearanceStatesetBordersetColorsetContentssetHiddensetInvisiblesetLockedsetLockedContentssetModifiedDatesetModifiedDatesetNoRotatesetNoViewsetNoZoomsetOptionalContentsetPagesetPrintedsetReadOnlysetRectanglesetStructParentsetSubtypesetToggleNoView

Field Detail

SUB_TYPEback to summary
public static final String SUB_TYPE

The type of annotation.

Constructor Detail

PDAnnotationWidgetback to summary
public PDAnnotationWidget()

Constructor.

PDAnnotationWidgetback to summary
public PDAnnotationWidget(COSDictionary field)

Creates a PDWidget from a COSDictionary, expected to be a correct object definition for a field in PDF.

Parameters
field:COSDictionary

the PDF object to represent as a field.

Method Detail

getActionback to summary
public PDAction getAction()

Get the action to be performed when this annotation is to be activated.

Returns:PDAction

The action to be performed when this annotation is activated.

getActionsback to summary
public PDAnnotationAdditionalActions getActions()

Get the additional actions for this field. This will return null if there are no additional actions for this field. As of PDF 1.6 this is only used for Widget Annotations.

Returns:PDAnnotationAdditionalActions

The actions of the field.

getAppearanceCharacteristicsback to summary
public PDAppearanceCharacteristicsDictionary getAppearanceCharacteristics()

Returns the appearance characteristics dictionary.

Returns:PDAppearanceCharacteristicsDictionary

the appearance characteristics dictionary

getBorderStyleback to summary
public PDBorderStyleDictionary getBorderStyle()

This will retrieve the border style dictionary, specifying the width and dash pattern used in drawing the line.

Returns:PDBorderStyleDictionary

the border style dictionary.

getHighlightingModeback to summary
public String getHighlightingMode()

Returns the highlighting mode. Default value: I

N
(None) No highlighting.
I
(Invert) Invert the contents of the annotation rectangle.
O
(Outline) Invert the annotation's border.
P
(Push) Display the annotation's down appearance, if any. If no down appearance is defined, the contents of the annotation rectangle shall be offset to appear as if it were pushed below the surface of the page
T
(Toggle) Same as P (which is preferred).
Returns:String

the highlighting mode

setActionback to summary
public void setAction(PDAction action)

Set the annotation action. As of PDF 1.6 this is only used for Widget Annotations

Parameters
action:PDAction

The annotation action.

setActionsback to summary
public void setActions(PDAnnotationAdditionalActions actions)

Set the actions of the field.

Parameters
actions:PDAnnotationAdditionalActions

The field actions.

setAppearanceCharacteristicsback to summary
public void setAppearanceCharacteristics(PDAppearanceCharacteristicsDictionary appearanceCharacteristics)

Sets the appearance characteristics dictionary.

Parameters
appearanceCharacteristics:PDAppearanceCharacteristicsDictionary

the appearance characteristics dictionary

setBorderStyleback to summary
public void setBorderStyle(PDBorderStyleDictionary bs)

This will set the border style dictionary, specifying the width and dash pattern used in drawing the line.

Parameters
bs:PDBorderStyleDictionary

the border style dictionary to set.

setHighlightingModeback to summary
public void setHighlightingMode(String highlightingMode)

Sets the highlighting mode.

N
(None) No highlighting.
I
(Invert) Invert the contents of the annotation rectangle.
O
(Outline) Invert the annotation's border.
P
(Push) Display the annotation's down appearance, if any. If no down appearance is defined, the contents of the annotation rectangle shall be offset to appear as if it were pushed below the surface of the page
T
(Toggle) Same as P (which is preferred).
Parameters
highlightingMode:String

the highlighting mode the defined values

setParentback to summary
public void setParent(PDTerminalField field)

Set the parent field of a widget annotation. This is only required if this widget annotation is one of multiple children in a field, and not to be set otherwise. You will usually not need this, because in most cases, fields have only one widget and share a common dictionary. A usage can be found in the CreateMultiWidgetsForm example.

Parameters
field:PDTerminalField

the parent field.

Exceptions
IllegalArgumentException:
if setParent() was called for a field that shares a dictionary with its only widget.