When you want to use the FOP-to-AWT Viewer from a Java application, you can use the ExampleAWTViewer.java. This application is available in the fop-0.20.5examplesembeddingjavaembedding directory. Using this class, you don’t have to develop the application from scratch.
Just copy the application, rename it, and make the following replacements:
//code to be replaced...//Setup directoriesFile baseDir = new File(".");...//Setup input and output filesFile fofile=new File(baseDir, "xml/fo/helloworld.fo");...//code for replacement...//Setup directoriesFile baseDir = new File("YOUR_DIRECTORY");...//Setup input and output filesFile fofile=new File(baseDir, "YOUR FO FILE");...