Class PDTextField
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.form.PDField
org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField
org.apache.pdfbox.pdmodel.interactive.form.PDVariableText
org.apache.pdfbox.pdmodel.interactive.form.PDTextField
- All Implemented Interfaces:
COSObjectable
A text field is a box or space for text fill-in data typically entered from a keyboard.
The text may be restricted to a single line or may be permitted to span multiple lines
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
Fields inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDVariableText
QUADDING_CENTERED, QUADDING_LEFT, QUADDING_RIGHT
-
Constructor Summary
ConstructorsConstructorDescriptionPDTextField
(PDAcroForm acroForm) PDTextField
(PDAcroForm acroForm, COSDictionary field, PDNonTerminalField parent) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) void
Constructs appearance streams and appearance dictionaries for all widget annotations.boolean
boolean
Returns the default value of this field, or an empty string.int
Returns the maximum number of characters of the text field.getValue()
Returns the value of this field, or an empty string.Returns a string representation of the "V" entry, or an empty string.boolean
isComb()
boolean
boolean
boolean
boolean
void
setComb
(boolean comb) Set the comb bit.void
setDefaultValue
(String value) Sets the default value of this field.void
setDoNotScroll
(boolean doNotScroll) Set the doNotScroll bit.void
setDoNotSpellCheck
(boolean doNotSpellCheck) Set the doNotSpellCheck bit.void
setFileSelect
(boolean fileSelect) Set the file select bit.void
setMaxLen
(int maxLen) Sets the maximum number of characters of the text field.void
setMultiline
(boolean multiline) Set the multiline bit.void
setPassword
(boolean password) Set the password bit.void
setRichText
(boolean richText) Set the richText bit.void
Sets the plain text value of this field.Methods inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDVariableText
getDefaultAppearance, getDefaultAppearanceString, getDefaultStyleString, getQ, getRichTextValue, getStringOrStream, setDefaultAppearance, setDefaultStyleString, setQ, setRichTextValue
Methods inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField
applyChange, exportFDF, getFieldFlags, getFieldType, getWidget, getWidgets, importFDF, setActions, setWidgets
Methods inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDField
findKid, fromDictionary, getAcroForm, getActions, getAlternateFieldName, getCOSObject, getFullyQualifiedName, getInheritableAttribute, getMappingName, getParent, getPartialName, isNoExport, isReadOnly, isRequired, setAlternateFieldName, setFieldFlags, setMappingName, setNoExport, setPartialName, setReadOnly, setRequired, toString
-
Field Details
-
FLAG_MULTILINE
private static final int FLAG_MULTILINE- See Also:
-
FLAG_PASSWORD
private static final int FLAG_PASSWORD- See Also:
-
FLAG_FILE_SELECT
private static final int FLAG_FILE_SELECT- See Also:
-
FLAG_DO_NOT_SPELL_CHECK
private static final int FLAG_DO_NOT_SPELL_CHECK- See Also:
-
FLAG_DO_NOT_SCROLL
private static final int FLAG_DO_NOT_SCROLL- See Also:
-
FLAG_COMB
private static final int FLAG_COMB- See Also:
-
FLAG_RICH_TEXT
private static final int FLAG_RICH_TEXT- See Also:
-
-
Constructor Details
-
PDTextField
- Parameters:
acroForm
- The acroform.- See Also:
-
PDTextField
PDTextField(PDAcroForm acroForm, COSDictionary field, PDNonTerminalField parent) Constructor.- Parameters:
acroForm
- The form that this field is part of.field
- the PDF object to represent as a field.parent
- the parent node of the node
-
-
Method Details
-
isMultiline
public boolean isMultiline()- Returns:
- true if the field is multiline
-
setMultiline
public void setMultiline(boolean multiline) Set the multiline bit.- Parameters:
multiline
- The value for the multiline.
-
isPassword
public boolean isPassword()- Returns:
- true if the field is a password field.
-
setPassword
public void setPassword(boolean password) Set the password bit.- Parameters:
password
- The value for the password.
-
isFileSelect
public boolean isFileSelect()- Returns:
- true if the field is a file select field.
-
setFileSelect
public void setFileSelect(boolean fileSelect) Set the file select bit.- Parameters:
fileSelect
- The value for the fileSelect.
-
doNotSpellCheck
public boolean doNotSpellCheck()- Returns:
- true if the field is not suppose to spell check.
-
setDoNotSpellCheck
public void setDoNotSpellCheck(boolean doNotSpellCheck) Set the doNotSpellCheck bit.- Parameters:
doNotSpellCheck
- The value for the doNotSpellCheck.
-
doNotScroll
public boolean doNotScroll()- Returns:
- true if the field is not suppose to scroll.
-
setDoNotScroll
public void setDoNotScroll(boolean doNotScroll) Set the doNotScroll bit.- Parameters:
doNotScroll
- The value for the doNotScroll.
-
isComb
public boolean isComb()- Returns:
- true if the field is not suppose to comb the text display.
-
setComb
public void setComb(boolean comb) Set the comb bit.- Parameters:
comb
- The value for the comb.
-
isRichText
public boolean isRichText()- Returns:
- true if the field is a rich text field.
-
setRichText
public void setRichText(boolean richText) Set the richText bit.- Parameters:
richText
- The value for the richText.
-
getMaxLen
public int getMaxLen()Returns the maximum number of characters of the text field.- Returns:
- the maximum number of characters, returns -1 if the value isn't present
-
setMaxLen
public void setMaxLen(int maxLen) Sets the maximum number of characters of the text field.- Parameters:
maxLen
- the maximum number of characters
-
setValue
Sets the plain text value of this field. It also tries to update the visual appearance, unlessPDAcroForm.getNeedAppearances()
is true.- Specified by:
setValue
in classPDField
- Parameters:
value
- Plain text- Throws:
IOException
- if the value could not be set
-
setDefaultValue
Sets the default value of this field.- Parameters:
value
- Plain text- Throws:
IOException
- if the value could not be set
-
getValue
Returns the value of this field, or an empty string.- Returns:
- A non-null string.
-
getDefaultValue
Returns the default value of this field, or an empty string.- Returns:
- A non-null string.
-
getValueAsString
Description copied from class:PDField
Returns a string representation of the "V" entry, or an empty string.- Specified by:
getValueAsString
in classPDField
- Returns:
- The list of widget annotations.
-
constructAppearances
Description copied from class:PDTerminalField
Constructs appearance streams and appearance dictionaries for all widget annotations. Subclasses should not call this method directly but viaPDTerminalField.applyChange()
.- Specified by:
constructAppearances
in classPDTerminalField
- Throws:
IOException
- if the appearance couldn't be generated
-