Package com.itextpdf.forms.fields
Class PdfButtonFormField
java.lang.Object
com.itextpdf.kernel.pdf.PdfObjectWrapper<PdfDictionary>
com.itextpdf.forms.fields.AbstractPdfFormField
com.itextpdf.forms.fields.PdfFormField
com.itextpdf.forms.fields.PdfButtonFormField
An interactive control on the screen that raises events and/or can retain data.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
If true, clicking the selected button deselects it, leaving no button selected.static final int
If true, the field is a push button that does not retain a permanent value.static final int
If true, the field is a set of radio buttons.static final int
If true, 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.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
PdfButtonFormField
(PdfWidgetAnnotation widget, PdfDocument pdfDocument) Creates a button form field as a parent of aPdfWidgetAnnotation
.protected
PdfButtonFormField
(PdfDictionary pdfObject) Creates a button form field as a wrapper object around aPdfDictionary
.protected
PdfButtonFormField
(PdfDocument pdfDocument) Creates a minimalPdfButtonFormField
. -
Method Summary
Modifier and TypeMethodDescriptionAdds a new kid to theKids
array property from aAbstractPdfFormField
.ReturnsBtn
, the form type for choice form fields.boolean
If true, the field is a pushbutton that does not retain a permanent value.boolean
isRadio()
If true, the field is a set of radio buttons; if false, the field is a check box.boolean
If true, 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.boolean
If true, clicking the selected button deselects it, leaving no button selected.Set image to be used as a background content in a push button.setImageAsForm
(PdfFormXObject form) Set image to be used as a background content in a push button asPdfFormXObject
.setPushButton
(boolean pushButton) If true, the field is a pushbutton that does not retain a permanent value.setRadio
(boolean radio) If true, the field is a set of radio buttons; if false, the field is a check box.setRadiosInUnison
(boolean radiosInUnison) If true, 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.setToggleOff
(boolean toggleOff) If true, clicking the selected button deselects it, leaving no button selected.Methods inherited from class com.itextpdf.forms.fields.PdfFormField
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_NO_TOGGLE_TO_OFF
public static final int FF_NO_TOGGLE_TO_OFFIf true, clicking the selected button deselects it, leaving no button selected. If false, exactly one radio button shall be selected at all times. -
FF_RADIO
public static final int FF_RADIOIf true, the field is a set of radio buttons. If false, the field is a check box. This flag should be set only if theFF_PUSH_BUTTON
flag is set to false. -
FF_PUSH_BUTTON
public static final int FF_PUSH_BUTTONIf true, the field is a push button that does not retain a permanent value. -
FF_RADIOS_IN_UNISON
public static final int FF_RADIOS_IN_UNISONIf true, 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 false, the buttons are mutually exclusive.
-
-
Constructor Details
-
PdfButtonFormField
Creates a minimalPdfButtonFormField
.- Parameters:
-
pdfDocument
- ThePdfDocument
instance.
-
PdfButtonFormField
Creates a button form field as a parent of aPdfWidgetAnnotation
.- Parameters:
-
widget
- The widget which will be a kid of thePdfButtonFormField
. -
pdfDocument
- ThePdfDocument
instance.
-
PdfButtonFormField
Creates a button 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
ReturnsBtn
, the form type for choice form fields.- Overrides:
-
getFormType
in classPdfFormField
- Returns:
-
the form type, as a
PdfName
-
isRadio
public boolean isRadio()If true, the field is a set of radio buttons; if false, the field is a check box. This flag only works if the Pushbutton flag is set to false.- Returns:
- whether the field is currently radio buttons or a checkbox
-
setRadio
If true, the field is a set of radio buttons; if false, the field is a check box. This flag should be set only if the Pushbutton flag is set to false.- Parameters:
-
radio
- whether the field should be radio buttons or a checkbox - Returns:
-
current
PdfButtonFormField
-
isToggleOff
public boolean isToggleOff()If true, clicking the selected button deselects it, leaving no button selected. If false, exactly one radio button shall be selected at all times. Only valid for radio buttons.- Returns:
- whether a radio button currently allows to choose no options
-
setToggleOff
If true, clicking the selected button deselects it, leaving no button selected. If false, exactly one radio button shall be selected at all times.- Parameters:
-
toggleOff
- whether a radio button may allow to choose no options - Returns:
-
current
PdfButtonFormField
-
isPushButton
public boolean isPushButton()If true, the field is a pushbutton that does not retain a permanent value.- Returns:
- whether or not the field is currently a pushbutton
-
setPushButton
If true, the field is a pushbutton that does not retain a permanent value.- Parameters:
-
pushButton
- whether or not to set the field to a pushbutton - Returns:
-
current
PdfButtonFormField
-
isRadiosInUnison
public boolean isRadiosInUnison()If true, 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 false, the buttons are mutually exclusive- Returns:
- whether or not buttons are turned off in unison
-
setRadiosInUnison
If true, 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 false, the buttons are mutually exclusive- Parameters:
-
radiosInUnison
- whether or not buttons should turn off in unison - Returns:
-
current
PdfButtonFormField
-
setImage
Set image to be used as a background content in a push button.- Parameters:
-
image
- path to the image to be used. - Returns:
-
this
PdfButtonFormField
- Throws:
-
IOException
- if provided path to the image is not correct
-
setImageAsForm
Set image to be used as a background content in a push button asPdfFormXObject
.- Parameters:
-
form
-PdfFormXObject
to be used as an image - Returns:
-
this
PdfButtonFormField
-
addKid
Adds a new kid to theKids
array property from aAbstractPdfFormField
. Also sets the kid'sParent
property to this object.- Overrides:
-
addKid
in classPdfFormField
- Parameters:
-
kid
- a newAbstractPdfFormField
entry for the field'sKids
array property. - Returns:
-
the edited
PdfFormField
.
-