0% found this document useful (0 votes)
165 views

FOP Development: Adding An Extension: $revision: 955915 $

This document discusses how to add extensions to Apache FOP by writing code that implements new functionality, creating an ElementMapping class, adding a services file, packaging the code into a JAR file, using the extension in an XSL-FO file, and running FOP with the extension JAR in the classpath. The easiest way to start is by looking at existing extension code examples. There are three types of extensions: output format extensions, instream foreign object extensions, and FO extensions for areas not possible with normal XSL-FO.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
165 views

FOP Development: Adding An Extension: $revision: 955915 $

This document discusses how to add extensions to Apache FOP by writing code that implements new functionality, creating an ElementMapping class, adding a services file, packaging the code into a JAR file, using the extension in an XSL-FO file, and running FOP with the extension JAR in the classpath. The easiest way to start is by looking at existing extension code examples. There are three types of extensions: output format extensions, instream foreign object extensions, and FO extensions for areas not possible with normal XSL-FO.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

FOP Development: Adding an Extension

$Revision: 955915 $

Table of contents
1 2

Overview..............................................................................................................................................2 Adding Your Own................................................................................................................................2

PDF created by Apache FOP http://xmlgraphics.apache.org/fop/

FOP Development: Adding an Extension

1. Overview
For documentation of standard 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: An output document extension such as the PDF bookmarks an instream-foreign-object extensions such as SVG an fo extension that creates an area in the area tree where normal xsl:fo is not possible

2. 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 org.apache.fop.fo.extensions, and by looking at the examples in the examples directory. 2. Create a class that extends the abstract org.apache.fop.fo.ElementMapping 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/org.apache.fop.fo.ElementMapping", 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 pdfoutline.fo 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.

PDF created by Apache FOP http://xmlgraphics.apache.org/fop/

You might also like