Class FormElement

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyChangeListener​(java.beans.PropertyChangeListener l)
      Add a PropertyChangeListener to this FormElement.
      protected java.lang.Object clone()  
      FormElement duplicate()
      Create an exact copy of this FormElement, but with no annotations
      void flatten()
      Flatten the form field so that the contents of it's annotation are permanently stamped on the page.
      PDFAction getAction​(Event event)
      Get the action that's performed when the specified event takes place on this field.
      WidgetAnnotation getAnnotation​(int annot)
      Return the specified annotation.
      java.util.List<WidgetAnnotation> getAnnotations()
      Return a list of all the annotations associated with this form element.
      java.lang.String getDescription()
      Return the text description of this field if specified, or null if no description is supplied.
      Form getForm()
      Return the form this form element belongs to
      abstract java.lang.String getValue()
      Return the value for this element.
      boolean isReadOnly()
      Get whether the field is read-only or not.
      boolean isRequired()
      Get whether the field is required before the form is submitted.
      boolean isSubmitted()
      Get whether the field is submitted or not.
      void putLiteral​(java.lang.String key, java.lang.String tokens)
      Put a literal token sequnce.
      void rebuild()
      Cause the annotation list to be rebuilt.
      void removePropertyChangeListener​(java.beans.PropertyChangeListener l)
      Remove a previously added PropertyChangeListener form this FormElement.
      void setAction​(Event event, PDFAction action)
      Set the action to perform when the specified event takes place on this field.
      void setDescription​(java.lang.String s)
      Set the text description of this field.
      void setReadOnly​(boolean readonly)
      Set whether the field is read-only or not.
      void setRequired​(boolean required)
      Set whether the field is required before the form is submitted.
      void setSubmitted​(boolean submit)
      Set whether the field is submitted or not.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • duplicate

        public FormElement duplicate()
        Create an exact copy of this FormElement, but with no annotations
        Since:
        2.10.6
      • getForm

        public Form getForm()
        Return the form this form element belongs to
        Since:
        2.0
      • getAnnotations

        public java.util.List<WidgetAnnotation> getAnnotations()
        Return a list of all the annotations associated with this form element. The list contains zero or more WidgetAnnotation objects, which may be accessed from this list or via the convenience method getAnnotation(int). The resulting list may have elements removed or reordered, although adding non-widget annotations, null objects or widgets from a different field will result in an Exception.
        Since:
        2.0 (prior to 2.0, this method returned an array of PDFAnnotation objects.
      • getAnnotation

        public WidgetAnnotation getAnnotation​(int annot)
        Return the specified annotation. Identical to getAnnotations().get(annot)
        Since:
        2.0
      • getValue

        public abstract java.lang.String getValue()
        Return the value for this element. Not all elements have a value returned by this method - for example, both FormButton and FormSignature return null from this method. See the method contract in each subclass for more detail.
        Since:
        2.0
      • getDescription

        public java.lang.String getDescription()
        Return the text description of this field if specified, or null if no description is supplied.
        Since:
        2.0
      • setDescription

        public void setDescription​(java.lang.String s)
        Set the text description of this field. Value may be null to remove it.
        Since:
        2.0
      • setReadOnly

        public void setReadOnly​(boolean readonly)
        Set whether the field is read-only or not.
        Parameters:
        readonly - whether the field is read-only or not
        Since:
        1.1.23
      • isReadOnly

        public boolean isReadOnly()
        Get whether the field is read-only or not.
        Returns:
        true if the field is read-only
        Since:
        1.1.23
      • setRequired

        public void setRequired​(boolean required)
        Set whether the field is required before the form is submitted. For some fields like pushbuttons, this method has no effect.
        Parameters:
        required - whether the field is a required field or not
        Since:
        1.1.23
      • isRequired

        public boolean isRequired()
        Get whether the field is required before the form is submitted. For some fields like pushbuttons, this method always returns false.
        Returns:
        true if the field is required on form submission
        Since:
        1.1.23
      • setSubmitted

        public void setSubmitted​(boolean submit)
        Set whether the field is submitted or not. The default for every element in the form is true.
        Parameters:
        submit - whether the element is submitted or not.
        Since:
        1.1.23
      • isSubmitted

        public boolean isSubmitted()
        Get whether the field is submitted or not.
        Returns:
        true if the field is submitted, false otherwise
        Since:
        1.1.23
      • rebuild

        public void rebuild()
        Cause the annotation list to be rebuilt. Unless you're rendering the annotation using the viewer, it's not necessary to call this method.
        Since:
        2.8
      • flatten

        public void flatten()
        Flatten the form field so that the contents of it's annotation are permanently stamped on the page. The field's annotations are removed, but the field is not removed from the form - this must be done manually. Usually it's more convenient to flatten the entire form in one go, by calling the Form.flatten() method.
        Since:
        2.0
        See Also:
        PDFAnnotation.flatten(), Form.flatten()
      • toString

        public java.lang.String toString()
      • putLiteral

        public void putLiteral​(java.lang.String key,
                               java.lang.String tokens)
        Put a literal token sequnce. For debugging
        Parameters:
        key - the key
        tokens - the token sequence, eg "true" or "/foo" or "[/Foo/Bar]". No refs, just direct objects.
      • clone

        protected java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object