//Setup renderer
AWTRenderer renderer = new AWTRenderer(translator);
//Create preview dialog (target for the AWTRenderer)
PreviewDialog frame = createPreviewDialog(renderer, translator);
renderer.setProgressListener(frame);
renderer.setComponent(frame);
//Setup Driver
Driver driver = new Driver();
driver.setLogger(new ConsoleLogger(ConsoleLogger.LEVEL_INFO));
driver.setRenderer(renderer);
try {
// build FO tree: time
frame.progress(translator.getString("Build FO tree") + " ...");
//Load XSL-FO file (you can also do an XSL transformation here)
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
Source src = new StreamSource(fo);
Result res = new SAXResult(driver.getContentHandler());
transformer.transform(src, res);
//Show page
frame.progress(translator.getString("Show"));
frame.showPage();
} catch (Exception e) {
frame.reportException(e);
if (e instanceof FOPException) {
throw (FOPException)e;
}
throw new FOPException(e);
}