Primary class that drives overall FOP process.
The simplest way to use this is to instantiate it with the InputSource and OutputStream, then set the renderer desired, and calling run();
Here is an example use of Driver which outputs PDF:
Driver driver = new Driver(new InputSource (args[0]), new FileOutputStream(args[1])); driver.setRenderer(RENDER_PDF); driver.run();
If neccessary, calling classes can call into the lower level methods to setup and render. Methods can be called to set the Renderer to use, the (possibly multiple) ElementMapping(s) to use and the OutputStream 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).
Once the Driver is set up, the render method is called. Depending on whether DOM or SAX is being used, the invocation of the method is either render(Document) or buildFOTree(Parser, InputSource) respectively.
A third possibility may be used to build the FO Tree, namely calling getContentHandler() and firing the SAX events yourself.
Once the FO Tree is built, the format() and render() methods may be called in that order.
Here is an example use of Driver which outputs to AWT:
Driver driver = new Driver(); driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator)); driver.render(parser, fileInputSource(args[0]));