XSL-FO -> PDF formatter. Can be used as standalone utility.
https://xmlgraphics.apache.org/fop/2.2/embedding.html
See "Basic Usage Pattern"
fop.getDefaultHandler() is the key, its a SAX event handler to receive parsed XSL-FO events
https://xmlgraphics.apache.org/fop/2.2/configuration.html
Can use either a configuration file or programmatically.
Two Levels to customise FOP: FopFactory (reuse) and user agent
FopFactory:
FopFactoryBuilder builder = new FopFactoryBuilder(baseURI);
// or
// myResourceResolver is a org.apache.xmlgraphics.io.ResourceResolver
FopFactoryBuilder builder = new FopFactoryBuilder(baseURI, myResourceResolver);
User agent:
FopFactory fopFactory = FopFactory.newInstance(new File(".").toURI()); // Reuse the FopFactory if possible!
// do the following for each new rendering run
FOUserAgent userAgent = fopFactory.newFOUserAgent();
// customize userAgent
Fop fop = fopFactory.newFop(MimeConstants.MIME_POSTSCRIPT, userAgent, out);
User agent allows interaction with a single rendering run (processing a single document).