Class TextFormElement
-
- All Implemented Interfaces:
public class TextFormElement extends FormElement
Represents a text control in a PDF form. Allows the user to enter custom text.
-
-
Method Summary
Modifier and Type Method Description FormType
getType()
Gets form type for TextFormElement. TextFormField
getFormField()
Retrieve parent form field. String
getText()
Current text value. boolean
setText(@NonNull() String text)
Sets the current text value. String
getRichText()
Current rich text value. int
getMaxLength()
Maximum length of text allowed in the text field. boolean
isMultiLine()
Returns whether text is allowed to have multiple lines or not. boolean
isPassword()
Returns whether text is intended for entering a secure password that should not be visible on the screen. boolean
isSpellCheckEnabled()
Returns whether text entered in the field shall be spell-checked. boolean
isScrollEnabled()
Returns whether the text field can be scrolled (horizontally for single-line fields, vertically for multi-line fields). boolean
isRichText()
Returns whether the value of this field can be a rich text string. void
setRichText(@NonNull() String richText)
Sets the current rich text value. boolean
isComb()
Returns whether the field shall be automatically divided into as many equally space positions, or combs, as the value of getMaxLength, and the text is laid out into those combs. boolean
isFileSelect()
Returns whether text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field. TextInputFormat
getInputFormat()
Input format of this text field. String
getInputFormatString()
Input format string of this text field, if any. String
getFormattedContents()
Returns the formatted contents of this form element based on rules in the annotation (including JavaScript) String
getEditingContents()
Returns the editing contents of this form element based on rules in the annotation (including JavaScript). -
-
Method Detail
-
getType
@NonNull() FormType getType()
Gets form type for TextFormElement. See FormType.
- Returns:
Form type for TextFormElement.
-
getFormField
@NonNull() TextFormField getFormField()
Retrieve parent form field.
- Returns:
Attached parent form field.
-
getText
@Nullable() String getText()
Current text value.
- Returns:
The current text value or
null
if no text has been set.
-
setText
boolean setText(@NonNull() String text)
Sets the current text value.
- Returns:
true
if the text field's text was updated, otherwisefalse
.
-
getRichText
@Nullable() String getRichText()
Current rich text value.
- Returns:
The current rich text value or
null
if no rich text has been set.
-
getMaxLength
int getMaxLength()
Maximum length of text allowed in the text field.
- Returns:
Maximum length of text allowed or 0 if length is unlimited.
-
isMultiLine
boolean isMultiLine()
Returns whether text is allowed to have multiple lines or not.
- Returns:
true
when text is allowed to span multiple lines.
-
isPassword
boolean isPassword()
Returns whether text is intended for entering a secure password that should not be visible on the screen.
- Returns:
true
when text should be not echoed on screen.
-
isSpellCheckEnabled
boolean isSpellCheckEnabled()
Returns whether text entered in the field shall be spell-checked.
- Returns:
true
when text content can be spell checked.
-
isScrollEnabled
boolean isScrollEnabled()
Returns whether the text field can be scrolled (horizontally for single-line fields, vertically for multi-line fields). Once the field is full, no further text shall be accepted for interactive form filling. For non-interactive form filling, the filler should take care not to add more character than will visibly fit in the defined area.
- Returns:
true
when text scrolling is enabled.
-
isRichText
boolean isRichText()
Returns whether the value of this field can be a rich text string.
- Returns:
true
when field supports rich text content.
-
setRichText
void setRichText(@NonNull() String richText)
Sets the current rich text value.
-
isComb
boolean isComb()
Returns whether the field shall be automatically divided into as many equally space positions, or combs, as the value of getMaxLength, and the text is laid out into those combs.
- Returns:
true
when dividing into combs is enabled.
-
isFileSelect
boolean isFileSelect()
Returns whether text entered in the field represents the pathname of a file whose contents shall be submitted as the value of the field.
- Returns:
true
when file selection dialog should appear and file content should be uploaded.
-
getInputFormat
@NonNull() TextInputFormat getInputFormat()
Input format of this text field.
- Returns:
Input format of this text field.
-
getInputFormatString
@Nullable() String getInputFormatString()
Input format string of this text field, if any. The format string is delivered in the format defined in the PDF, not the Java format.
- Returns:
Input format string of this text field.
-
getFormattedContents
@Nullable() String getFormattedContents()
Returns the formatted contents of this form element based on rules in the annotation (including JavaScript)
- Returns:
Formatted contents of this form element or
null
if contents could not be formatted.
-
getEditingContents
@Nullable() String getEditingContents()
Returns the editing contents of this form element based on rules in the annotation (including JavaScript). The editing contents of a form field are the contents that are shown when the user is editing a form field. These contents may be different from the form field value in some situations. For example, when the form field is prepared to show numbers with a comma decimal separator, the editing contents should also contain a decimal comma so that the user can edit the form field without causing keystroke validation errors that would prevent input.
- Returns:
Editing contents of this form element or
null
if the field does not have editing contents (for example, because it doesn't have formatting scripts).
-
-
-
-