Package org.faceless.pdf2
Class FormButton
- java.lang.Object
-
- org.faceless.pdf2.FormElement
-
- org.faceless.pdf2.FormButton
-
- All Implemented Interfaces:
Cloneable
public final class FormButton extends FormElement
A type of
FormElementrepresenting a "Push Button", of the kind used to trigger an action like submitting or resetting a form.A push buttons has no value - it's
getValue()method will always returnnull. However, eachWidgetAnnotationreturned by theFormElement.getAnnotations()method may have a different value specified - although these values are not submitted with the form. Buttons may also have images associated with them, which can be set via theWidgetAnnotation.setButtonImage(org.faceless.pdf2.PDFImage)method.Here's an example showing how to add a pushbutton which submits the form.
PDFAction act = PDFAction.formSubmit("/servlet/Submit", PDFAction.METHOD_HTTP_POST)); Form form = pdf.getForm(); FormButton button = new FormButton(); WidgetAnnotation annot = button.addAnnotation(pdf.getLastPage(), 100,100,200,120); annot.setValue("Submit"); annot.setAction(Event.MOUSEUP, act); form.addElement("SubmitButton", button);- Since:
- 1.1.23
-
-
Constructor Summary
Constructors Constructor Description FormButton()Create a new FormButton element.FormButton(PDFPage page, float x1, float y1, float x2, float y2)Create a new FormButton element, and add a single annotation at the specified position.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WidgetAnnotationaddAnnotation(PDFPage page, float x1, float y1, float x2, float y2)Add an annotation for this Form element at the specified position on the specified page.protected Objectclone()StringgetValue()FormButtonelements don't have a value, so this method always returnsnull- try calling theWidgetAnnotation.getValue()method on theWidgetAnnotationclass to get back the text label of a button.booleanisRTL()Return true if this text field is marked as right-to-left.voidrebuild()Cause the annotation list to be rebuilt.voidsetRTL(boolean rtl)Set the field to be right-to-left.StringtoString()-
Methods inherited from class org.faceless.pdf2.FormElement
addPropertyChangeListener, duplicate, flatten, getAction, getAnnotation, getAnnotations, getDescription, getForm, isReadOnly, isRequired, isSubmitted, removePropertyChangeListener, setAction, setDescription, setReadOnly, setRequired, setSubmitted
-
-
-
-
Constructor Detail
-
FormButton
public FormButton()
Create a new FormButton element. With this constructor at least one annotation must be added explicitly by calling theaddAnnotationmethod- Since:
- 1.1.26
-
FormButton
public FormButton(PDFPage page, float x1, float y1, float x2, float y2)
Create a new FormButton element, and add a single annotation at the specified position. Equivalent toFormButton button = new FormButton(); button.addAnnotation(page,x1,y1,x2,y2);
- Parameters:
page- the page to place the annotation onx1- the left-most X co-ordinate of the annotationy1- the top-most Y co-ordinate of the annotationx2- the right-most X co-ordinate of the annotationy2- the bottom-most Y co-ordinate of the annotation
-
-
Method Detail
-
isRTL
public boolean isRTL()
Return true if this text field is marked as right-to-left. This is an undocumented and non-standard flag, but is used by Acrobat to create RTL fields.- Since:
- 2.20.3
-
setRTL
public void setRTL(boolean rtl)
Set the field to be right-to-left. This is an undocumented and non-standard flag, but is used by Acrobat to create RTL fields.- Since:
- 2.20.3
-
addAnnotation
public WidgetAnnotation addAnnotation(PDFPage page, float x1, float y1, float x2, float y2)
Add an annotation for this Form element at the specified position on the specified page.- Parameters:
page- the page to place the annotation onx1- the left-most X co-ordinate of the annotationy1- the top-most Y co-ordinate of the annotationx2- the right-most X co-ordinate of the annotationy2- the bottom-most Y co-ordinate of the annotation- Since:
- 2.0
-
getValue
public String getValue()
FormButtonelements don't have a value, so this method always returnsnull- try calling theWidgetAnnotation.getValue()method on theWidgetAnnotationclass to get back the text label of a button.- Specified by:
getValuein classFormElement
-
rebuild
public void rebuild()
Description copied from class:FormElementCause the annotation list to be rebuilt. Unless you're rendering the annotation using the viewer, it's not necessary to call this method.- Overrides:
rebuildin classFormElement
-
toString
public String toString()
-
-