Apache FOP: Configuration
Configuration File Basics
The FOP configuration file is an XML file containing a variety of settings that are useful for controlling FOP's behavior, and for helping it find resources that you wish it to use.
The easiest way to get started using a FOP configuration file is to copy the sample found at {fop-dir}/conf/fop.xconf to a location of your choice, and then to edit it according to your needs. It contains templates for the various configuration options, most of which are commented out. Remove the comments and change the settings for entries that you wish to use. Be sure to follow any instructions, including comments which specify the value range. Also, since the configuration file is XML, be sure to keep it well-formed.
Making Configuration Available to FOP
After creating your configuration file, you must tell FOP how to find it:
- If running FOP from the command-line, see the "-c" command-line option in Running FOP.
- If running FOP as an embedded application, see Embedding, Using a Configuration File.
See Setting the Configuration Programmatically for instructions on how to do so in an embedded environment.
Summary of the General Configuration Options
Element | Data Type (for the value) | Default Value |
---|---|---|
base | URL | Specifies the base URL based on which relative URL will be resolved. |
resolution | Integer, dpi | Resolution in dpi (dots per inch) which is used internally. |
default-page-settings | n/a | Specifies the default width and height of a page if "auto" is specified for either or both values. Use "height" and "width" attributes on the default-page-settings element to specify the two values. |
renderers | (see text below) | Contains the configuration for each renderer. See below. |
This is an excerpt from the example configuration file coming with FOP:
<fop version="1.0"> <!-- Base URL for resolving relative URLs --> <base>./</base> <!-- Internal resolution in dpi (dots per pixel), default: 72dpi --> <resolution>72</resolution> <!-- default page-height and page-width, in case value is specified as auto --> <default-page-settings height="11in" width="8.26in"/> <!-- etc. etc..... --> </fop>
Renderer configuration
Each Renderer has its own configuration section which is identified by the MIME type the Renderer is written for, ex. "application/pdf" for the PDF Renderer.
The configuration for the PDF Renderer could look like this:
<renderers> <renderer mime="application/pdf"> <filterList> <!-- provides compression using zlib flate (default is on) --> <value>flate</value> </filterList> <fonts> <font metrics-url="arial.xml" kerning="yes" embed-url="arial.ttf"> <font-triplet name="Arial" style="normal" weight="normal"/> <font-triplet name="ArialMT" style="normal" weight="normal"/> </font> <font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf"> <font-triplet name="Arial" style="normal" weight="bold"/> <font-triplet name="ArialMT" style="normal" weight="bold"/> </font> </fonts> </renderer> <renderer mime="application/postscript"> <!-- etc. etc..... -->
The details on the font configuration can be found on the separate Fonts page. Note especially the section entitled Register Fonts with FOP.