aboutsummaryrefslogtreecommitdiffstats
path: root/docs/xml-docs/fop/embedding.xml
blob: c39e58d3c892e279287bebb1bceb0e0b5bdb0380 (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
<?xml version="1.0" standalone="no"?>



<!-- Embedding FOP -->

<s1 title="Embedding FOP ">
  <s2 title="">
  <p>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).
  </p>
  <p>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.
  </p>
  <p>A third possibility may be used to build the FO Tree, namely
     calling getDocumentHandler() and firing the SAX events yourself.
  </p>
  <p>Once the FO Tree is built, the format() and render() methods may be
     called in that order.
  </p>
  <p>Here is an example use of Driver from CommandLine.java:</p>
  <p><code>Driver driver = new Driver();</code></p>
  <p><code>driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer", version);</code></p>
  <p><code>driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");</code></p>
  <p><code>driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");</code></p>
  <p><code>driver.setWriter(new PrintWriter(new FileWriter(args[1])));</code></p>
  <p><code>driver.buildFOTree(parser, fileInputSource(args[0]));</code></p>
  <p><code>driver.format();</code></p>
  <p><code>driver.render();</code></p>
  </s2>
</s1>