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
-
public class PdfTextFormField extends PdfFormField
An AcroForm field containing textual data.
-
-
Field Summary
Fields Modifier and Type Field Description static int
FF_COMB
constant which determines maximum length of the field's text.static int
FF_DO_NOT_SCROLL
constant which determines whether longer texts are currently allowed.static int
FF_DO_NOT_SPELL_CHECK
constant which determines whether spell-checking is currently enabledstatic int
FF_FILE_SELECT
constant which determines whether field currently represents a path.static int
FF_RICH_TEXT
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, pdfConformanceLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PdfName
getFormType()
ReturnsTx
, the form type for textual form fields.int
getMaxLen()
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
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.boolean
isRichText()
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
isSpellCheck()
If true, text entered in the field is spell-checked.PdfTextFormField
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.PdfTextFormField
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.PdfTextFormField
setMaxLen(int maxLen)
Sets the maximum length of the field's text, in characters.PdfTextFormField
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.PdfTextFormField
setPassword(boolean password)
If true, the field is intended for entering a secure password that should not be echoed visibly to the screen.PdfTextFormField
setRichText(boolean richText)
If true, the value of this field should be represented as a rich text string.PdfTextFormField
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.PdfTextFormField
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, optionsArrayToString, regenerateField, release, removeChild, removeChildren, replaceKids, setAdditionalAction, setAlternativeName, setCheckType, setChildField, setColor, setDefaultStyle, setDefaultValue, setFieldFlag, setFieldFlag, setFieldFlags, setFieldName, setJustification, setMappingName, setNoExport, setOptions, setReadOnly, setRequired, setRichText, setValue, setValue, setValue, setValue, updateDefaultAppearance, updateFontAndFontSize
-
Methods inherited from class com.itextpdf.forms.fields.AbstractPdfFormField
disableCurrentFieldRegeneration, disableFieldRegeneration, enableCurrentFieldRegeneration, enableFieldRegeneration, equals, getAcroFormObject, getColor, getDocument, getFieldName, getFont, getFontSize, getParent, getParentField, getPdfAConformanceLevel, getPdfConformanceLevel, getPdfObject, hashCode, isFieldRegenerationEnabled, isTerminalFormField, isWrappedObjectMustBeIndirect, put, remove, retrieveStyles, setColorNoRegenerate, 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 Detail
-
FF_FILE_SELECT
public static final int FF_FILE_SELECT
constant which determines whether field currently represents a path.
-
FF_DO_NOT_SPELL_CHECK
public static final int FF_DO_NOT_SPELL_CHECK
constant which determines whether spell-checking is currently enabled
-
FF_DO_NOT_SCROLL
public static final int FF_DO_NOT_SCROLL
constant which determines whether longer texts are currently allowed.
-
FF_COMB
public static final int FF_COMB
constant which determines maximum length of the field's text.
-
FF_RICH_TEXT
public static final int FF_RICH_TEXT
constant which determines whether text is currently represented as rich text.
-
-
Constructor Detail
-
PdfTextFormField
protected PdfTextFormField(PdfDocument pdfDocument)
Creates a minimalPdfTextFormField
.- Parameters:
pdfDocument
- ThePdfDocument
instance.
-
PdfTextFormField
protected PdfTextFormField(PdfWidgetAnnotation widget, PdfDocument pdfDocument)
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
protected PdfTextFormField(PdfDictionary pdfObject)
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 Detail
-
getFormType
public PdfName getFormType()
ReturnsTx
, the form type for textual form fields.- Overrides:
getFormType
in classPdfFormField
- Returns:
- the form type, as a
PdfName
-
setMultiline
public PdfTextFormField 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.- Parameters:
multiline
- whether or not the file can contain multiple lines of text- Returns:
- current
PdfTextFormField
-
setPassword
public PdfTextFormField setPassword(boolean password)
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
public PdfTextFormField 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.- 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
public PdfTextFormField setSpellCheck(boolean spellCheck)
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
public PdfTextFormField 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. 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
public PdfTextFormField 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. 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
public PdfTextFormField setRichText(boolean richText)
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
public PdfTextFormField setMaxLen(int maxLen)
Sets the maximum length of the field's text, in characters.- Parameters:
maxLen
- the maximum text length- Returns:
- current
-
-