Libraries like iText,PDFBox are some of the best libraries available for PDF creation and manipulation. But these libraries have its disadvantages. One such disadvantage is templating the PDFs you create. In a enterprise where reports (PDF files) are generated automatically and routed to work-flows or stored in content management repositories. These reports follow an enterprise level style and pattern which can be reused, can change and will require proper management. Hardcoding styles and formats of reports into your application can cause lots of issues in future. That's when XSL-FO and Java (or other language) come into picture. In this article I will introduce XSL-FO and Apache FOP.
Let me intoduce XSL-FO first. XSL-FO stand for Extensible Stylesheet Language Formatting Objects and is a language for formatting XML data. It was initially part of the XSL W3C recommendation. So W3C has come up with XSLT for transforming XML documents and XSL-FO for formatting. XSL-FO documents are XML files that contain information about the output layout and output contents. But they do not specify the content type of the output. This output can be any document type; all you need is a transformation library that transform the XSL-FO to the appropriate content. In this article I will make use of Apache FOP, which is part of Apache XML Graphics Project.