Class FormButton

  • All Implemented Interfaces:
    Cloneable

    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);
     
    Since:
    1.1.23
    • Constructor Detail

      • FormButton

        public FormButton()
        Create a new FormButton element. With this constructor at least one annotation must be added explicitly by calling the addAnnotation method
        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 to
          FormButton button = new FormButton();
          button.addAnnotation(page,x1,y1,x2,y2);
         
        Parameters:
        page - the page to place the annotation on
        x1 - the left-most X co-ordinate of the annotation
        y1 - the top-most Y co-ordinate of the annotation
        x2 - the right-most X co-ordinate of the annotation
        y2 - 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 on
        x1 - the left-most X co-ordinate of the annotation
        y1 - the top-most Y co-ordinate of the annotation
        x2 - the right-most X co-ordinate of the annotation
        y2 - the bottom-most Y co-ordinate of the annotation
        Since:
        2.0
      • rebuild

        public void rebuild()
        Description copied from class: FormElement
        Cause the annotation list to be rebuilt. Unless you're rendering the annotation using the viewer, it's not necessary to call this method.
        Overrides:
        rebuild in class FormElement
      • toString

        public String toString()