- All Implemented Interfaces:
COSObjectable
- Direct Known Subclasses:
PDComboBox,PDListBox
- Author:
- sug, John Hewson
-
Field Summary
Fields inherited from class org.sejda.sambox.pdmodel.interactive.form.PDVariableText
QUADDING_CENTERED, QUADDING_LEFT, QUADDING_RIGHT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the default values, or an empty List.This will get the option values "Opt".This will get the display values from the options.This will get the export values from the options.This will get the indices of the selected options - the 'I' key.getValue()Returns the selected values, or an empty List.Returns a string representation of the "V" entry, or an empty string.booleanisCombo()Determines if Combo is set.booleanDetermines if CommitOnSelChange is set.booleanDetermines if DoNotSpellCheck is set.booleanDetermines if MultiSelect is set.booleanisSort()Determines if Sort is set.voidsetCombo(boolean combo) Set the Combo bit.voidsetCommitOnSelChange(boolean commitOnSelChange) Set the CommitOnSelChange bit.voidsetDefaultValue(String value) Sets the default value of this field.voidsetDoNotSpellCheck(boolean doNotSpellCheck) Set the DoNotSpellCheck bit.voidsetMultiSelect(boolean multiSelect) Set the MultiSelect bit.voidsetOptions(List<String> displayValues) This will set the display values - the 'Opt' key.voidsetOptions(List<String> exportValues, List<String> displayValues) This will set the display and export values - the 'Opt' key.voidsetSelectedOptionsIndex(List<Integer> values) This will set the indices of the selected options - the 'I' key.voidsetSort(boolean sort) Set the Sort bit.voidSets the selected value of this field.voidSets the entry "V" to the given values.Methods inherited from class org.sejda.sambox.pdmodel.interactive.form.PDVariableText
getAppearanceFont, getAppearanceOverrideFont, getDefaultAppearance, getDefaultStyleString, getQ, getRichTextValue, getStringOrStream, setAppearanceOverrideFont, setDefaultAppearance, setDefaultStyleString, setQ, setRichTextValueMethods inherited from class org.sejda.sambox.pdmodel.interactive.form.PDTerminalField
addWidgetIfMissing, applyChange, getFieldFlags, getFieldType, getWidgets, isTerminal, removeWidget, setActions, setWidgetsMethods inherited from class org.sejda.sambox.pdmodel.interactive.form.PDField
getAcroForm, getActions, getAlternateFieldName, getFullyQualifiedName, getInheritableAttribute, getMappingName, getParent, getPartialName, isNoExport, isReadonly, isRequired, setAlternateFieldName, setFieldFlags, setMappingName, setNoExport, setPartialName, setReadonly, setRequired, toStringMethods inherited from class org.sejda.sambox.pdmodel.common.PDDictionaryWrapper
equals, getCOSObject, hashCode
-
Constructor Details
-
PDChoice
- Parameters:
acroForm- The acroform.- See Also:
-
PDField(PDAcroForm)
-
-
Method Details
-
getOptions
This will get the option values "Opt".For a choice field the options array can either be an array of text strings or an array of a two-element arrays.
The method always only returns either the text strings or, in case of two-element arrays, an array of the first element of the two-element arraysUse
getOptionsExportValues()andgetOptionsDisplayValues()to get the entries of two-element arrays.- Returns:
- List containing the export values.
-
setOptions
This will set the display values - the 'Opt' key.The Opt array specifies the list of options in the choice field either as an array of text strings representing the display value or as an array of a two-element array where the first element is the export value and the second the display value.
To set both the export and the display value use
setOptions(List, List)- Parameters:
displayValues- List containing all possible options.
-
setOptions
This will set the display and export values - the 'Opt' key.This will set both, the export value and the display value of the choice field. If either one of the parameters is null or an empty list is supplied the options will be removed.
An
IllegalArgumentExceptionwill be thrown if the number of items in the list differ.- Parameters:
exportValues- List containing all possible export values.displayValues- List containing all possible display values.- See Also:
-
getOptionsDisplayValues
This will get the display values from the options.For options with an array of text strings the display value and export value are the same.
For options with an array of two-element arrays the display value is the second entry in the two-element array.- Returns:
- List containing all the display values.
-
getOptionsExportValues
This will get the export values from the options.For options with an array of text strings the display value and export value are the same.
For options with an array of two-element arrays the export value is the first entry in the two-element array.- Returns:
- List containing all export values.
-
getSelectedOptionsIndex
This will get the indices of the selected options - the 'I' key.This is only needed if a choice field allows multiple selections and two different items have the same export value or more than one values is selected.
The indices are zero-based
- Returns:
- List containing the indices of all selected options.
-
setSelectedOptionsIndex
This will set the indices of the selected options - the 'I' key.This method is preferred over
setValue(List)for choice fields which- do support multiple selections
- have export values with the same value
Setting the index will set the value too.
- Parameters:
values- List containing the indices of all selected options.
-
isSort
public boolean isSort()Determines if Sort is set.If set, the field’s option items shall be sorted alphabetically. The sorting has to be done when writing the PDF. PDF Readers are supposed to display the options in the order in which they occur in the Opt array.
- Returns:
- true if the options are sorted.
-
setSort
public void setSort(boolean sort) Set the Sort bit.- Parameters:
sort- The value for Sort.- See Also:
-
isMultiSelect
public boolean isMultiSelect()Determines if MultiSelect is set.- Returns:
- true if multi select is allowed.
-
setMultiSelect
public void setMultiSelect(boolean multiSelect) Set the MultiSelect bit.- Parameters:
multiSelect- The value for MultiSelect.
-
isDoNotSpellCheck
public boolean isDoNotSpellCheck()Determines if DoNotSpellCheck is set.- Returns:
- true if spell checker is disabled.
-
setDoNotSpellCheck
public void setDoNotSpellCheck(boolean doNotSpellCheck) Set the DoNotSpellCheck bit.- Parameters:
doNotSpellCheck- The value for DoNotSpellCheck.
-
isCommitOnSelChange
public boolean isCommitOnSelChange()Determines if CommitOnSelChange is set.- Returns:
- true if value shall be committed as soon as a selection is made.
-
setCommitOnSelChange
public void setCommitOnSelChange(boolean commitOnSelChange) Set the CommitOnSelChange bit.- Parameters:
commitOnSelChange- The value for CommitOnSelChange.
-
isCombo
public boolean isCombo()Determines if Combo is set.- Returns:
- true if value the choice is a combo box..
-
setCombo
public void setCombo(boolean combo) Set the Combo bit.- Parameters:
combo- The value for Combo.
-
setValue
Sets the selected value of this field.- Specified by:
setValuein classPDField- Parameters:
value- The name of the selected item.- Throws:
IOException- if the value could not be set
-
setDefaultValue
Sets the default value of this field.- Parameters:
value- The name of the selected item.- Throws:
IOException- if the value could not be set
-
setValue
Sets the entry "V" to the given values. RequiresisMultiSelect()to be true.- Parameters:
values- the list of values- Throws:
IOException
-
getValue
Returns the selected values, or an empty List. This list always contains a single item unlessisMultiSelect()is true.- Returns:
- A non-null string.
-
getDefaultValue
Returns the default values, or an empty List. This list always contains a single item unlessisMultiSelect()is true.- Returns:
- A non-null string.
-
getValueAsString
Description copied from class:PDFieldReturns a string representation of the "V" entry, or an empty string.- Specified by:
getValueAsStringin classPDField- Returns:
- A non-null string.
-