Apache FOP
From Oxxus Wiki
Apache FOP, (Formatting Objects Processor), represents print formating application driven by XSL formatting objects (XSL-FO) and output independent formatter.
It's developed in Java and reads formating object trees and render them into desired output. There are many output formats supported like
PDF, PS, PCL, AFP, XML (area tree representation), Print, AWT and PNG, and to a lesser extent, RTF and TXT. The primary output target is PDF.
Latest stable release 1.0 can be downloaded from one of the Apache mirrors. It is a binary release which will be within archived file and has to be extracted into desired folder at hosting account once downloaded.
Contents |
Starting up with Apache FOP
Before starting to use FOP some basic configurations have to be done. In the text below, only an overview of configuration steps will be presented while detailed instructions and configuration examples are at Apache FOP's official pages at FOP Configuration.
Configuration File Basics
Apache FOP has the configuration stored within XML file which contains variety of settings that are useful for controlling the FOP. The easiest way to have FOP started is to use example configuration from FOP configuration folder sample, file named fop.xconf. It's just a sample configuration file but will enable FOP. File contains detailed instructions and following them, both basic and advanced setup can be achieved. As it's XML-based, please keep it well formed.
Once configured per needs, FOP has to be set in a way it can actually find its configuration file. There are two ways of stating configuration file location to FOP
- setting from command line, check "-c" command-line option at Running FOP
- setting from FOP running as an embedded service, check options at Embedded
Detailed summary of configuration options are at configuration options.
Image Loading Customization
The Apache FOP loads images using image loading framework from Apache XML Graphics Commons. All image loaders are placed into plugins and their usage is bonded with penalties which will, at the end, determine which plugin will be used.
Renderer configuration
To prepare loaded image to be presented in desired way for print out, rendering features also have to be configured. Every output format will require its render features. Configured and detailed instructions are available at Renderers.
As mentioned, there are several ways of using FOP services. Embedded with your java application or as an servlet with Apache jsp servlets container is one of the most commonly used features. Details about how to setup FOB as embedded app within java application you already have are shown here. If servlet is preferable then detailed setup and configuration instructions are here.
Startup issues
There could be issues with starting up FOP since it expects its configuration file to be at the exact place defined at start-up process presented in this document. Apache FOP will start even if configuration file is not found, without any complains, but won't be able to perform any tasks against documents needed for printout. To have FOP start with correct configuration file include, start FOP with -d option, for debugging, where every misconfiguration will be reported.