Is it possible to have access to FOPs Area Tree in version 0.20.5 from java code?
(disclosure: I'm a FOP developer, though quite inactive nowadays)
Looking at the embedding examples inside FOP 0.20.5 distribution (I don't have the source code at hand), it looks like the class org.apache.fop.apps.Driver
has a .setRenderer()
method; to create a PDF, this method is called like this:
driver.setRenderer(Driver.RENDER_PDF);
and I guess the Driver
class has a constant for the area tree output too.
However, FOP 0.20.5 is really old, so I would recommend using a more recent version (2.0 has been released in June 2015).
Using FOP 2.0, as seen in the embedding documentation page, you can use an org.apache.fop.apps.FopFactory
to get an instance of org.apache.fop.apps.Fop
for the required output type, in this case:
Fop fop = fopFactory.newFop(MimeConstants.MIME_FOP_AREA_TREE, out);
The area tree output (regardless of the FOP version) is an XML file, so you can use a parser to obtain a Document
object and look at the geometric properties of the areas.
Recent versions of FOP (not 0.20.5) allow to use the area tree XML as input, to obtain (for example) a PDF output file: