public final class FormButton extends FormElement
A type of FormElement
representing 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 return
null
. However, each WidgetAnnotation
returned by the FormElement.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 the WidgetAnnotation.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);
Constructor and 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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
String |
getValue()
FormButton elements don't have a value, so this method always
returns null - try calling the WidgetAnnotation.getValue()
method on the WidgetAnnotation class to get back the text label of a
button. |
void |
rebuild()
Cause the annotation list to be rebuilt.
|
String |
toString() |
addPropertyChangeListener, duplicate, flatten, getAction, getAnnotation, getAnnotations, getDescription, getForm, isReadOnly, isRequired, isSubmitted, removePropertyChangeListener, setAction, setDescription, setReadOnly, setRequired, setSubmitted
public FormButton()
addAnnotation
methodpublic FormButton(PDFPage page, float x1, float y1, float x2, float y2)
FormButton button = new FormButton(); button.addAnnotation(page,x1,y1,x2,y2);
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 annotationpublic WidgetAnnotation addAnnotation(PDFPage page, float x1, float y1, float x2, float y2)
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 annotationpublic String getValue()
FormButton
elements don't have a value, so this method always
returns null
- try calling the WidgetAnnotation.getValue()
method on the WidgetAnnotation
class to get back the text label of a
button.getValue
in class FormElement
public void rebuild()
FormElement
rebuild
in class FormElement
public String toString()
Copyright © 2001-2017 Big Faceless Organization