blob: 561ec256cc22e1494788bffe94bb94e4a90bbb90 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.1//EN"
"http://cvs.apache.org/viewcvs.cgi/*checkout*/xml-forrest/src/resources/schema/dtd/document-v11.dtd">
<document>
<header>
<title>Adding an Extension to FOP</title>
</header>
<body>
<section id="overview">
<title>Overview</title>
<p>For documentation of standard FOP extensions, see the <link href="../extensions.html">User FOP Extensions</link> document.</p>
<p>
If the default funtionality of FOP needs to be extended for
some reason then you can write an extension.
</p>
<p>There are three types of extensions possible:</p>
<ul>
<li>An output document extension such as the PDF bookmarks</li>
<li>an instream-foreign-object extensions such as SVG</li>
<li>an fo extension that creates an area in the area tree where normal xsl:fo is not possible</li>
</ul>
</section>
<section id="adding">
<title>Adding Your Own</title>
<p>
To add your own extension you need to do the following things.
</p>
<ol>
<li>Write code that implements your extension functionality. The easiest place to
start is by looking at the code in org.apache.fop.extension, and by looking at the examples in the <code>contrib</code> directory.</li>
<li>Create a class that implements the org.apache.fop.fo.ElementMapping interface. 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.</li>
<li>Create the following file: "/META-INF/services/org.apache.fop.fo.ElementMapping", which should contain the fully qualified classname of your ElementMapping implementation class.</li>
<li>Create a jar file containing all of the above files.</li>
<li>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 <link href="../examples.html">Examples</link> for more examples.</li>
<li>Put your jar file in the classpath</li>
<li>Run FOP using your XSL-FO file as input.</li>
</ol>
</section>
</body>
</document>
|