|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.fop.apps.Driver
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 render(Parser, InputSource) respectively.
A third possibility is to call getContentHandler() and firing the SAX events yourself.
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]));
Field Summary | |
static int |
RENDER_AWT
Render to a GUI window. |
static int |
RENDER_MIF
Render to MIF. |
static int |
RENDER_PCL
Render to PCL. |
static int |
RENDER_PDF
Render to PDF. |
static int |
RENDER_PRINT
Render to PRINT. |
static int |
RENDER_PS
Render to Postscript. |
static int |
RENDER_SVG
Render to SVG. |
static int |
RENDER_TXT
Render to Text. |
static int |
RENDER_XML
Render to XML. |
Constructor Summary | |
Driver()
create a new Driver |
|
Driver(InputSource source,
OutputStream stream)
|
Method Summary | |
void |
addElementMapping(ElementMapping mapping)
Add the given element mapping. |
void |
addElementMapping(String mappingClassName)
add the element mapping with the given class name |
void |
dumpError(Exception e)
Dumps an error |
ContentHandler |
getContentHandler()
Returns the tree builder (a SAX ContentHandler). |
static String |
getParserClassName()
|
Renderer |
getRenderer()
|
FormattingResults |
getResults()
Returns the results of the last rendering process. |
boolean |
hasData()
|
void |
render(Document document)
Build the formatting object tree using the given DOM Document |
void |
render(XMLReader parser,
InputSource source)
Build the formatting object tree using the given SAX Parser and SAX InputSource |
void |
reset()
Resets the Driver so it can be reused. |
void |
run()
Runs the formatting and renderering process using the previously set inputsource and outputstream |
void |
setErrorDump(boolean dump)
Set the error dump option |
void |
setInputSource(InputSource source)
Set the source for the FO document. |
void |
setLogger(org.apache.avalon.framework.logger.Logger logger)
|
void |
setOutputStream(OutputStream stream)
Set the OutputStream to use to output the result of the Renderer (if applicable) |
void |
setRenderer(int renderer)
Set the rendering type to use. |
void |
setRenderer(Renderer renderer)
Set the Renderer to use |
void |
setRenderer(String rendererClassName)
Set the class name of the Renderer to use as well as the producer string for those renderers that can make use of it. |
void |
setRenderer(String rendererClassName,
String version)
Deprecated. use renderer.setProducer(version) + setRenderer(renderer) or just setRenderer(renderer_type) which will use the default producer string. |
void |
setupDefaultMappings()
Sets all the element and property list mappings to their default values. |
void |
setXMLReader(XMLReader reader)
Sets the reader used when reading in the source. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int RENDER_PDF
public static final int RENDER_AWT
public static final int RENDER_MIF
public static final int RENDER_XML
public static final int RENDER_PRINT
public static final int RENDER_PCL
public static final int RENDER_PS
public static final int RENDER_TXT
public static final int RENDER_SVG
Constructor Detail |
public Driver()
public Driver(InputSource source, OutputStream stream)
Method Detail |
public static final String getParserClassName()
public void setLogger(org.apache.avalon.framework.logger.Logger logger)
public void reset()
public FormattingResults getResults()
public boolean hasData()
public void setErrorDump(boolean dump)
dump
- if true, full stacks will be reported to the error logpublic void setOutputStream(OutputStream stream)
stream
- the stream to output the result of rendering topublic void setInputSource(InputSource source)
DocumentInputSource
public void setXMLReader(XMLReader reader)
public void setupDefaultMappings()
public void setRenderer(int renderer) throws IllegalArgumentException
renderer
- the type of renderer to use
IllegalArgumentException
public void setRenderer(Renderer renderer)
renderer
- the renderer instance to usepublic Renderer getRenderer()
public void setRenderer(String rendererClassName, String version)
setRenderer(int)
,
setRenderer(Renderer)
public void setRenderer(String rendererClassName) throws IllegalArgumentException
rendererClassName
- classname of the renderer to use such as
"org.apache.fop.render.pdf.PDFRenderer"
IllegalArgumentException
- if the classname was invalid.setRenderer(int)
public void addElementMapping(ElementMapping mapping)
mapping
- the element mappingto addpublic void addElementMapping(String mappingClassName) throws IllegalArgumentException
IllegalArgumentException
public ContentHandler getContentHandler()
public void render(XMLReader parser, InputSource source) throws FOPException
FOPException
public void render(Document document) throws FOPException
FOPException
public void dumpError(Exception e)
public void run() throws IOException, FOPException
IOException
FOPException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |