Package com.itextpdf.forms.fields
Class PdfFormField
- Direct Known Subclasses:
-
PdfButtonFormField
,PdfChoiceFormField
,PdfSignatureFormField
,PdfTextFormField
This class represents a single field or field group in an
AcroForm
.
To be able to be wrapped with this PdfObjectWrapper
the PdfObject
must be indirect.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
protected Color
protected Color
protected float
protected int
protected Color
static final int
Flag that designates, if set, that the field can contain multiple lines of text.static final int
static final int
Flag that designates, if set, that the field's contents must be obfuscated.static final int
static final int
protected PdfFont
protected float
protected PdfFormXObject
static final int
static final int
protected ImageData
protected PdfAConformanceLevel
protected int
protected String
static final int
A field with the symbol checkstatic final int
A field with the symbol circlestatic final int
A field with the symbol crossstatic final int
A field with the symbol diamondstatic final int
A field with the symbol squarestatic final int
A field with the symbol starstatic final int
static final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
PdfFormField
(PdfWidgetAnnotation widget, PdfDocument pdfDocument) Creates a form field as a parent of aPdfWidgetAnnotation
.PdfFormField
(PdfDictionary pdfObject) Creates a form field as a wrapper object around aPdfDictionary
.protected
PdfFormField
(PdfDocument pdfDocument) Creates a minimalPdfFormField
. -
Method Summary
Modifier and TypeMethodDescriptionaddKid
(PdfFormField kid) Adds a new kid to theKids
array property from aPdfFormField
.Adds a new kid to theKids
array property from aPdfWidgetAnnotation
.static PdfButtonFormField
createButton
(PdfDocument doc, int flags) Creates an emptybutton form field
with custom behavior and layout.static PdfButtonFormField
createButton
(PdfDocument doc, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptybutton form field
with custom behavior and layout.static PdfButtonFormField
createButton
(PdfDocument doc, Rectangle rect, int flags) Creates an emptybutton form field
with custom behavior and layout, on a specified location.static PdfButtonFormField
createButton
(PdfDocument doc, Rectangle rect, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptybutton form field
with custom behavior and layout, on a specified location.static PdfButtonFormField
createCheckBox
(PdfDocument doc, Rectangle rect, String name, String value) Creates aPdfButtonFormField
as a checkbox.static PdfButtonFormField
createCheckBox
(PdfDocument doc, Rectangle rect, String name, String value, int checkType) Creates aPdfButtonFormField
as a checkbox.static PdfButtonFormField
createCheckBox
(PdfDocument doc, Rectangle rect, String name, String value, int checkType, PdfAConformanceLevel pdfAConformanceLevel) Creates aPdfButtonFormField
as a checkbox.static PdfChoiceFormField
createChoice
(PdfDocument doc, int flags) Creates an emptychoice form field
.static PdfChoiceFormField
createChoice
(PdfDocument doc, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptychoice form field
.static PdfChoiceFormField
createChoice
(PdfDocument doc, Rectangle rect, int flags) Creates an emptychoice form field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createChoice
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags) Creates achoice form field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createChoice
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates achoice form field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createChoice
(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags) Creates achoice form field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createChoice
(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates achoice form field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createComboBox
(PdfDocument doc, Rectangle rect, String name, String value, String[] options) Creates acombobox
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createComboBox
(PdfDocument doc, Rectangle rect, String name, String value, String[][] options) Creates acombobox
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createComboBox
(PdfDocument doc, Rectangle rect, String name, String value, String[][] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates acombobox
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createComboBox
(PdfDocument doc, Rectangle rect, String name, String value, String[] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates acombobox
with custom behavior and layout, on a specified location.static PdfFormField
Creates an empty form field without a predefined set of layout or behavior.static PdfFormField
createEmptyField
(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an empty form field without a predefined set of layout or behavior.static PdfChoiceFormField
createList
(PdfDocument doc, Rectangle rect, String name, String value, String[] options) Creates alist field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createList
(PdfDocument doc, Rectangle rect, String name, String value, String[][] options) Creates alist field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createList
(PdfDocument doc, Rectangle rect, String name, String value, String[][] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates alist field
with custom behavior and layout, on a specified location.static PdfChoiceFormField
createList
(PdfDocument doc, Rectangle rect, String name, String value, String[] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates alist field
with custom behavior and layout, on a specified location.static PdfTextFormField
createMultilineText
(PdfDocument doc, Rectangle rect, String name, String value) Creates a namedmultiline text form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.static PdfTextFormField
createMultilineText
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize) Creates a namedmultilined text form field
with an initial value, with a specified font and font size.static PdfButtonFormField
createPushButton
(PdfDocument doc, Rectangle rect, String name, String caption) Creates aPdfButtonFormField
as a push button without data.static PdfButtonFormField
createPushButton
(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize) Creates aPdfButtonFormField
as a push button without data, with its caption in a custom font.static PdfButtonFormField
createPushButton
(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize, PdfAConformanceLevel pdfAConformanceLevel) Creates aPdfButtonFormField
as a push button without data, with its caption in a custom font.static PdfFormField
createRadioButton
(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value) Creates a genericPdfFormField
that is added to a radio group.static PdfFormField
createRadioButton
(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value, PdfAConformanceLevel pdfAConformanceLevel) Creates a genericPdfFormField
that is added to a radio group.static PdfButtonFormField
createRadioGroup
(PdfDocument doc, String name, String value) Creates aradio group form field
.static PdfButtonFormField
createRadioGroup
(PdfDocument doc, String name, String value, PdfAConformanceLevel pdfAConformanceLevel) Creates aradio group form field
.static PdfSignatureFormField
Creates an emptysignature form field
.static PdfSignatureFormField
createSignature
(PdfDocument doc, Rectangle rect) Creates an emptysignature form field
.static PdfSignatureFormField
createSignature
(PdfDocument doc, Rectangle rect, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptysignature form field
.static PdfSignatureFormField
createSignature
(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptysignature form field
.static PdfTextFormField
createText
(PdfDocument doc) Creates an emptytext form field
.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect) Creates an emptytext form field
.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect, String name) Creates a namedtext form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect, String name, String value) Creates a namedtext form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize) Creates a namedtext form field
with an initial value, with a specified font and font size.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline) Creates a namedtext form field
with an initial value, with a specified font and font size.static PdfTextFormField
createText
(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline, PdfAConformanceLevel pdfAConformanceLevel) Creates a namedtext form field
with an initial value, with a specified font and font size.static PdfTextFormField
createText
(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptytext form field
.protected void
drawBorder
(PdfCanvas canvas, PdfFormXObject xObject, float width, float height) Draws a border using the borderWidth and borderColor of the form field.protected void
drawButton
(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, float fontSize) Performs the low-level drawing operations to draw a button object.protected void
drawCheckAppearance
(float width, float height, String onStateName) Draws the appearance of a checkbox with a specified state value.protected void
drawCheckBox
(PdfCanvas canvas, float width, float height, float fontSize) Performs the low-level drawing operations to draw a checkbox object.protected void
drawMultiLineTextAppearance
(Rectangle rect, PdfFont font, String value, PdfFormXObject appearance) protected void
drawPdfA2CheckAppearance
(float width, float height, String onStateName, int checkType) Draws PDF/A-2 compliant check appearance.protected void
drawPdfACheckBox
(PdfCanvas canvas, float width, float height, boolean on) protected PdfFormXObject
drawPushButtonAppearance
(float width, float height, String text, PdfFont font, float fontSize) Draws the appearance for a push button.protected void
drawRadioAppearance
(float width, float height, String value) Draws the appearance of a radio button with a specified value.protected void
drawRadioBorder
(PdfCanvas canvas, PdfFormXObject xObject, float width, float height) protected void
drawRadioField
(PdfCanvas canvas, float width, float height, boolean on) Draws a radio button.protected void
drawTextAppearance
(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance) Draws the visual appearance of text in a form field.Gets the currently additional action dictionary for the form field.Gets the current alternate name.String[]
Gets the appearance state names.float
Gets the border width for the field.getColor()
Gets the current color of the form field.Gets default appearance string containing a sequence of valid page-content graphics or text state operators that define such properties as the field's text size and color.Gets a default style string, as described in "Rich Text Strings" section of Pdf spec.Gets the default fallback value for the form field.protected PdfDocument
Gets thePdfDocument
that owns that form field.boolean
getFieldFlag
(int flag) Checks whether a certain flag, or any of a combination of flags, is set for this form field.int
Gets the current list of PDF form field flags.Gets the current field name.getFont()
Gets the current font of the form field.float
Gets the current fontSize of the form field.Returns the type of the parent form field, or of the wrappedobject. Gets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justifiedgetKids()
Gets the kids of this object.Gets the current mapping name.Gets options for the form field.Gets the parent dictionary.protected Rectangle
getRect
(PdfDictionary field) Gets aRectangle
that matches the current size and position of this form field.Gets a rich text string, as described in "Rich Text Strings" section of Pdf spec.getValue()
Gets the current value contained in the form field.Gets the current value contained in the form field.Gets allPdfWidgetAnnotation
that this form field and itskids
refer to.boolean
If true, the field can contain multiple lines of text; if false, the field's text is restricted to a single line.boolean
Gets the NoExport attribute.boolean
If true, the field is intended for entering a secure password that should not be echoed visibly to the screen.boolean
Gets the ReadOnly flag, specifying whether or not the field can be changed.boolean
Gets the Required flag, specifying whether or not the field must be filled in.protected boolean
Defines if the object behind this wrapper must be an indirect object in the resultant document.static int
makeFieldFlag
(int bitPosition) Makes a field flag by bit position.static PdfFormField
makeFormField
(PdfObject pdfObject, PdfDocument document) Creates a (subtype of)PdfFormField
object.protected static PdfArray
processOptions
(String[] options) protected static PdfArray
processOptions
(String[][] options) Inserts the value into thePdfDictionary
of this field and associates it with the specified key.boolean
This method regenerates appearance stream of the field.void
release()
Releases underlying pdf object and other pdf entities used by wrapper.Removes the specified key from thePdfDictionary
of this field.Sets the action on allwidgets
of this form field.setAdditionalAction
(PdfName key, PdfAction action) Sets an additional action for the form field.setAlternativeName
(String name) Changes the alternate name of the field to the specified value.setAppearance
(PdfName appearanceType, String appearanceState, PdfStream appearanceStream) Sets an appearance for (the widgets related to) the form field.setBackgroundColor
(Color backgroundColor) Basic setter for thebackgroundColor
property.setBorderColor
(Color color) Sets the Border Color.setBorderStyle
(PdfDictionary style) Sets the border style for the field.setBorderWidth
(float borderWidth) Sets the border width for the field.setCheckType
(int checkType) Changes the type of graphical marker used to mark a checkbox as 'on'.Sets the text color.setDefaultStyle
(PdfString defaultStyleString) Sets a default style string, as described in "Rich Text Strings" section of Pdf spec.setDefaultValue
(PdfObject value) Sets the default fallback value for the form field.setFieldFlag
(int flag) Adds a flag, or combination of flags, for the form field.setFieldFlag
(int flag, boolean value) Adds or removes a flag, or combination of flags, for the form field.setFieldFlags
(int flags) Sets a flag, or combination of flags, for the form field.setFieldName
(String name) Changes the name of the field to the specified value.Basic setter for thefont
property.setFontAndSize
(PdfFont font, float fontSize) Combined setter for thefont
andfontSize
properties.setFontSize
(float fontSize) Basic setter for thefontSize
property.setFontSize
(int fontSize) Basic setter for thefontSize
property.Sets zero font size which will be interpreted as auto-size according to ISO 32000-1, 12.7.3.3.setJustification
(int justification) Sets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justifiedsetMappingName
(String name) Changes the mapping name of the field to the specified value.setNoExport
(boolean noExport) Sets the NoExport flag, specifying whether or not exporting is forbidden.setOptions
(PdfArray options) Sets options for the form field.setPage
(int pageNum) Specifies on which page the form field's widget must be shown.setParent
(PdfFormField parent) Sets a parentPdfFormField
for the current object.setReadOnly
(boolean readOnly) Sets the ReadOnly flag, specifying whether or not the field can be changed.setRequired
(boolean required) Sets the Required flag, specifying whether or not the field must be filled in.setRichText
(PdfObject richText) Sets a rich text string, as described in "Rich Text Strings" section of Pdf spec.setRotation
(int degRotation) Basic setter for thedegRotation
property.Sets a value to the field and generating field appearance if needed.Sets a value to the field and generates field appearance if needed.Set text field value with given font and sizeSets the field value and the display string.setVisibility
(int visibility) Set the visibility flags of the form field annotation Options are: HIDDEN, HIDDEN_BUT_PRINTABLE, VISIBLE, VISIBLE_BUT_DOES_NOT_PRINTprotected static Object[]
void
Updates DA for Variable text, Push button and choice form fields.Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, getPdfObject, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Field Details
-
FF_MULTILINE
public static final int FF_MULTILINEFlag that designates, if set, that the field can contain multiple lines of text. -
FF_PASSWORD
public static final int FF_PASSWORDFlag that designates, if set, that the field's contents must be obfuscated. -
ALIGN_LEFT
public static final int ALIGN_LEFT- See Also:
-
ALIGN_CENTER
public static final int ALIGN_CENTER- See Also:
-
ALIGN_RIGHT
public static final int ALIGN_RIGHT- See Also:
-
TYPE_CHECK
public static final int TYPE_CHECKA field with the symbol check- See Also:
-
TYPE_CIRCLE
public static final int TYPE_CIRCLEA field with the symbol circle- See Also:
-
TYPE_CROSS
public static final int TYPE_CROSSA field with the symbol cross- See Also:
-
TYPE_DIAMOND
public static final int TYPE_DIAMONDA field with the symbol diamond- See Also:
-
TYPE_SQUARE
public static final int TYPE_SQUAREA field with the symbol square- See Also:
-
TYPE_STAR
public static final int TYPE_STARA field with the symbol star- See Also:
-
HIDDEN
public static final int HIDDEN- See Also:
-
VISIBLE_BUT_DOES_NOT_PRINT
public static final int VISIBLE_BUT_DOES_NOT_PRINT- See Also:
-
HIDDEN_BUT_PRINTABLE
public static final int HIDDEN_BUT_PRINTABLE- See Also:
-
VISIBLE
public static final int VISIBLE- See Also:
-
FF_READ_ONLY
public static final int FF_READ_ONLY -
FF_REQUIRED
public static final int FF_REQUIRED -
FF_NO_EXPORT
public static final int FF_NO_EXPORT -
text
-
img
-
font
-
fontSize
protected float fontSize -
color
-
checkType
protected int checkType -
borderWidth
protected float borderWidth -
backgroundColor
-
borderColor
-
rotation
protected int rotation -
form
-
pdfAConformanceLevel
-
-
Constructor Details
-
PdfFormField
Creates a form field as a wrapper object around aPdfDictionary
. ThisPdfDictionary
must be an indirect object.- Parameters:
-
pdfObject
- the dictionary to be wrapped, must have an indirect reference.
-
PdfFormField
Creates a minimalPdfFormField
.- Parameters:
-
pdfDocument
- The document
-
PdfFormField
Creates a form field as a parent of aPdfWidgetAnnotation
.- Parameters:
-
widget
- The widget which will be a kid of thePdfFormField
-
pdfDocument
- The document
-
-
Method Details
-
makeFieldFlag
public static int makeFieldFlag(int bitPosition) Makes a field flag by bit position. Bit positions are numbered 1 to 32. But position 0 corresponds to flag 1, position 3 corresponds to flag 4 etc.- Parameters:
-
bitPosition
- bit position of a flag in range 1 to 32 from the pdf specification. - Returns:
- corresponding field flag.
-
createEmptyField
Creates an empty form field without a predefined set of layout or behavior.- Parameters:
-
doc
- thePdfDocument
to create the field in - Returns:
-
a new
PdfFormField
-
createEmptyField
public static PdfFormField createEmptyField(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an empty form field without a predefined set of layout or behavior.- Parameters:
-
doc
- thePdfDocument
to create the field in -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfFormField
-
createButton
Creates an emptybutton form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the button field in -
rect
- the location on the page for the button -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfButtonFormField
-
createButton
public static PdfButtonFormField createButton(PdfDocument doc, Rectangle rect, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptybutton form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the button field in -
rect
- the location on the page for the button -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfButtonFormField
-
createButton
Creates an emptybutton form field
with custom behavior and layout.- Parameters:
-
doc
- thePdfDocument
to create the button field in -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfButtonFormField
-
createButton
public static PdfButtonFormField createButton(PdfDocument doc, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptybutton form field
with custom behavior and layout.- Parameters:
-
doc
- thePdfDocument
to create the button field in -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfButtonFormField
-
createText
Creates an emptytext form field
.- Parameters:
-
doc
- thePdfDocument
to create the text field in - Returns:
-
a new
PdfTextFormField
-
createText
public static PdfTextFormField createText(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptytext form field
.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
pdfAConformanceLevel
- the desiredPdfAConformanceLevel
of the field. Must match the conformance level of thePdfDocument
this field will eventually be added into - Returns:
-
a new
PdfTextFormField
-
createText
Creates an emptytext form field
.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field - Returns:
-
a new
PdfTextFormField
-
createText
Creates a namedtext form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field - Returns:
-
a new
PdfTextFormField
-
createText
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value) Creates a namedtext form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value - Returns:
-
a new
PdfTextFormField
-
createText
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize) Creates a namedtext form field
with an initial value, with a specified font and font size.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font - Returns:
-
a new
PdfTextFormField
-
createText
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline) Creates a namedtext form field
with an initial value, with a specified font and font size.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font -
multiline
- true for multiline text field - Returns:
-
a new
PdfTextFormField
-
createText
public static PdfTextFormField createText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, boolean multiline, PdfAConformanceLevel pdfAConformanceLevel) Creates a namedtext form field
with an initial value, with a specified font and font size.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font -
multiline
- true for multiline text field -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfTextFormField
-
createMultilineText
public static PdfTextFormField createMultilineText(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize) Creates a namedmultilined text form field
with an initial value, with a specified font and font size.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font - Returns:
-
a new
PdfTextFormField
-
createMultilineText
public static PdfTextFormField createMultilineText(PdfDocument doc, Rectangle rect, String name, String value) Creates a namedmultiline text form field
with an initial value, and the form's default font specified inPdfAcroForm.getDefaultResources()
.- Parameters:
-
doc
- thePdfDocument
to create the text field in -
rect
- the location on the page for the text field -
name
- the name of the form field -
value
- the initial value - Returns:
-
a new
PdfTextFormField
-
createChoice
Creates an emptychoice form field
.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfChoiceFormField
-
createChoice
public static PdfChoiceFormField createChoice(PdfDocument doc, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptychoice form field
.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
-
createChoice
Creates an emptychoice form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfChoiceFormField
-
createChoice
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags) Creates achoice form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
options
- an array ofPdfString
objects that each represent the 'on' state of one of the choices. -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfChoiceFormField
-
createChoice
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfArray options, int flags, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates achoice form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
options
- an array ofPdfString
objects that each represent the 'on' state of one of the choices. -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. -
font
- the desired font to be used when displaying the text -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
-
createChoice
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags) Creates achoice form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font -
options
- an array ofPdfString
objects that each represent the 'on' state of one of the choices. -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. - Returns:
-
a new
PdfChoiceFormField
-
createChoice
public static PdfChoiceFormField createChoice(PdfDocument doc, Rectangle rect, String name, String value, PdfFont font, float fontSize, PdfArray options, int flags, PdfAConformanceLevel pdfAConformanceLevel) Creates achoice form field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
font
- aPdfFont
-
fontSize
- the size of the font -
options
- an array ofPdfString
objects that each represent the 'on' state of one of the choices. -
flags
- anint
, containing a set of binary behavioral flags. Do binaryOR
on thisint
to set the flags you require. -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
-
createSignature
Creates an emptysignature form field
.- Parameters:
-
doc
- thePdfDocument
to create the signature field in - Returns:
-
a new
PdfSignatureFormField
-
createSignature
public static PdfSignatureFormField createSignature(PdfDocument doc, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptysignature form field
.- Parameters:
-
doc
- thePdfDocument
to create the signature field in -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfSignatureFormField
-
createSignature
Creates an emptysignature form field
.- Parameters:
-
doc
- thePdfDocument
to create the signature field in -
rect
- the location on the page for the signature field - Returns:
-
a new
PdfSignatureFormField
-
createSignature
public static PdfSignatureFormField createSignature(PdfDocument doc, Rectangle rect, PdfAConformanceLevel pdfAConformanceLevel) Creates an emptysignature form field
.- Parameters:
-
doc
- thePdfDocument
to create the signature field in -
rect
- the location on the page for the signature field -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfSignatureFormField
-
createRadioGroup
Creates aradio group form field
.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
name
- the name of the form field -
value
- the initial value - Returns:
-
a new
radio group
-
createRadioGroup
public static PdfButtonFormField createRadioGroup(PdfDocument doc, String name, String value, PdfAConformanceLevel pdfAConformanceLevel) Creates aradio group form field
.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
name
- the name of the form field -
value
- the initial value -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
radio group
-
createRadioButton
public static PdfFormField createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value) Creates a genericPdfFormField
that is added to a radio group.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
radioGroup
- the radio button group that this field should belong to -
value
- the initial value - Returns:
-
a new
PdfFormField
- See Also:
-
createRadioButton
public static PdfFormField createRadioButton(PdfDocument doc, Rectangle rect, PdfButtonFormField radioGroup, String value, PdfAConformanceLevel pdfAConformanceLevel) Creates a genericPdfFormField
that is added to a radio group.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
radioGroup
- the radio button group that this field should belong to -
value
- the initial value -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfFormField
- See Also:
-
createPushButton
public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption) Creates aPdfButtonFormField
as a push button without data.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
caption
- the text to display on the button - Returns:
-
a new
PdfButtonFormField
-
createPushButton
public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize) Creates aPdfButtonFormField
as a push button without data, with its caption in a custom font.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
caption
- the text to display on the button -
font
- aPdfFont
-
fontSize
- the size of the font - Returns:
-
a new
PdfButtonFormField
-
createPushButton
public static PdfButtonFormField createPushButton(PdfDocument doc, Rectangle rect, String name, String caption, PdfFont font, float fontSize, PdfAConformanceLevel pdfAConformanceLevel) Creates aPdfButtonFormField
as a push button without data, with its caption in a custom font.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
caption
- the text to display on the button -
font
- aPdfFont
-
fontSize
- the size of the font -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfButtonFormField
-
createCheckBox
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value) Creates aPdfButtonFormField
as a checkbox.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
value
- the initial value - Returns:
-
a new
checkbox
-
createCheckBox
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType) Creates aPdfButtonFormField
as a checkbox.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
value
- the initial value -
checkType
- the type of checkbox graphic to use. - Returns:
-
a new
checkbox
-
createCheckBox
public static PdfButtonFormField createCheckBox(PdfDocument doc, Rectangle rect, String name, String value, int checkType, PdfAConformanceLevel pdfAConformanceLevel) Creates aPdfButtonFormField
as a checkbox. Check symbol will fit rectangle. You may set font and font size after creation.- Parameters:
-
doc
- thePdfDocument
to create the radio group in -
rect
- the location on the page for the field -
name
- the name of the form field -
value
- the initial value -
checkType
- the type of checkbox graphic to use. -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
checkbox
-
createComboBox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[][] options) Creates acombobox
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the combobox in -
rect
- the location on the page for the combobox -
name
- the name of the form field -
value
- the initial value -
options
- a two-dimensional array of Strings which will be converted to a PdfArray. - Returns:
-
a new
PdfChoiceFormField
as a combobox
-
createComboBox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[][] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates acombobox
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the combobox in -
rect
- the location on the page for the combobox -
name
- the name of the form field -
value
- the initial value -
options
- a two-dimensional array of Strings which will be converted to a PdfArray. -
font
- the desired font to be used when displaying the text -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
as a combobox
-
createComboBox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[] options) Creates acombobox
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the combobox in -
rect
- the location on the page for the combobox -
name
- the name of the form field -
value
- the initial value -
options
- an array of Strings which will be converted to a PdfArray. - Returns:
-
a new
PdfChoiceFormField
as a combobox
-
createComboBox
public static PdfChoiceFormField createComboBox(PdfDocument doc, Rectangle rect, String name, String value, String[] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates acombobox
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the combobox in -
rect
- the location on the page for the combobox -
name
- the name of the form field -
value
- the initial value -
options
- an array of Strings which will be converted to a PdfArray. -
font
- the desired font to be used when displaying the text -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
as a combobox
-
createList
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[][] options) Creates alist field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
options
- a two-dimensional array of Strings which will be converted to a PdfArray. - Returns:
-
a new
PdfChoiceFormField
as a list field
-
createList
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[][] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates alist field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the choice field in -
rect
- the location on the page for the choice field -
name
- the name of the form field -
value
- the initial value -
options
- a two-dimensional array of Strings which will be converted to a PdfArray. -
font
- the desired font to be used when displaying the text -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
as a list field
-
createList
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[] options) Creates alist field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the list field in -
rect
- the location on the page for the list field -
name
- the name of the form field -
value
- the initial value -
options
- an array of Strings which will be converted to a PdfArray. - Returns:
-
a new
PdfChoiceFormField
as a list field
-
createList
public static PdfChoiceFormField createList(PdfDocument doc, Rectangle rect, String name, String value, String[] options, PdfFont font, PdfAConformanceLevel pdfAConformanceLevel) Creates alist field
with custom behavior and layout, on a specified location.- Parameters:
-
doc
- thePdfDocument
to create the list field in -
rect
- the location on the page for the list field -
name
- the name of the form field -
value
- the initial value -
options
- an array of Strings which will be converted to a PdfArray. -
font
- the desired font to be used when displaying the text -
pdfAConformanceLevel
- thePdfAConformanceLevel
of the document. null if it's no PDF/A document - Returns:
-
a new
PdfChoiceFormField
as a list field
-
makeFormField
Creates a (subtype of)PdfFormField
object. The type of the object depends on theFT
entry in thepdfObject
parameter.- Parameters:
-
pdfObject
- assumed to be either aPdfDictionary
, or aPdfIndirectReference
to aPdfDictionary
-
document
- thePdfDocument
to create the field in - Returns:
-
a new
PdfFormField
, ornull
ifpdfObject
does not contain aFT
entry
-
getFormType
Returns the type of the parent form field, or of the wrappedobject. - Returns:
-
the form type, as a
PdfName
-
setValue
Sets a value to the field and generating field appearance if needed.- Parameters:
-
value
- of the field - Returns:
- the field
-
setValue
Sets a value to the field and generates field appearance if needed.- Parameters:
-
value
- of the field -
generateAppearance
- if false, appearance won't be regenerated - Returns:
- the field
-
setValue
Set text field value with given font and size- Parameters:
-
value
- text value -
font
- aPdfFont
-
fontSize
- the size of the font - Returns:
- the edited field
-
setValue
Sets the field value and the display string. The display string is used to build the appearance.- Parameters:
-
value
- the field value -
display
- the string that is used for the appearance. Ifnull
thevalue
parameter will be used - Returns:
- the edited field
-
setParent
Sets a parentPdfFormField
for the current object.- Parameters:
-
parent
- another form field that this field belongs to, usually a group field - Returns:
- the edited field
-
getParent
Gets the parent dictionary.- Returns:
- another form field that this field belongs to, usually a group field
-
getKids
Gets the kids of this object.- Returns:
-
contents of the dictionary's
Kids
property, as aPdfArray
-
addKid
Adds a new kid to theKids
array property from aPdfFormField
. Also sets the kid'sParent
property to this object.- Parameters:
-
kid
- a newPdfFormField
entry for the field'sKids
array property - Returns:
- the edited field
-
addKid
Adds a new kid to theKids
array property from aPdfWidgetAnnotation
. Also sets the kid'sParent
property to this object.- Parameters:
-
kid
- a newPdfWidgetAnnotation
entry for the field'sKids
array property - Returns:
- the edited field
-
setFieldName
Changes the name of the field to the specified value.- Parameters:
-
name
- the new field name, as a String - Returns:
- the edited field
-
getFieldName
Gets the current field name.- Returns:
-
the current field name, as a
PdfString
-
setAlternativeName
Changes the alternate name of the field to the specified value. The alternate is a descriptive name to be used by status messages etc.- Parameters:
-
name
- the new alternate name, as a String - Returns:
- the edited field
-
getAlternativeName
Gets the current alternate name. The alternate is a descriptive name to be used by status messages etc.- Returns:
-
the current alternate name, as a
PdfString
-
setMappingName
Changes the mapping name of the field to the specified value. The mapping name can be used when exporting the form data in the document.- Parameters:
-
name
- the new alternate name, as a String - Returns:
- the edited field
-
getMappingName
Gets the current mapping name. The mapping name can be used when exporting the form data in the document.- Returns:
-
the current mapping name, as a
PdfString
-
getFieldFlag
public boolean getFieldFlag(int flag) Checks whether a certain flag, or any of a combination of flags, is set for this form field.- Parameters:
-
flag
- anint
interpreted as a series of a binary flags - Returns:
- true if any of the flags specified in the parameter is also set in the form field.
-
setFieldFlag
Adds a flag, or combination of flags, for the form field. This method is intended to be used one flag at a time, but this is not technically enforced. To replace the current value, usesetFieldFlags(int)
.- Parameters:
-
flag
- anint
interpreted as a series of a binary flags - Returns:
- the edited field
-
setFieldFlag
Adds or removes a flag, or combination of flags, for the form field. This method is intended to be used one flag at a time, but this is not technically enforced. To replace the current value, usesetFieldFlags(int)
.- Parameters:
-
flag
- anint
interpreted as a series of a binary flags -
value
- iftrue
, adds the flag(s). iffalse
, removes the flag(s). - Returns:
- the edited field
-
isMultiline
public boolean isMultiline()If true, the field can contain multiple lines of text; if false, the field's text is restricted to a single line.- Returns:
- whether the field can span over multiple lines.
-
isPassword
public boolean isPassword()If true, the field is intended for entering a secure password that should not be echoed visibly to the screen. Characters typed from the keyboard should instead be echoed in some unreadable form, such as asterisks or bullet characters.- Returns:
- whether or not the contents of the field must be obfuscated
-
setFieldFlags
Sets a flag, or combination of flags, for the form field. This method replaces the previous value. Compare withsetFieldFlag(int)
which adds a flag to the existing flags.- Parameters:
-
flags
- anint
interpreted as a series of a binary flags - Returns:
- the edited field
-
getFieldFlags
public int getFieldFlags()Gets the current list of PDF form field flags.- Returns:
-
the current list of flags, encoded as an
int
-
getValue
Gets the current value contained in the form field.- Returns:
-
the current value, as a
PdfObject
-
getValueAsString
Gets the current value contained in the form field.- Returns:
-
the current value, as a
String
-
setDefaultValue
Sets the default fallback value for the form field.- Parameters:
-
value
- the default value - Returns:
- the edited field
-
getDefaultValue
Gets the default fallback value for the form field.- Returns:
- the default value
-
setAdditionalAction
Sets an additional action for the form field.- Parameters:
-
key
- the dictionary key to use for storing the action -
action
- the action - Returns:
- the edited field
-
getAdditionalAction
Gets the currently additional action dictionary for the form field.- Returns:
- the additional action dictionary
-
setOptions
Sets options for the form field. Only to be used for checkboxes and radio buttons.- Parameters:
-
options
- an array ofPdfString
objects that each represent the 'on' state of one of the choices. - Returns:
- the edited field
-
getOptions
Gets options for the form field. Should only return usable values for checkboxes and radio buttons. -
getWidgets
Gets allPdfWidgetAnnotation
that this form field and itskids
refer to.- Returns:
-
a list of
PdfWidgetAnnotation
-
getDefaultAppearance
Gets default appearance string containing a sequence of valid page-content graphics or text state operators that define such properties as the field's text size and color.- Returns:
-
the default appearance graphics, as a
PdfString
-
updateDefaultAppearance
public void updateDefaultAppearance()Updates DA for Variable text, Push button and choice form fields. The resources required for DA will be put to AcroForm's DR. Note, for other form field types DA will be removed. -
getJustification
Gets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justified- Returns:
- the current justification attribute
-
setJustification
Sets a code specifying the form of quadding (justification) to be used in displaying the text: 0 Left-justified 1 Centered 2 Right-justified- Parameters:
-
justification
- the value to set the justification attribute to - Returns:
- the edited field
-
getDefaultStyle
Gets a default style string, as described in "Rich Text Strings" section of Pdf spec.- Returns:
-
the default style, as a
PdfString
-
setDefaultStyle
Sets a default style string, as described in "Rich Text Strings" section of Pdf spec.- Parameters:
-
defaultStyleString
- a new default style for the form field - Returns:
- the edited field
-
getRichText
Gets a rich text string, as described in "Rich Text Strings" section of Pdf spec. May be eitherPdfStream
orPdfString
.- Returns:
- the current rich text value
-
setRichText
Sets a rich text string, as described in "Rich Text Strings" section of Pdf spec. May be eitherPdfStream
orPdfString
.- Parameters:
-
richText
- a new rich text value - Returns:
- The edited PdfFormField
-
getFontSize
public float getFontSize()Gets the current fontSize of the form field.- Returns:
- the current fontSize
-
getFont
Gets the current font of the form field.- Returns:
-
the current
font
-
getColor
Gets the current color of the form field.- Returns:
-
the current
color
-
setFont
Basic setter for thefont
property. Regenerates the field appearance after setting the new value. Note that the font will be added to the document so ensure that the font is embedded if it's a pdf/a document.- Parameters:
-
font
- The new font to be set - Returns:
- The edited PdfFormField
-
setFontSize
Basic setter for thefontSize
property. Regenerates the field appearance after setting the new value.- Parameters:
-
fontSize
- The new font size to be set - Returns:
- The edited PdfFormField
-
setFontSize
Basic setter for thefontSize
property. Regenerates the field appearance after setting the new value.- Parameters:
-
fontSize
- The new font size to be set - Returns:
- The edited PdfFormField
-
setFontAndSize
Combined setter for thefont
andfontSize
properties. Regenerates the field appearance after setting the new value.- Parameters:
-
font
- The new font to be set -
fontSize
- The new font size to be set - Returns:
- The edited PdfFormField
-
setBackgroundColor
Basic setter for thebackgroundColor
property. Regenerates the field appearance after setting the new value.- Parameters:
-
backgroundColor
- The new color to be set ornull
if no background needed - Returns:
- The edited PdfFormField
-
setRotation
Basic setter for thedegRotation
property. Regenerates the field appearance after setting the new value.- Parameters:
-
degRotation
- The new degRotation to be set - Returns:
- The edited PdfFormField
-
setAction
Sets the action on allwidgets
of this form field.- Parameters:
-
action
- The action - Returns:
- The edited field
-
setCheckType
Changes the type of graphical marker used to mark a checkbox as 'on'. Notice that in order to complete the change one should callregenerateField
method- Parameters:
-
checkType
- the new checkbox marker - Returns:
- The edited field
-
setVisibility
Set the visibility flags of the form field annotation Options are: HIDDEN, HIDDEN_BUT_PRINTABLE, VISIBLE, VISIBLE_BUT_DOES_NOT_PRINT- Parameters:
-
visibility
- visibility option - Returns:
- The edited field
-
regenerateField
public boolean regenerateField()This method regenerates appearance stream of the field. Use it if you changed any field parameters and didn't use setValue method which generates appearance by itself.- Returns:
- whether or not the regeneration was successful.
-
getBorderWidth
public float getBorderWidth()Gets the border width for the field.- Returns:
- the current border width.
-
setBorderWidth
Sets the border width for the field.- Parameters:
-
borderWidth
- The new border width. - Returns:
- The edited field
-
setBorderStyle
Sets the border style for the field.- Parameters:
-
style
- the new border style. - Returns:
- the edited field
-
setBorderColor
Sets the Border Color.- Parameters:
-
color
- the new value for the Border Color - Returns:
- the edited field
-
setColor
Sets the text color.- Parameters:
-
color
- the new value for the Color - Returns:
- the edited field
-
setReadOnly
Sets the ReadOnly flag, specifying whether or not the field can be changed.- Parameters:
-
readOnly
- iftrue
, then the field cannot be changed. - Returns:
- the edited field
-
isReadOnly
public boolean isReadOnly()Gets the ReadOnly flag, specifying whether or not the field can be changed.- Returns:
-
true
if the field cannot be changed.
-
setRequired
Sets the Required flag, specifying whether or not the field must be filled in.- Parameters:
-
required
- iftrue
, then the field must be filled in. - Returns:
- the edited field
-
isRequired
public boolean isRequired()Gets the Required flag, specifying whether or not the field must be filled in.- Returns:
-
true
if the field must be filled in.
-
setNoExport
Sets the NoExport flag, specifying whether or not exporting is forbidden.- Parameters:
-
noExport
- iftrue
, then exporting is forbidden - Returns:
- the edited field
-
isNoExport
public boolean isNoExport()Gets the NoExport attribute.- Returns:
- whether exporting the value following a form action is forbidden.
-
setPage
Specifies on which page the form field's widget must be shown.- Parameters:
-
pageNum
- the page number - Returns:
- the edited field
-
getAppearanceStates
Gets the appearance state names.- Returns:
- an array of Strings containing the names of the appearance states
-
setAppearance
public PdfFormField setAppearance(PdfName appearanceType, String appearanceState, PdfStream appearanceStream) Sets an appearance for (the widgets related to) the form field.- Parameters:
-
appearanceType
- the type of appearance stream to be added- PdfName.N: normal appearance
- PdfName.R: rollover appearance
- PdfName.D: down appearance
-
appearanceState
- the state of the form field that needs to be true for the appearance to be used. Differentiates between several streams of the same type. -
appearanceStream
- the appearance instructions, as aPdfStream
- Returns:
- the edited field
-
setFontSizeAutoScale
Sets zero font size which will be interpreted as auto-size according to ISO 32000-1, 12.7.3.3.- Returns:
- the edited field
-
put
Inserts the value into thePdfDictionary
of this field and associates it with the specified key. If the key is already present in this field dictionary, this method will override the old value with the specified one.- Parameters:
-
key
- key to insert or to override -
value
- the value to associate with the specified key - Returns:
-
this
PdfFormField
instance
-
remove
Removes the specified key from thePdfDictionary
of this field.- Parameters:
-
key
- key to be removed - Returns:
-
this
PdfFormField
instance
-
release
public void release()Releases underlying pdf object and other pdf entities used by wrapper. This method should be called instead of direct call toPdfObject.release()
if the wrapper is used. -
isWrappedObjectMustBeIndirect
protected boolean isWrappedObjectMustBeIndirect()Description copied from class:PdfObjectWrapper
Defines if the object behind this wrapper must be an indirect object in the resultant document.
If this method returns true it doesn't necessarily mean that object must be in the indirect state at any moment, but rather defines that when the object will be written to the document it will be transformed into indirect object if it's not indirect yet.
Return value of this method shouldn't depend on any logic, it should return always true or false.- Specified by:
-
isWrappedObjectMustBeIndirect
in classPdfObjectWrapper<PdfDictionary>
- Returns:
- true if in the resultant document the object behind the wrapper must be indirect, otherwise false.
-
getDocument
Gets thePdfDocument
that owns that form field.- Returns:
-
the
PdfDocument
that owns that form field.
-
getRect
Gets aRectangle
that matches the current size and position of this form field.- Parameters:
-
field
- current form field. - Returns:
-
a
Rectangle
that matches the current size and position of this form field.
-
processOptions
- Parameters:
-
options
- Two-dimensional array of options. - Returns:
-
a
PdfArray
that contains all the options.
-
processOptions
- Parameters:
-
options
- array of options. - Returns:
-
a
PdfArray
that contains all the options.
-
splitDAelements
-
drawTextAppearance
protected void drawTextAppearance(Rectangle rect, PdfFont font, float fontSize, String value, PdfFormXObject appearance) Draws the visual appearance of text in a form field.- Parameters:
-
rect
- The location on the page for the list field -
font
- aPdfFont
-
fontSize
- The size of the font -
value
- The initial value -
appearance
- The appearance
-
drawMultiLineTextAppearance
protected void drawMultiLineTextAppearance(Rectangle rect, PdfFont font, String value, PdfFormXObject appearance) -
drawBorder
Draws a border using the borderWidth and borderColor of the form field.- Parameters:
-
canvas
- ThePdfCanvas
on which to draw -
xObject
- The PdfFormXObject -
width
- The width of the rectangle to draw -
height
- The height of the rectangle to draw
-
drawRadioBorder
protected void drawRadioBorder(PdfCanvas canvas, PdfFormXObject xObject, float width, float height) -
drawRadioAppearance
Draws the appearance of a radio button with a specified value.- Parameters:
-
width
- the width of the radio button to draw -
height
- the height of the radio button to draw -
value
- the value of the button
-
drawRadioField
Draws a radio button.- Parameters:
-
canvas
- thePdfCanvas
on which to draw -
width
- the width of the radio button to draw -
height
- the height of the radio button to draw -
on
- required to betrue
for fulfilling the drawing operation
-
drawCheckAppearance
Draws the appearance of a checkbox with a specified state value.- Parameters:
-
width
- the width of the checkbox to draw -
height
- the height of the checkbox to draw -
onStateName
- the state of the form field that will be drawn
-
drawPdfA2CheckAppearance
protected void drawPdfA2CheckAppearance(float width, float height, String onStateName, int checkType) Draws PDF/A-2 compliant check appearance. Actually it's just PdfA check appearance. According to corrigendum there is no difference between them- Parameters:
-
width
- width of the checkbox -
height
- height of the checkbox -
onStateName
- name that corresponds to the "On" state of the checkbox -
checkType
- the type that determines how the checkbox will look like. Allowed values areTYPE_CHECK
,TYPE_CIRCLE
,TYPE_CROSS
,TYPE_DIAMOND
,TYPE_SQUARE
,TYPE_STAR
-
drawPushButtonAppearance
protected PdfFormXObject drawPushButtonAppearance(float width, float height, String text, PdfFont font, float fontSize) Draws the appearance for a push button.- Parameters:
-
width
- the width of the pushbutton -
height
- the width of the pushbutton -
text
- the text to display on the button -
font
- aPdfFont
-
fontSize
- the size of the font - Returns:
-
a new
PdfFormXObject
-
drawButton
protected void drawButton(PdfCanvas canvas, float x, float y, float width, float height, String text, PdfFont font, float fontSize) Performs the low-level drawing operations to draw a button object.- Parameters:
-
canvas
- thePdfCanvas
of the page to draw on. -
x
- will be ignored, according to spec it shall be 0 -
y
- will be ignored, according to spec it shall be 0 -
width
- the width of the button -
height
- the width of the button -
text
- the text to display on the button -
font
- aPdfFont
-
fontSize
- the size of the font
-
drawCheckBox
Performs the low-level drawing operations to draw a checkbox object.- Parameters:
-
canvas
- thePdfCanvas
of the page to draw on. -
width
- the width of the button -
height
- the width of the button -
fontSize
- the size of the font
-
drawPdfACheckBox
-