+ public static void main(String[] args) throws Exception {
+ // Step 1: Construct a FopFactory by specifying a reference to the configuration
+ // file
+ // (reuse if you plan to render multiple documents!)
+ FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI());
+
+ // Step 2: Set up output stream.
+ // Note: Using BufferedOutputStream for performance reasons (helpful with
+ // FileOutputStreams).
+ OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(
+ System.getProperty("user.home") + "/dev/git/unstable/argeo-qa/doc/platform/argeo-platform-test.pdf")));
+
+ try {
+ // Step 3: Construct fop with desired output format
+ Fop fop = fopFactory.newFop("application/pdf", out);
+
+ // Step 4: Setup JAXP using identity transformer
+ TransformerFactory fopTransformerFactory = TransformerFactory.newInstance();
+ Transformer fopTransformer = fopTransformerFactory.newTransformer(); // identity transformer
+
+ // Step 5: Setup input and output for XSLT transformation
+ // Setup input stream
+ Source src = new StreamSource(new File(
+ System.getProperty("user.home") + "/dev/git/unstable/argeo-qa/doc/platform/argeo-platform.fo"));
+
+ // Resulting SAX events (the generated FO) must be piped through to FOP
+ Result res = new SAXResult(fop.getDefaultHandler());
+
+ // Step 6: Start XSLT transformation and FOP processing
+ fopTransformer.transform(src, res);
+
+ } finally {
+ // Clean-up
+ out.close();
+ }
+ }