Class FormElement

    • 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 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 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 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​(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 String toString()
      • putLiteral

        public void putLiteral​(String key,
                               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.