Class PDRadioButton
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.interactive.form.PDField
-
- org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField
-
- org.apache.pdfbox.pdmodel.interactive.form.PDButton
-
- org.apache.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 Modifier and Type Field Description private static int
FLAG_NO_TOGGLE_TO_OFF
A Ff flag.-
Fields inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDButton
FLAG_PUSHBUTTON, FLAG_RADIO, FLAG_RADIOS_IN_UNISON
-
-
Constructor Summary
Constructors Constructor Description PDRadioButton(PDAcroForm acroForm)
PDRadioButton(PDAcroForm acroForm, COSDictionary field, PDNonTerminalField parent)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<java.lang.String>
getSelectedExportValues()
This will get the selected export values.int
getSelectedIndex()
This will get the selected index.boolean
isRadiosInUnison()
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.-
Methods inherited from class org.apache.pdfbox.pdmodel.interactive.form.PDButton
checkValue, constructAppearances, getDefaultValue, getExportValues, getOnValues, getValue, getValueAsString, isPushButton, isRadioButton, setDefaultValue, setExportValues, setPushButton, setRadioButton, setValue, setValue
-
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 Detail
-
FLAG_NO_TOGGLE_TO_OFF
private static final int FLAG_NO_TOGGLE_TO_OFF
A Ff flag.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PDRadioButton
public PDRadioButton(PDAcroForm acroForm)
- Parameters:
acroForm
- The acroform.- See Also:
PDField(PDAcroForm)
-
PDRadioButton
PDRadioButton(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 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.
-
getSelectedIndex
public int getSelectedIndex()
This will get the selected index.A RadioButton might have multiple same value options which are not selected jointly if they are not set in unison
isRadiosInUnison()
.The method will return the first selected index or -1 if no option is selected.
- Returns:
- the first selected index or -1.
-
getSelectedExportValues
public java.util.List<java.lang.String> getSelectedExportValues() throws java.io.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:
java.io.IOException
- in case the fields value can not be retrieved
-
-