Hello. I am in the process of converting from 0.20.5 to a recent
trunk. It now executes with throwing an exception, but I see
nothing in the browser. The browser just hangs after a few seconds (after
the FOP process completes). I’ve done some searching in the mailing list, etc –
and I found a few instances of this. But none of the resolutions (if
present) have helped. An excerpt of the code is below. The
System.out that I added shows a non-zero value, as expected. I’ve
stripped the XSL doc down to pretty much nothing (just some text in a table) because
the original version had a lot on non-compliant stuff. This is exactly how I handled the output stream in the old
version of FOP and it worked perfectly. Any assistance is greatly appreciated. Chris ByteArrayOutputStream out = new
ByteArrayOutputStream(); FopFactory fopFactory =
FopFactory.newInstance(); FOUserAgent foUserAgent =
fopFactory.newFOUserAgent(); try
{
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new
StreamSource(xslURI.toString()));
transformer.setParameter("versionParam", "2.0");
Source src = "" StreamSource(new StringReader(xmlString));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
byte[] content = out.toByteArray();
System.out.println("FOT.render
content.length:"+content.length);
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
} finally {
out.close();
}
|