com.justformspdf.pdf
Class FormElement

java.lang.Object
  |
  +--com.justformspdf.lib.PDFObjectImp
        |
        +--com.justformspdf.lib.PDFObjectGeneric
              |
              +--com.justformspdf.pdf.FormElement
All Implemented Interfaces:
com.justformspdf.lib.PDFObject
Direct Known Subclasses:
FormButton, FormCheckbox, FormRadioGroup, FormText

public abstract class FormElement
extends com.justformspdf.lib.PDFObjectGeneric

The FormElement class is the class from which all classes representing various form elements are derived. User accessing a form element (from the Form object) of a specific type must type cast it to the matching class.

Here is an example showing a Text Box form element is being accessed and type casted to FormText.

 
 FileInputStream fis = new FileInputStream("C:\\JustFormsPDF\\examples\\AddressForm32A2.pdf"); 
 PDF pdf = new PDF(new PDFReader(fis));
 Form form = pdf.getForm();             
 FormText text = (FormText) form.getElement("Name");
 text.setValue("John K. Baker");
 
 


Field Summary
static int JUSTIFICATION_CENTER
           
static int JUSTIFICATION_LEFT
           
static int JUSTIFICATION_RIGHT
           
  
Constructor Summary
FormElement(java.lang.String name)
           
 
Method Summary
 java.lang.String getName()
          Get name of this form element.
java.lang.String getType()
          Get form element type
java.lang.String getRect()
          Get rectangular coordinates
 java.lang.String getValue()
          Get value (text) of this form element.
 void setValue(java.lang.String value)
          Set value of a form element.
 void setReadOnly(boolean)
          Set the "ReadOnly" flag of a form element.
 boolean isReadOnly()
          Get the value of "ReadOnly" flag.
    

Field Detail

JUSTIFICATION_LEFT

public static int JUSTIFICATION_LEFT

JUSTIFICATION_CENTER

public static int JUSTIFICATION_CENTER

JUSTIFICATION_RIGHT

public static int JUSTIFICATION_RIGHT
Constructor Detail

FormElement

public FormElement(java.lang.String name)
Method Detail

getName

public java.lang.String getName()
Get name of this form element.

Returns:
name

getType

public java.lang.String getType()
Get type of this form element.

Returns:
type - type can be one of the following values (as String types):
(Text, Check, Combo, Radio, Button, UNKNOWN)
 

getRect

public java.lang.String getRect()
Get rectangular coordinates of the location this form element.

Returns:
rect - the rectangular coordinates as String of the following forms
[ x1, y1, x2, y2]
where x1 and y1 are coordiantes of the lower-left corner and
y1 and y2 are coordinates of the upper-right corner.
 



getValue

public java.lang.String getValue()
Get value (text) of this form element.

Returns:
value

setValue

public void setValue(java.lang.String value)
              throws java.lang.Exception
Set value of a form element. This method is applibale to all the form elements FormText, FormCheckBox, FormComboBox, FormButton and FormRadioGroup.

Parameters:
value - form element value
Throws:
java.lang.Exception

setReadOnly

public void setReadOnly(boolean flag)
             
Set the "ReadOnly" flag of a form element. This method is applibale to all the form elements FormText, FormCheckBox, FormComboBox, FormButton and FormRadioGroup.

Parameters:
falg - "ReadOnly" flag. true = ReadOnly, false = Read/Write
 

isReadOnly

public boolean isReadOnly()
             
Get the value of "ReadOnly" flag of a form element. This method is applibale to all the form elements FormText, FormCheckBox, FormComboBox, FormButton and FormRadioGroup.

Returns:
falg - "ReadOnly" flag of a form element. true = ReadOnly, false = Read/Write