I'm using FOP 0.94 with JDK 1.4 for producing a simple 1 page PDF
transforming a simple XML on a Mandrake Linux release 9.2 for i586.
If I try with command line the result is about in 3 or 4 second. 
Next I write a Servlet on JRun 4.0:
 
public void init() throws ServletException {
    uriResolver = new ServletContextURIResolver(getServletContext());
    TransformerFactory tFactory = TransformerFactory.newInstance();

    tFactory.setURIResolver(uriResolver);

    //Cache del template XSLT
    try {
        Source xsltSrc =
uriResolver.resolve("servlet-context:/template/fo.xsl", null);
        cachedXSLT = tFactory.newTemplates(xsltSrc);
    } catch (Exception e) {
        throw new ServletException(e);
    }

    //config di FOP
    fopFactory = FopFactory.newInstance();
    fopFactory.setURIResolver(uriResolver);
    fopFactory.setSourceResolution(96); //96dpi
    fopFactory.setTargetResolution(96); //96dpi
}

protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
    (...)

    ByteArrayOutputStream pdf = new ByteArrayOutputStream();

    Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF,
fopFactory.newFOUserAgent(), pdf);

    Transformer transformer = cachedXSLT.newTransformer();
    transformer.setURIResolver(uriResolver); 

    Result res = new SAXResult(fop.getDefaultHandler());

    Source src = new StreamSource(new StringReader(theXML));

    transformer.setParameter("param", "value");
    transformer.transform(src, res);

    (...)
}
 
All work fine but the latter line (transformer.transform(src, res);)
take about 40 seconds to generate PDF, I saw that during transformation
CPU usage is about 50% user and about 10% system.
Can anyone tell me what is the problem?
 
Thanks in advance for your kind attention
Paolo
 
 
 
 
 
 

Reply via email to