Rendering of XHTML to PDF is slow on FlyingSaucer with OpenPDF library

597 Views Asked by At

Any chance to improve XHTML to PDF rendering speed in FlyingSaucer /OpenPDF ? I am using version 9.1.20 of flying-saucer-pdf-openpdf library. Simple XML took almost 5 seconds. Took 0.5 sec with the flying-saucer-pdf lib.

org.w3c.dom.Document doc = parseXMLContent(xhtmlContent, validate);
Date tim = new Date();
ITextRenderer renderer = new ITextRenderer();
renderer.setDocument(doc, null); 
renderer.layout();
renderer.createPDF(out);
renderer.finishPDF();
log.debug("xhtml2pdf took " + ((new Date()).getTime() - tim.getTime()) / 1000.0 + " seconds");

XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <body>
        <h1>TEST</h1>
    </body>
</html>
0

There are 0 best solutions below