Hi,
we have a content management system, which can create FO and with the help of
FOP PDF. The system uses an Apache Tomcat 5 and we have used FOP 0.20. This
combination works.
But now, I've switched to FOP 0.94 and changed the code which creates the PDF.
At this moment, FOP only creates white pages without any text. The number of
pages is correct, for example when I create a FO with 2 pages, 2 pages will be
in the PDF, but all are white.
The FO-Code is still ok, which can be demonstrated by copying the FO-Code to a
special test-program. Even the new code, which is copied to this test-program.
But I don't see the problem, why the same code doesn't work inside the Tomcat.
Here's my source-code to create the PDF:
/* create the streams */
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent userAgent = fopFactory.newFOUserAgent();
File userConfigFile = new File(new
File(context.getGenerator().getServletContext().getRealPath("WEB-INF/etc")),
"pdfuserconfig.xml");
userAgent.getRendererOptions().put("encryption-params", new
PDFEncryptionParams(null, null, true, false, false, false));
if (userConfigFile.exists())
fopFactory.setUserConfig(userConfigFile);
Source source = new StreamSource(new ByteArrayInputStream(strFo.getBytes()));
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent, outStream);
Result result = new SAXResult(fop.getDefaultHandler());
TransformerFactory.newInstance().newTransformer().transform(source, result);
if (log.isDebugEnabled()) {
FormattingResults formattingResults = fop.getResults();
List<PageSequenceResults> pageSequences =
formattingResults.getPageSequences();
for (PageSequenceResults pageSequenceResults : pageSequences) {
log.debug("PageSequence "
+ (String.valueOf(pageSequenceResults.getID()).length() > 0
? pageSequenceResults.getID() : "<no id>")
+ " generated " + pageSequenceResults.getPageCount() + "
pages.");
}
log.debug("Generated " + formattingResults.getPageCount() + " pages in
total.");
}
} catch (Exception e) {
log.error(e);
throw new CMSException(e);
} finally {
outStream.flush();
outStream.close();
}
strFo contains the complete FO-Code.
The part with the useragent and userconfig can be removed, the program produces
the same problem. Outside a Tomcat works it well.
Is there maybe a problem of a missing configuration-file? If yes, where do I
place it inside the Tomcat-directory-structure?
Thanks,
Michael
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]