Class PDCheckbox
- 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.PDCheckbox
-
- All Implemented Interfaces:
COSObjectable
public final class PDCheckbox extends PDButton
A check box toggles between two states, on and off.
-
-
Field Summary
-
Fields inherited from class com.tom_roush.pdfbox.pdmodel.interactive.form.PDField
acroForm, dictionary, parent
-
-
Constructor Summary
Constructors Constructor Description PDCheckbox(PDAcroForm acroForm)PDCheckbox(PDAcroForm acroForm, COSDictionary field, PDNonTerminalField parent)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheck()Checks the check box.StringgetDefaultValue()Returns the default value, if any.StringgetOnValue()Get the value which sets the check box to the On state.Set<String>getOnValues()Get the values which sets the check box to the On state.StringgetValue()Returns the fields value entry.StringgetValueAsString()Returns a string representation of the "V" entry, or an empty string.booleanisChecked()This will tell if this radio button is currently checked or not.voidsetDefaultValue(String value)Sets the default value.voidsetValue(String value)Sets the checked value of this field.voidunCheck()Unchecks the check box.-
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
-
PDCheckbox
public PDCheckbox(PDAcroForm acroForm)
- Parameters:
acroForm- The acroform.- See Also:
PDField(PDAcroForm)
-
PDCheckbox
public PDCheckbox(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
-
isChecked
public boolean isChecked()
This will tell if this radio button is currently checked or not. This is equivalent to callinggetValue().- Returns:
- true If this field is checked.
-
check
public void check() throws IOExceptionChecks the check box.- Throws:
IOException- if the appearance couldn't be generated.
-
unCheck
public void unCheck() throws IOExceptionUnchecks the check box.- Throws:
IOException- if the appearance couldn't be generated.
-
getValue
public String getValue()
Returns the fields value entry.- Returns:
- the fields value entry.
-
getDefaultValue
public String getDefaultValue()
Returns the default value, if any.- Returns:
- the fields default value.
-
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 checked value of this field.To retrieve the potential On value use
getOnValue()orgetOnValues(). The Off value shall always be 'Off'.- Parameters:
value- matching the On or Off state of the checkbox.- Throws:
IOException- if the appearance couldn't be generated.IllegalArgumentException- if the value is not a valid option for the checkbox.
-
setDefaultValue
public void setDefaultValue(String value)
Sets the default value.- Parameters:
value- matching the On or Off state of the checkbox.- See Also:
setValue(String)
-
getOnValue
public String getOnValue()
Get the value which sets the check box to the On state.The On value should be 'Yes' but other values are possible so we need to look for that. On the other hand 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.
- Throws:
IOException- if the value could not be set
-
getOnValues
public Set<String> getOnValues()
Get the values which sets the check box to the On state.This is a convenience function to provide a similar method to
PDRadioButton- Returns:
- the value setting the check box to the On state. If an empty List is returned there is no appearance definition.
- Throws:
IOException- if the value could not be set- See Also:
getOnValue()
-
-