The easy way to convert XML into PDF

J4L FO Designer is a productivity tool that helps you to convert XML files into PDF by using Apache FOP, the open and free implementation of the XLS-FO standard.

Our product intends to save you a significant amount of your time, and spare you the difficulties of a manual process. As explained in my previous post “How to create PDF files from XML with Apache-FOP”, XSL-FO and Apache-FOP provide a free and standard way to create PDF files in a language independent manner.

But there are a number of disadvantages with that approach, e.g.:

  • you have to learn XSL-FO (and therefore also XPath and XSL).
  • even if you know XSL-FO you do not want to be writing FO templates using a text editor.
  • there is some logic that cannot be easily defined using XSL-FO. For example, grouping of data requires you to use the so called Muenchian method , which isn't straightforward to understand.

In order to overcome these drawbacks, at J4L Components we have developed J4L FO Designer. The designer is a Visual (WYSIWYG) editor that will generate XSL-FO files for you. This makes the start into the XSL-FO world very easy, and it is also a useful tool for experienced developers since you can create and test XSL-FO files very quickly.

Additionally, it will also implement the algorithms for data grouping and running subtotals. Even though the tool has been created and tested for Apache FOP, the generated XSL-FO files would work with other FOP implementations.

Last but not least, we have added additional features to the FOP server (this is outside the standard) such as digital signatures and creation of PDF interactive forms.

You can download the evaluation version here.

Example

In the previous post we have seen how to create a "Hello World" PDF file by using XSL-FO files. The following instructions explain how the same PDF file can be created using J4L FO Designer:

1) We use the same persons.xml file:

<?xml version="1.0"?>

<persons>

<person>
<name>John</name>
</person>

<person>
<name>Mary</name>
</person>

</persons>

2) Open the designer, select the "Test Data" section on top of the left column and load persons.xml

the content of the file will be shown in the tool

3) We will now create an XML schema. In the XML schema you will see the structure of your file. Select the "XML Schema" section on the left column then use also the persons.xml file to create it on the fly.
4) In the next step we associate the detail section to the /persons/person node, so we will get one line for each person. Click on the Detail area header, then set XML node property to /persons/person.
5) As last step we add a field in the detail area. Click on the "Aa" button on top to select the field tool, then click somewhere in the detail area to add the field there. Finally we set the Xpath property. In this example we use the concat function to concatenate the text ‘Hello’ and the name of the current person (this could also be done with two separate fields):
6) Click on the PDF button
and the report.pdf file will be created.