J4L FOP Server
J4L FOP Server versions
J4L FO Designer
Purchase J4L FO Designer / J4L FOP Server Professional
Nowadays, XML is the native format of many applications, Oracle APEX for example, partly bases its reporting systen on XML. Middleware as Oracle BPEL, SAP PI, IBM Websphere and of course many Web services are also XML based. XML is also being used as exchange format in business to business transactions, for example for e-Invoicing. In these and many other environments there is often the need to create PDF files from XML.
In the past PDF files would be created using proprietary reporting tools that would use a database as data source. Additionally these tools are programming language specific. Later on the XSL-FO standard allowed for a better way to do it in many cases.
What is new about XSL-FO?
- it is programming language neutral.
- it is a standard so you are not tied to a vendor.
- it uses XML as data source.
Many free/open source products have a license model that puts strong restrictions on the way you may use the software. Not surprisingly there are software companies that do not allow the use in their code any open source software other than Apache Foundation one. So if you use Apache you know you are on the safe side.
Once you have installed Apache-FO, let's see how we can create a very simple PDF file. Initially we will use the file hello.fo for this. The output will contain the lines “Hello John” and “Hello Mary”. It is not the the aim of this article to present XSL-FO language in detail, there is a good tutorial here, but you can see the hight level structure is made of the document layout (red lines) and the page content (blue lines).
<?xml version="1.0" encoding="UTF-8"?>
<fo:simple-page-master margin-right="2cm" margin-left="2cm" margin-bottom="1cm" margin-top="0.5cm" font-family="sans-serif" page-width="21cm" page-height="29.7cm" master-name="main">
<fo:region-body margin-bottom="1cm" margin-top="4.0cm"/>
Using Apache FOP command line utility you can convert this file to PDF. For instance:
fop hello.fo hello.pdf
You could automatically create the file hello.fo by different means, however the recommended way to create this file is by putting the data (persons’ names) in a XML file like for example this one:
...and then creating a XSLT (XSL transformation) which takes the XML data as input and composes the hello.fo file.
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Page layout information -->
<fo:simple-page-master master-name="main" page-height="29.7cm" page-width="21cm" font-family="sans-serif" margin-top="0.5cm" margin-bottom="1cm" margin-left="2cm" margin-right="2cm">
<fo:region-body margin-top="4.0cm" margin-bottom="1cm" />
<fo:region-before extent="1.5cm" />
<fo:flow flow-name="xsl-region-body" >
<xsl:apply-templates select="persons/person" />
Hello <xsl:value-of select="name" />
With these two files, the Apache FOP command to create the PDF file would be:
fop -xml persons.xml -xsl hello.xsl -pdf hello.pdf
This command is performing 2 steps in one call:
As we have seen, if your data native format is XML, you can create user friendly PDF files with no programming. This is vendor independent and it is being used today in many situations and products.
With this procedure you are however involved with XSLT and XSL-FO languages and files, which you may prefer to avoid learning and mastering. If that is your case you may be interested in my related post The easy way to convert XML into PDF.
I was intrigued about all the buzz around the Rails framework and the Ruby language, so I thought it was the time to check it out by myself and start by learning Ruby. So, as I usually do, I assigned myself some specific learning task: in this case porting the J4L barcoding software from PHP (which in turn was ported from Java).
Here's the result
(only 1D barcodes at the moment)
From a commercial point of view, I wonder if this product will work well because there are already some open source solutions, most notably Barby, and the Ruby community appears to be very focused on open source and have do-it-yourself attitude.
If you're a Rubist and have considered to use this product and/or some other alternative, I'd appreciate your thoughts. These are the advantages that I think this product offers, compared to Barby:
During 2010 I worked mostly on this project. J.M.E., the web designer, and I worked with Iker Marcaide to develop the first version of the international money transfer web application, which was launched around June, just in time to win the "HiT Barcelona global technological innovation summit".
This initial web application was developed using the Zend Framework.
It was very exciting to participate in this project and contribute to its early success!