Home Page FO Designer user guide. XSL-FO tool for Oracle APEX and the Java[TM] platform
                                                    FO Designer guide
                                                  • First steps
                                                  • Introduction
                                                  • The user interface
                                                  • Working with the interface
                                                  • Structure of the template
                                                  • Executing the template to create PDF files
                                                  • Learn by doing
                                                  • The invoice IDOC example
                                                  • The Group by example
                                                  • The two columns example
                                                  • Barcodes
                                                  • Charts
                                                  • The running totals example
                                                  • Interactive forms
                                                  • Flavours
                                                  • The base template
                                                  • Long texts and HTML fields
                                                  • The memo field explained
                                                  • Advanced functionalities
                                                  • FOP Could Server
                                                  • Migration of existing XSL-FO files
                                                  • FAQS
                                                  • Troubleshooting
                                                  • Licenses
                                                  • Interactive forms

                                                    13. PDF interactive forms


                                                    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 XSL-FO standard.

                                                    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.

                                                    Form objects

                                                    The highlighted objects in the toolbar can be used for data entry:

                                                    • Text fields.This object is also used in non-form PDF files to display data.
                                                    • Combo boxes. This object is also used in non-form PDF files to display data.
                                                    • Checkbox. This object can be used in forms only.
                                                    • Button (to submit or reset a form). This object can be used in forms only.

                                                    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 field

                                                    Text fields can be used to allow free entry of data. The following properties are available for these kind of input fields:

                                                    • Read only: It is possible to set the field to read only, this is useful to prefill fields which you later can read when the user has submitted the PDF form. The read only field can contain a user id which you would use to identity the form.
                                                    • Is hidden field. If true the field will not be displayed in the PDF reader but the field is still contained in the PDF file.
                                                    • Mandatory: the field must contain a value
                                                    • Multiline: several lines of text can be entered in the field.
                                                    • Max length: maximum number of characters that can be entered

                                                    The default value of the text field will be the constant one (see value property) or the one returned by the Xpath.

                                                    Combo box

                                                    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:

                                                    • reset form to the default values.
                                                    • submit form. In this case you have to enter the url in the "Submit to URL" field. This can be:

                                                      Email address URL, for example:
                                                      • mailto:receiver@company.com?Subject=My%20Order&body=bla
                                                      • A web server HTTP URL, for example http://myserver/submit.

                                                        The submit URL value can also be filled dynamically from the XML data using the Xpath.
                                                    • The submission format, HTML, XML or PDF

                                                    Filling in the form

                                                    There are several ways to submit the forms:

                                                    1. submitting to a web server (as PDF, HTML or XML)
                                                    2. email (as PDF or XML)
                                                    3. printing and sending paper
                                                    4. sending the filled PDF file by any other means

                                                    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:

                                                    1. Buy Adobe LiveCycle reader extensions server which will add the signature to the form.
                                                    2. Use Adobe standard to fill in the form (instead of the free adobe reader)
                                                    3. or use another reader.
                                                      there are several free PDF readers that will allow you to fill and save forms. One of them is Nitro PDF Reader

                                                    Form submission

                                                    The PDF form can be submitted in several ways:

                                                    • to a web server using HTTP
                                                    • by email
                                                    • or saving the filled form to a PDF file and submitting by any other means.

                                                    There are several formats which can be used to receive the form data:

                                                    • ·HTML, the data will be submitted to your web server (the URL you have specified) using the HTTP POST method. The body on the HTTP request will be something like this:

                                                    • XML. The format of the data when submitted using XML is:

                                                    <?xml version="1.0" encoding="UTF-8" standalone="no"?> <formData>


                                                    <field name="fieldname1"><value>value1</value></field> <field name="fieldname2"><value>value2</value></field>




                                                    • PDF. Submitting in PDF format requires you to have a reader that allows you to do that (see previous section), it has the advantage that the user can keep a copy of the same file she has submitted. The receiver of the submitted PDF can also display the received data in a user friendly way.

                                                      In order for your application to extract the content of the submitted PDF you have 2 options:
                                                      • Use our servlet which converts PDF to XML. The file J4LFOPServer.war file contains a servlet, once this file has been deployed to a web server you can reach our servlet in this URL:


                                                        This servlet accepts HTTP POST requests which contain the PDF as body of the request, and returns the XML file with the field values.

                                                        It also accepts files to be uploaded using an HTML form using the parameter FORMMODE=ON, see example FormRead.html inside J4LFOPServer.war.
                                                      • Or use our Java API to extract tha values of the fields. This example shows how to do it:

                                                        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));


                                                    Input form example

                                                    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:

                                                    • Contains a read only field (customer number) which can be used as key for identifying the customer.
                                                    • The address and city fields are prefilled with the customer data but the customer can change the delivery address by modifying the fields.
                                                    • ·Contains a list of items the customer can order by just entering the quantity at selecting the color.
                                                    • There is a multiline comments field at the bottom.

                                                    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: