The Apache FOP Project

The Apache™ FOP Project

Apache™ FOP Development: Adding an Extension


For documentation of standard Apache™ FOP extensions, see the User FOP Extensions document.

If the default funtionality of FOP needs to be extended for some reason then you can write an extension.

There are three types of extensions possible:

Adding Your Own

To add your own extension you need to do the following things.

  1. Write code that implements your extension functionality. The easiest place to start is by looking at the code in, and by looking at the examples in the examples directory.

  2. Create a class that extends the abstract class. ElementMapping is a hashmap of all of the elements in a particular namespace, which makes it easier for FOP to create a different object for each element. ElementMapping objects are static to save on memory. They are loaded by FOP when parsing starts to validate input.

  3. Create the following file: "/META-INF/services/", which should contain the fully qualified classname of your ElementMapping implementation class.

  4. Create a jar file containing all of the above files.

  5. Create your XSL-FO file with the extra XML data embedded in the file with the correct name space. The examples for SVG and show how this can be done. The pdf documents on the FOP site use this extension. See also Examples for more examples.

  6. Put your jar file in the classpath

  7. Run FOP using your XSL-FO file as input.