<
fo:root xmlns:fo="
http://www.w3.org/1999/XSL/Format" >
<
fo:layout-master-set>
<
fo:simple-page-master master-name="first"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<
fo:region-body margin-top="3cm"/>
<
fo:region-before extent="3cm"/>
<
fo:region-after extent="1.5cm"/>
</
fo:simple-page-master>
<
fo:simple-page-master master-name="rest"
page-height="29.7cm"
page-width="21cm"
margin-top="1cm"
margin-bottom="2cm"
margin-left="2.5cm"
margin-right="2.5cm">
<
fo:region-body margin-top="2.5cm"/>
<
fo:region-before extent="2.5cm"/>
<
fo:region-after extent="1.5cm"/>
</
fo:simple-page-master>
<
fo:page-sequence-master master-name="basicPSM">
<
fo:repeatable-page-master-alternatives>
<
fo:conditional-page-master-reference master-name="first"
page-position="first"/>
<
fo:conditional-page-master-reference master-name="rest"
page-position="rest"/>
<
fo:conditional-page-master-reference master-name="rest"/>
</
fo:repeatable-page-master-alternatives>
</
fo:page-sequence-master>
</
fo:layout-master-set>
<fox:outline
internal-destination="sec1">
<fox:label>What is FOP?</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec2">
<fox:label>Downloading FOP</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec3">
<fox:label>Running FOP</fox:label>
<fox:outline
internal-destination="sec3-1">
<fox:label>Prerequisites</fox:label>
<fox:outline
internal-destination="sec3-1-1">
<fox:label>Java 1.1</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec3-1-2">
<fox:label>XML Parser</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec3-1-3">
<fox:label>XSLT Processor</fox:label>
</fox:outline>
</fox:outline>
<fox:outline
internal-destination="sec3-2">
<fox:label>Starting FOP</fox:label>
</fox:outline>
</fox:outline>
<fox:outline
internal-destination="sec4">
<fox:label>Embedding FOP</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec5">
<fox:label>What's Implemented?</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec6">
<fox:label>Limitations</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec7">
<fox:label>Bugs</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec8">
<fox:label>Compiling FOP</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec9">
<fox:label>Getting Involved</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec10">
<fox:label>FOP Relevant Specifications</fox:label>
</fox:outline>
<fox:outline
internal-destination="sec11">
<fox:label>License</fox:label>
</fox:outline>
<
fo:page-sequence master-name="basicPSM">
<
fo:static-content flow-name="xsl-region-before">
<
fo:block text-align="end"
font-size="10pt"
font-family="serif"
line-height="14pt"
color="red">
This is not the latest Fop documentation, but just an fo example. FOP - p.
<
fo:page-number/>
</
fo:block>
</
fo:static-content>
<
fo:flow flow-name="xsl-region-body">
<
fo:block id="secA"
font-size="18pt"
font-family="sans-serif"
line-height="24pt"
space-after.optimum="15pt"
background-color="blue"
color="white"
text-align="center"
padding-top="3pt">FOP: An Open-Source XSL Formatter and Renderer</
fo:block>
<
fo:block id="sec1"
font-size="18pt"
font-family="serif"
line-height="20pt"
space-before.optimum="20pt"
space-after.optimum="14pt">A)
What is FOP?</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a formatting object
tree and then turns it into a PDF document. The formatting object
tree, can be in the form of an XML document (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">FOP is part of Apache's XML project. The homepage of FOP is
<
fo:inline font-style="italic"
font-family="serif">
<
fo:basic-link color="blue"
external-destination="http://xml.apache.org/fop">http://xml.apache.org/fop</
fo:basic-link>
</
fo:inline>
</
fo:block>
<
fo:block id="sec2"
font-size="18pt"
font-family="serif"
line-height="20pt"
space-before.optimum="20pt"
space-after.optimum="14pt">B)
Downloading FOP</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">The latest release version is
<
fo:inline font-style="italic"
font-family="serif">FOP
0.14</
fo:inline>
<
fo:inline font-family="serif">
()
</
fo:inline>.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">NOTE: you do not have to unjar or unzip this jar file.</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Documentation can be downloaded here as
<
fo:inline font-style="italic"
font-family="serif">HMTL file</
fo:inline>
<
fo:inline font-family="serif">
()
</
fo:inline> or
as
<
fo:inline font-style="italic"
font-family="serif">PDF file</
fo:inline>
<
fo:inline font-family="serif">
()
</
fo:inline>.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">To run FOP from the command line, see Running FOP. If you are interested in
embedding FOP in a Java application of your own, see Embedding FOP.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">You can also download the
<
fo:inline font-style="italic"
font-family="serif">source code v. 0.14</
fo:inline>
<
fo:inline font-family="serif">
()
</
fo:inline> as jar file
</
fo:block>
<
fo:block id="sec3"
font-size="18pt"
font-family="serif"
line-height="20pt"
space-before.optimum="20pt"
space-after.optimum="14pt">C)
Running FOP</
fo:block>
<
fo:block id="sec3-1"
font-size="16pt"
font-family="serif"
line-height="18pt"
space-before.optimum="8pt"
space-after.optimum="8pt">1) Prerequisites</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Following software must be installed:</
fo:block>
<
fo:block id="sec3-1-1"
space-after.optimum="3pt"
font-family="serif">a) Java 1.1.x or later</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">For the fo-file viewer mode of FOP (see below) you must have the swing classes installed.
From Java 1.2 on (aka Java 2) they are part of the standard java distribution.
If you use Java 1.1.x you must seperately include the swing classes, which can
be found at the
<
fo:inline font-style="italic"
font-family="serif">
Sun website</
fo:inline>
<
fo:inline font-family="serif">
(http://java.sun.com/products/jfc/#download-swing)
</
fo:inline>.
</
fo:block>
<
fo:block id="sec3-1-2"
space-after.optimum="3pt"
font-family="serif">b) An XML parser which supports SAX and DOM like
<
fo:inline font-style="italic"
font-family="serif">Xerces-J</
fo:inline>
<
fo:inline font-family="serif">
(http://xml.apache.org/xerces-j/index.html)
</
fo:inline>.
</
fo:block>
<
fo:block id="sec3-1-3"
space-after.optimum="3pt"
font-family="serif">c) If you have to produce the flow objects files, which are the input for FOP,
you need a transformation utility to create this files from your xml files.
Normally this is an XSLT stylesheet processor like
<
fo:inline font-style="italic"
font-family="serif">XT</
fo:inline>
<
fo:inline font-family="serif">
(http://www.jclark.com/xml/xt.html)
</
fo:inline>
or
<
fo:inline font-style="italic"
font-family="serif">XALAN</
fo:inline>
<
fo:inline font-family="serif">
(http://xml.apache.org/xalan/index.html)
</
fo:inline>.
</
fo:block>
<
fo:block id="sec3-2"
font-size="16pt"
font-family="serif"
line-height="18pt"
space-before.optimum="8pt"
space-after.optimum="8pt">2) Starting FOP as an standalone application</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">There are three ways to run FOP from the command line.</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">a) Batch processing formatting objects (fo) files: </
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java org.apache.fop.apps.CommandLine fo-file pdf-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">b) Batch processing xml files (includes production of the fo-files):</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java org.apache.fop.apps.CommandLine xml-file xsl-file pdf-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">c) Previewing the fo-file:</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java org.apache.fop.apps.AWTCommandLine fo-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Each method uses next to the fop classes other packages. The following describes
each method in detail.</
fo:block>
<
fo:block font-size="14pt"
font-family="serif"
line-height="16pt"
space-before.optimum="8pt"
space-after.optimum="4pt">a) Method One</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">One is to first use an XSLT engine to produce the formatting object tree as an
XML document and then running the class org.apache.fop.apps.CommandLine with the
formatting object file name and PDF filename as arguments. You will need to include
FOP and your XML Parser in your classpath and so you might invoke
</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java -cp fop_x_xx_x.jar;xerces.jar</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">org.apache.fop.apps.CommandLine fo-file pdf-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">If your SAX Parser is other than Xerces, you will need to set the property
org.xml.sax.parser to the SAX Parser class to use. The following example shows
the command line, if you use XP, the XML parser from James Clark:
</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java -Dorg.xml.sax.parser=com.jclark.xml.sax.Driver</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">-cp fop_x_xx_x.jar;sax.jar;xt.jar;xp.jar;xerces.jar</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">org.apache.fop.apps.AWTCommandLine formatting-tree-file pdf-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">(You have to include xerces.jar or another xml parser which supports DOM in your classpath.) </
fo:block>
<
fo:block font-size="14pt"
font-family="serif"
line-height="16pt"
space-before.optimum="8pt"
space-after.optimum="4pt">b) Method Two</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Rather than performing transformation with an XSLT before invoking FOP, it is
possible, if you use XT as your XSLT engine, to just call FOP and have it call
XT for you. To do this, run the class org.apache.fop.apps.CommandLine with the
source XML file name, XSL file name and PDF file name as arguments. You will
need to include FOP, SAX, your SAX Parser and XT in your classpath and so you might
invoke
</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java -Dorg.xml.sax.parser=com.jclark.xml.sax.Driver</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">-cp fop_x_xx_x.jar;xt.jar;xerces.jar</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">org.apache.fop.apps.CommandLine xml-file xsl-file pdf-file</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Again, if your SAX Parser is other than Xerces, you will need to set the property
org.xml.sax.parser to the SAX Parser class to use.
</
fo:block>
<
fo:block font-size="14pt"
font-family="serif"
line-height="16pt"
space-before.optimum="8pt"
space-after.optimum="4pt">c) Method Three</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">If you already produced the FO file, you can preview the results of your
transformation without using any pdf viewer by invoking FOP with the viewer
application. You will need to include FOP and your XML Parser in your classpath
</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java -cp fop_x_xx_x.jar;xerces.jar</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">org.apache.fop.apps.AWTCommandLine fo-file </
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">The viewer uses the swing classes.</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Note: If you are using java 2 or later (i.e. jdk 1.2. or later) you can put all
needed jar files into the subdirectory jdk1.2.x\jre\lib\ext (windows example). Then
FOP can be started without classpath:
</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">java org.apache.fop.apps.CommandLine fo-file pdf-file</
fo:block>
<
fo:block font-size="16pt"
font-family="serif"
line-height="18pt"
space-before.optimum="8pt"
space-after.optimum="8pt">3) Running FOP on MacOS</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Ensure that you have a recent MRJ, and that you have downloaded and
unpacked the XP and SAX distributions. The xp.jar and sax.jar files work
as is on MacOS.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Drag the FOP jarfile onto the JBindery icon. When the first dialog
appears, type "org.apache.fop.apps.CommandLine" in the "Class name" field.
Using UNIX syntax, type the names of the input formatting-object file and
the output PDF in the "Optional parameters" field.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Click on the Classpath icon. To add the xp.jar and sax.jar files, click
the "Add .zip file" button, navigate to the file in question, and click
Open.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Once both are added (the FOP jarfile will already be in the list), click
Run. A "stdout" window will appear and display FOP runtime messages.
</
fo:block>
<
fo:block font-size="16pt"
font-family="serif"
line-height="18pt"
space-before.optimum="8pt"
space-after.optimum="8pt">4) Problems</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">If you have problems running FOP, please have a look at the
<
fo:inline font-style="italic"
font-family="serif">FOP FAQ</
fo:inline>
<
fo:inline font-family="serif">
(faq.html)
</
fo:inline>. If you don't find a solution there,
you can ask for help on the list fop-dev@xml.apache.org. Maybe it's bug and
maybe somebody is already working on it.
</
fo:block>
<
fo:block id="sec4"
font-size="18pt"
font-family="serif"
line-height="20pt"
space-before.optimum="20pt"
space-after.optimum="14pt">D)
Embedding FOP </
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Instantiate org.apache.fop.apps.Driver. Once this class is
instantiated, methods are called to set the
Renderer to use, the (possibly multiple) ElementMapping(s) to
use and the PrintWriter to use to output the results of the
rendering (where applicable). In the case of the Renderer and
ElementMapping(s), the Driver may be supplied either with the
object itself, or the name of the class, in which case Driver will
instantiate the class itself. The advantage of the latter is it
enables runtime determination of Renderer and ElementMapping(s).
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Once the Driver is set up, the buildFOTree method
is called. Depending on whether DOM or SAX is being used, the
invocation of the method is either buildFOTree(Document) or
buildFOTree(Parser, InputSource) respectively.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">A third possibility may be used to build the FO Tree, namely
calling getDocumentHandler() and firing the SAX events yourself.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Once the FO Tree is built, the format() and render() methods may be
called in that order.
</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Here is an example use of Driver from CommandLine.java:</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">Driver driver = new Driver();</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.setWriter(new PrintWriter(new FileWriter(args[1])));</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.buildFOTree(parser, fileInputSource(args[0]));</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.format();</
fo:block>
<
fo:block font-size="10pt"
font-family="monospace"
line-height="12pt"
space-before.optimum="0pt"
space-after.optimum="0pt">driver.render();</
fo:block>
<
fo:block id="sec5"
font-size="18pt"
font-family="serif"
line-height="20pt"
space-before.optimum="20pt"
space-after.optimum="14pt">E)
What's Implemented?</
fo:block>
<
fo:block space-after.optimum="3pt"
font-family="serif">Also see STATUS for what is being worked on.</
fo:block>
<
fo:block font-size="16pt"
font-family="serif"
line-height="18pt"
space-before.optimum="8pt"
space-after.optimum="8pt">1) Formatting Objects</
fo:block>
<
fo:list-block start-indent="1cm"
provisional-distance-between-starts="12pt"
font-family="serif">
<
fo:list-item>
<
fo:list-item-label end-indent="label-end()">
<
fo:block>
<
fo:inline font-family="Symbol">·</
fo:inline>
</
fo:block>
</
fo:list-item-label>
<
fo:list-item-body start-indent="body-start()">
<
fo:block>root </
fo:block>
</
fo:list-item-body>
</
fo:list-item>
<
fo:list-item>
<
fo:list-item-label end-indent="label-end()">
<
fo:block>
<
fo:inline font-family="Symbol">·</
fo:inline>
</
fo:block>
</
fo:list-item-label>
<
fo:list-item-body start-indent="body-start()">
<
fo:block>layout-master-set </
fo:block>
</
fo:list-item-body>
</
fo:list-item>
<
fo:list-item>
<
fo:list-item-label end-indent="label-end()">
<
fo:block>
<
fo:inline