Package com.itextpdf.forms.fields
Class PdfTextFormField
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.forms.fields.AbstractPdfFormField
com.itextpdf.forms.fields.PdfFormField
com.itextpdf.forms.fields.PdfTextFormField
An AcroForm field containing textual data.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
constant which determines maximum length of the field's text.static final int
constant which determines whether longer texts are currently allowed.static final int
constant which determines whether spell-checking is currently enabledstatic final int
constant which determines whether field currently represents a path.static final int
constant which determines whether text is currently represented as rich text.Fields inherited from class com.itextpdf.forms.fields.PdfFormField
checkType, FF_MULTILINE, FF_NO_EXPORT, FF_PASSWORD, FF_READ_ONLY, FF_REQUIRED, form, img, text
Fields inherited from class com.itextpdf.forms.fields.AbstractPdfFormField
color, DEFAULT_FONT_SIZE, font, fontSize, MIN_FONT_SIZE, parent, pdfAConformanceLevel
-
Constructor Summary
ModifierConstructorDescriptionprotected
PdfTextFormField
(PdfWidgetAnnotation widget, PdfDocument pdfDocument) Creates a text form field as a parent of aPdfWidgetAnnotation
.protected
PdfTextFormField
(PdfDictionary pdfObject) Creates a text form field as a wrapper object around aPdfDictionary
.protected
PdfTextFormField
(PdfDocument pdfDocument) Creates a minimalPdfTextFormField
. -
Method Summary
Modifier and TypeMethodDescriptionReturnsTx
, the form type for textual form fields.int
Gets the maximum length of the field's text, in characters.boolean
isComb()
Meaningful only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear.boolean
If true, the text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.boolean
If true, the value of this field should be represented as a rich text string.boolean
isScroll()
If true, the field scrolls (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle.boolean
If true, text entered in the field is spell-checked.setComb
(boolean comb) Meaningful only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear.setFileSelect
(boolean fileSelect) If true, the text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.setMaxLen
(int maxLen) Sets the maximum length of the field's text, in characters.setMultiline
(boolean multiline) If true, the field can contain multiple lines of text; if false, the field?s text is restricted to a single line.setPassword
(boolean password) If true, the field is intended for entering a secure password that should not be echoed visibly to the screen.setRichText
(boolean richText) If true, the value of this field should be represented as a rich text string.setScroll
(boolean scroll) If true, the field scrolls (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle.setSpellCheck
(boolean spellCheck) If true, text entered in the field is spell-checked.Methods inherited from class com.itextpdf.forms.fields.PdfFormField
addKid, addKid, addKid, getAdditionalAction, getAllChildFields, getAllChildFormFields, getAlternativeName, getAppearanceStates, getChildField, getChildFields, getChildFormAnnotations, getChildFormFields, getDefaultAppearance, getDefaultStyle, getDefaultValue, getDisplayValue, getFieldFlag, getFieldFlags, getFirstFormAnnotation, getFormFieldKeys, getFormType, getJustification, getKids, getMappingName, getOptions, getPartialFieldName, getRichText, getValue, getValueAsString, getWidgets, isFormField, isInReadingMode, isMultiline, isNoExport, isPassword, isReadOnly, isRequired, makeFieldFlag, makeFormField, makeFormFieldOrAnnotation, regenerateField, release, removeChild, removeChildren, setAdditionalAction, setAlternativeName, setCheckType, setColor, setDefaultStyle, setDefaultValue, setFieldFlag, setFieldFlag, setFieldFlags, setFieldName, setJustification, setMappingName, setNoExport, setOptions, setReadOnly, setRequired, setRichText, setValue, setValue, setValue, setValue, updateDefaultAppearance
Methods inherited from class com.itextpdf.forms.fields.AbstractPdfFormField
disableCurrentFieldRegeneration, disableFieldRegeneration, enableCurrentFieldRegeneration, enableFieldRegeneration, equals, getColor, getDocument, getFieldName, getFont, getFontSize, getParent, getParentField, getPdfAConformanceLevel, getPdfObject, hashCode, isFieldRegenerationEnabled, isTerminalFormField, isWrappedObjectMustBeIndirect, put, remove, setFont, setFontAndSize, setFontSize, setFontSize, setFontSizeAutoScale, setParent
Methods inherited from class com.itextpdf.kernel.pdf.PdfObjectWrapper
ensureObjectIsAddedToDocument, ensureUnderlyingObjectHasIndirectReference, flush, isFlushed, makeIndirect, makeIndirect, markObjectAsIndirect, setForbidRelease, setModified, setPdfObject, unsetForbidRelease
-
Field Details
-
FF_FILE_SELECT
public static final int FF_FILE_SELECTconstant which determines whether field currently represents a path. -
FF_DO_NOT_SPELL_CHECK
public static final int FF_DO_NOT_SPELL_CHECKconstant which determines whether spell-checking is currently enabled -
FF_DO_NOT_SCROLL
public static final int FF_DO_NOT_SCROLLconstant which determines whether longer texts are currently allowed. -
FF_COMB
public static final int FF_COMBconstant which determines maximum length of the field's text. -
FF_RICH_TEXT
public static final int FF_RICH_TEXTconstant which determines whether text is currently represented as rich text.
-
-
Constructor Details
-
PdfTextFormField
Creates a minimalPdfTextFormField
.- Parameters:
-
pdfDocument
- ThePdfDocument
instance.
-
PdfTextFormField
Creates a text form field as a parent of aPdfWidgetAnnotation
.- Parameters:
-
widget
- The widget which will be a kid of thePdfTextFormField
. -
pdfDocument
- ThePdfDocument
instance.
-
PdfTextFormField
Creates a text 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.
-
-
Method Details
-
getFormType
ReturnsTx
, the form type for textual form fields.- Overrides:
-
getFormType
in classPdfFormField
- Returns:
-
the form type, as a
PdfName
-
setMultiline
If true, the field can contain multiple lines of text; if false, the field?s text is restricted to a single line.- Parameters:
-
multiline
- whether or not the file can contain multiple lines of text - Returns:
-
current
PdfTextFormField
-
setPassword
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.- Parameters:
-
password
- whether or not to obscure the typed characters - Returns:
-
current
PdfTextFormField
-
isFileSelect
public boolean isFileSelect()If true, the text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.- Returns:
- whether or not this field currently represents a path
-
setFileSelect
If true, the text entered in the field represents the pathname of a file whose contents are to be submitted as the value of the field.- Parameters:
-
fileSelect
- whether or not this field should represent a path - Returns:
-
current
PdfTextFormField
-
isSpellCheck
public boolean isSpellCheck()If true, text entered in the field is spell-checked.- Returns:
- whether or not spell-checking is currently enabled
-
setSpellCheck
If true, text entered in the field is spell-checked.- Parameters:
-
spellCheck
- whether or not to spell-check - Returns:
-
current
PdfTextFormField
-
isScroll
public boolean isScroll()If true, the field scrolls (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text is accepted.- Returns:
- whether or not longer texts are currently allowed
-
setScroll
If true, the field scrolls (horizontally for single-line fields, vertically for multiple-line fields) to accommodate more text than fits within its annotation rectangle. Once the field is full, no further text is accepted.- Parameters:
-
scroll
- whether or not to allow longer texts - Returns:
-
current
PdfTextFormField
-
isComb
public boolean isComb()Meaningful only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear. If true, the field is automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs.- Returns:
- whether or not combing is enabled
-
setComb
Meaningful only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear. If true, the field is automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs.- Parameters:
-
comb
- whether or not to enable combing - Returns:
-
current
PdfTextFormField
-
isRichText
public boolean isRichText()If true, the value of this field should be represented as a rich text string. If the field has a value, the RV entry of the field dictionary specifies the rich text string.- Returns:
- whether or not text is currently represented as rich text
-
setRichText
If true, the value of this field should be represented as a rich text string. If the field has a value, the RV entry of the field dictionary specifies the rich text string.- Parameters:
-
richText
- whether or not to represent text as rich text - Returns:
-
current
PdfTextFormField
-
getMaxLen
public int getMaxLen()Gets the maximum length of the field's text, in characters. This is an optional parameter, so if it is not specified, 0 value will be returned.- Returns:
- the current maximum text length
-
setMaxLen
Sets the maximum length of the field's text, in characters.- Parameters:
-
maxLen
- the maximum text length - Returns:
- current
-