Package com.itextpdf.forms.fields
Class PdfChoiceFormField
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.forms.fields.AbstractPdfFormField
com.itextpdf.forms.fields.PdfFormField
com.itextpdf.forms.fields.PdfChoiceFormField
An AcroForm field type representing any type of choice field. Choice fields are to be represented by a viewer as a list box or a combo box.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
If true, the field is a combo box.static final int
If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).static final int
If true, text entered in the field shall be spell-checked.static final int
If true, the combo box shall include an editable text box as well as a drop-down list.static final int
If true, more than one of the field's option items may be selected simultaneously.static final int
If true, the field's option items shall be sorted alphabetically.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, pdfConformance
-
Constructor Summary
ModifierConstructorDescriptionprotected
PdfChoiceFormField
(PdfWidgetAnnotation widget, PdfDocument pdfDocument) Creates a choice form field as a parent of aPdfWidgetAnnotation
.protected
PdfChoiceFormField
(PdfDictionary pdfObject) Creates a choice form field as a wrapper object around aPdfDictionary
.protected
PdfChoiceFormField
(PdfDocument pdfDocument) Creates a minimalPdfChoiceFormField
. -
Method Summary
Modifier and TypeMethodDescriptionReturnsCh
, the form type for choice form fields.Gets the currently selected items in the fieldGets the current index of the first option in a scrollable list.boolean
isCombo()
If true, the field is a combo box; if false, the field is a list box.boolean
If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).boolean
isEdit()
If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list.boolean
If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.boolean
isSort()
If true, the field's option items shall be sorted alphabetically.boolean
If true, text entered in the field shall be spell-checked..setCombo
(boolean combo) If true, the field is a combo box; if false, the field is a list box.setCommitOnSelChange
(boolean commitOnSelChange) If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).setEdit
(boolean edit) If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list.setIndices
(PdfArray indices) Sets the selected items in the field.setListSelected
(int[] optionNumbers) Highlights the options.setListSelected
(String[] optionValues) Highlights the options.setListSelected
(String[] optionValues, boolean generateAppearance) Highlights the options and generates field appearance if needed.setMultiSelect
(boolean multiSelect) If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.setSort
(boolean sort) If true, the field's option items shall be sorted alphabetically.setSpellCheck
(boolean spellCheck) If true, text entered in the field shall be spell-checked.setTopIndex
(int index) Sets the index of the first visible option in a scrollable list.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, getPdfConformance, 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_COMBO
public static final int FF_COMBOIf true, the field is a combo box. If false, the field is a list box. -
FF_EDIT
public static final int FF_EDITIf true, the combo box shall include an editable text box as well as a drop-down list. If false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true. -
FF_SORT
public static final int FF_SORTIf true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers. -
FF_MULTI_SELECT
public static final int FF_MULTI_SELECTIf true, more than one of the field's option items may be selected simultaneously. If false, at most one item shall be selected. -
FF_DO_NOT_SPELL_CHECK
public static final int FF_DO_NOT_SPELL_CHECKIf true, text entered in the field shall be spell-checked. -
FF_COMMIT_ON_SEL_CHANGE
public static final int FF_COMMIT_ON_SEL_CHANGEIf true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).
-
-
Constructor Details
-
PdfChoiceFormField
Creates a minimalPdfChoiceFormField
.- Parameters:
-
pdfDocument
- ThePdfDocument
instance.
-
PdfChoiceFormField
Creates a choice form field as a parent of aPdfWidgetAnnotation
.- Parameters:
-
widget
- The widget which will be a kid of thePdfChoiceFormField
. -
pdfDocument
- ThePdfDocument
instance.
-
PdfChoiceFormField
Creates a choice 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
ReturnsCh
, the form type for choice form fields.- Overrides:
-
getFormType
in classPdfFormField
- Returns:
-
the form type, as a
PdfName
-
setTopIndex
Sets the index of the first visible option in a scrollable list.- Parameters:
-
index
- the index of the first option - Returns:
-
current
PdfChoiceFormField
-
getTopIndex
Gets the current index of the first option in a scrollable list.- Returns:
-
the index of the first option, as a
PdfNumber
-
setIndices
Sets the selected items in the field.- Parameters:
-
indices
- a sorted array of indices representing selected items in the field - Returns:
-
current
PdfChoiceFormField
-
setListSelected
Highlights the options. If this method is used for Combo box, the first value in input array will be the field value.- Parameters:
-
optionValues
- Array of display values to be highlighted. - Returns:
-
current
PdfChoiceFormField
.
-
setListSelected
Highlights the options and generates field appearance if needed. If this method is used for Combo box, the first value in input array will be the field value- Parameters:
-
optionValues
- Array of options to be highlighted -
generateAppearance
- if false, appearance won't be regenerated - Returns:
-
current
PdfChoiceFormField
-
setListSelected
Highlights the options. If this method is used for Combo box, the first value in input array will be the field value- Parameters:
-
optionNumbers
- The option numbers - Returns:
-
The edited
PdfChoiceFormField
-
getIndices
Gets the currently selected items in the field- Returns:
- a sorted array of indices representing the currently selected items in the field
-
setCombo
If true, the field is a combo box; if false, the field is a list box.- Parameters:
-
combo
- whether or not the field should be a combo box - Returns:
-
current
PdfChoiceFormField
-
isCombo
public boolean isCombo()If true, the field is a combo box; if false, the field is a list box.- Returns:
- whether or not the field is now a combo box.
-
setEdit
If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true.- Parameters:
-
edit
- whether or not to add an editable text box - Returns:
-
current
PdfChoiceFormField
-
isEdit
public boolean isEdit()If true, the combo box shall include an editable text box as well as a drop-down list; if false, it shall include only a drop-down list. This flag shall be used only if the Combo flag is true.- Returns:
- whether or not there is currently an editable text box
-
setSort
If true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers.- Parameters:
-
sort
- whether or not to sort the items - Returns:
-
current
PdfChoiceFormField
-
isSort
public boolean isSort()If true, the field's option items shall be sorted alphabetically. This flag is intended for use by writers, not by readers.- Returns:
- whether or not the items are currently sorted
-
setMultiSelect
If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.- Parameters:
-
multiSelect
- whether or not to allow multiple selection - Returns:
-
current
PdfChoiceFormField
-
isMultiSelect
public boolean isMultiSelect()If true, more than one of the field's option items may be selected simultaneously; if false, at most one item shall be selected.- Returns:
- whether or not multiple selection is currently allowed
-
setSpellCheck
If true, text entered in the field shall be spell-checked.- Parameters:
-
spellCheck
- whether or not to require the PDF viewer to perform a spell check - Returns:
-
current
PdfChoiceFormField
-
isSpellCheck
public boolean isSpellCheck()If true, text entered in the field shall be spell-checked..- Returns:
- whether or not PDF viewer must perform a spell check
-
setCommitOnSelChange
If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).- Parameters:
-
commitOnSelChange
- whether or not to save changes immediately - Returns:
-
current
PdfChoiceFormField
-
isCommitOnSelChange
public boolean isCommitOnSelChange()If true, the new value shall be committed as soon as a selection is made (commonly with the pointing device).- Returns:
- whether or not to save changes immediately
-