Class PDRadioButton
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.interactive.form.PDField
-
- com.tom_roush.pdfbox.pdmodel.interactive.form.PDTerminalField
-
- com.tom_roush.pdfbox.pdmodel.interactive.form.PDButton
-
- com.tom_roush.pdfbox.pdmodel.interactive.form.PDRadioButton
-
- All Implemented Interfaces:
COSObjectable
public final class PDRadioButton extends PDButton
Radio button fields contain a set of related buttons that can each be on or off.
-
-
Field Summary
-
Fields inherited from class com.tom_roush.pdfbox.pdmodel.interactive.form.PDField
acroForm, dictionary, parent
-
-
Constructor Summary
Constructors Constructor Description PDRadioButton(PDAcroForm acroForm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetDefaultValue()Returns the default value, if any.Set<String>getOnValues()Get the values to set individual radio buttons to the on state.List<String>getSelectedExportValues()This will get the selected export values.StringgetValue()Returns the selected value.StringgetValueAsString()Returns a string representation of the "V" entry, or an empty string.booleanisRadiosInUnison()voidsetDefaultValue(String value)Sets the default value.voidsetRadiosInUnison(boolean radiosInUnison)From the PDF Spec
If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked.voidsetValue(String value)Sets the selected radio button, given its name.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from class com.tom_roush.pdfbox.pdmodel.interactive.form.PDButton
getExportValues, isPushButton, isRadioButton, setExportValues, setPushButton, setRadioButton
-
Methods inherited from class com.tom_roush.pdfbox.pdmodel.interactive.form.PDField
getAcroForm, getActions, getAlternateFieldName, getCOSObject, getFullyQualifiedName, getInheritableAttribute, getMappingName, getParent, getPartialName, isNoExport, isReadOnly, isRequired, setAlternateFieldName, setFieldFlags, setMappingName, setNoExport, setPartialName, setReadOnly, setRequired, toString
-
Methods inherited from class com.tom_roush.pdfbox.pdmodel.interactive.form.PDTerminalField
applyChange, getFieldFlags, getFieldType, getWidget, getWidgets, importFDF, setActions, setWidgets
-
-
-
-
Constructor Detail
-
PDRadioButton
public PDRadioButton(PDAcroForm acroForm)
- Parameters:
acroForm- The acroform.- See Also:
PDField(PDAcroForm)
-
-
Method Detail
-
setRadiosInUnison
public void setRadiosInUnison(boolean radiosInUnison)
From the PDF Spec
If set, a group of radio buttons within a radio button field that use the same value for the on state will turn on and off in unison; that is if one is checked, they are all checked. If clear, the buttons are mutually exclusive (the same behavior as HTML radio buttons).- Parameters:
radiosInUnison- The new flag for radiosInUnison.
-
isRadiosInUnison
public boolean isRadiosInUnison()
- Returns:
- true If the flag is set for radios in unison.
-
getSelectedExportValues
public List<String> getSelectedExportValues() throws IOException
This will get the selected export values.A RadioButton might have an export value to allow field values which can not be encoded as PDFDocEncoding or for the same export value being assigned to multiple RadioButtons in a group.
To define an export value the RadioButton must define optionsPDButton.setExportValues(List)which correspond to the individual items within the RadioButton.The method will either return the corresponding values from the options entry or in case there is no such entry the fields value
- Returns:
- the export value of the field.
- Throws:
IOException- in case the fields value can not be retrieved
-
getValue
public String getValue()
Returns the selected value. May be empty if NoToggleToOff is set but there is no value selected.- Returns:
- A non-null string.
-
getDefaultValue
public String getDefaultValue()
Returns the default value, if any.- Returns:
- A non-null string.
-
getValueAsString
public 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.
-
setValue
public void setValue(String value) throws IOException
Sets the selected radio button, given its name.- Parameters:
value- Name of radio button to select- Throws:
IOException- if the value could not be setIllegalArgumentException- if the value is not a valid option.
-
setDefaultValue
public void setDefaultValue(String value)
Sets the default value.- Parameters:
value- Name of radio button to select- Throws:
IOException- if the value could not be setIllegalArgumentException- if the value is not a valid option.
-
getOnValues
public Set<String> getOnValues()
Get the values to set individual radio buttons to the on state.The On value could be an arbitrary string as long as it is within the limitations of a PDF name object. The Off value shall always be 'Off'. If not set or not part of the normal appearance keys 'Off' is the default
- Returns:
- the value setting the check box to the On state. If an empty string is returned there is no appearance definition.
-
-