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.5\examples\embedding\java\embedding 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 directories
File baseDir = new File(".");
...
//Setup input and output files
File fofile=new File(baseDir, "xml/fo/helloworld.fo");
...
//code for replacement
...
//Setup directories
File baseDir = new File("YOUR_DIRECTORY");
...
//Setup input and output files
File fofile=new File(baseDir, "YOUR FO FILE");
...