Starting with version 1.5 you can create PDF forms using J4L FO
Designer (Suite edition), however this requires that you use our
FOP server since the generation of PDF forms is not part of the
You will find an introduction to the usage of and motivations for PDF forms at this page in our site.
Note the generation of forms requires the suite or enterprise license and the use of J4L FOP Server.
The highlighted objects in the toolbar can be used for data entry:
Text fields and combo boxes are normally used to display data. In order to activate them for data entry the "Input field" property must be set to yes.
Input fields have a green border in the designer.
Text fields can be used to allow free entry of data. The following properties are available for these kind of input fields:
The default value of the text field will be the constant one (see value property) or the one returned by the Xpath.
This kind of fields offer a list of values the user can select. They behave in a similar way as text fields.
Checkboxes are input fields which can only contain the value true or false (selected or not selected).
Button objects are used to execute actions. The actions available at this time are:
There are several ways to submit the forms:
The option (4 or partly 2) that requires you to save the filled form to a PDF file has a potential issue. If you use Adobe Reader you will get an error like this one "You cannot saved data typed into this form".
The reason for this is, Adobe Reader allows saving filled forms only if the forms has been created and digitally signed by Adobe tools. At this point you have some options:
The PDF form can be submitted in several ways:
There are several formats which can be used to receive the form data:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <formData>
<fields>
<field name="fieldname1"><value>value1</value></field> <field name="fieldname2"><value>value2</value></field>
...
<fields>
</formData>
import
com.java4less.xreport.fop.FormValuesExtractor;
....
FormValuesExtractor extractor=new FormValuesExtractor(); FileInputStream is=new FileInputStream("myform.pdf"); Hashtable fieldsTable=extractToTable(is);
Enumeration enum=fieldsTable.keys(); while (enum.hasMoreElements()) {
String
key=(String)
enum.nextElement(); System.out.println("Field
"+key+"="+fieldsTable.get(key));
}
The order_form.xre example shows how the input fields can be used. The example contains one input field of each type, furthermore it shows how fields can be repeated in the detail area.
The example contains no submit button since it assumes the user will fill the form with a PDF reader that can save forms (see the Filling forms section) and submit the saved PDF by email. This example is an order form which:
the screenshot shows how the PDF form has been filled and can be saved using Nitro PDF Reader:
As last step the filled forms has been received by the
selling company and the values of the PDF can be extracted
(see section Form submission). We include a simple HTML page
inside J4LFOPServer.war which calls our form
extractor server:
once submitted the server returns the form content as XML, note field names have a suffix ( _1 ,_2 ..) because fields in a detail section (like the items in a purchase order) can be repeated:
By default all input fields in a form will be stored as an
list in the PDF form (Flat form). If you would use a PDF
analizer tool, you would see the internal list of fields:
It is however possible to create a hierarchical structure for
the field in the form. This can be achieved by removing
the Flat form flag in the report‘s properties.
After removing the flag the created form fields in the PDF
will have the same internal strtucture as the report in the
designer:
that is it will have a tree structure:
• the form header fields will be in the
first level
• the areas will be a node in the tree
• for each repetition of the area there
will be a record node
• finally for each record there will be
list of form fields
The naming of the form input fields (also called terminal
nodes) and areas/record (non-terminal nodes, because the have
children) is as follows:
• for form fields:
<fieldname>_<GeneratedUniqueId>. For example: CustomerID_N10001
• for areas:
<level>_<areacounter>_<GeneratedUniqueId>_AREA.
For example the first detail area after the report header will
be named 1_1_N10001_AREA.
• for records (area repetitions) :
<level>_<areacounter>_<GeneratedUniqueRecordId>_RECORD.
For example the first detail area repetition after the report
header will be called 1_1_N10001_RECORD , the second
repetition of the same area could be 1_1_N102B5_RECORD