On Wildfly 10.0
deployed EAR
application, in which is generated PDF document. Generation occurs during a call to the REST
service and uses Apache FOP 2.3
.
When the service is first called after restarting / re-deploying the application generation is performed for almost 6 seconds, the subsequent ones in 0.7 seconds.
Document generation scheme:
- Generate XML with data and XSLT with design.
- Create FopFactory -> get RenderFactory of FopFactory -> get new FOUserAgent of FopFactory.
- Create fop of FopFactory (based MIME_PDF, FOUserAgent and ByteArrayOutputStream.
- Create TransformerFactory -> get new Transformer of TransformerFactory with XSLT.
- Get xml.transform.Result based fop.defaultHandler and execute transform XML to PDF.
- The resulting byte array is output to the ByteArrayInputStream.
How can you speed up the first generation of a PDF? In the logs at the first start, about 10,000 lines generated with the initialization of Apache FOP components.