Hi all,
I've got a problem using FOP (0.20.5) with external fonts. The funny thing is that everything works fine when I use FOP from the command line whereas using FOP in a
servlet on WebSphere (Version 5) I get the following error message:
[ERROR] unknown font Arial,normal,normal so defaulted font to any [02.03.04 14:33:38:651 CET] 33b6ae4d SystemOut
I think it's got something to do with the path names of the userconfig.xml, the font metrics file and the ttf-file. I have placed them in same directory like the .fo-file that I want to be rendered. My Code looks like this:
- userconfig.xml
<fonts>
<font metrics-file="Arial.xml" kerning="yes" embed-file="Arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
<font-triplet name="ArialMT" style="normal" weight="normal"/>
</font>
</fonts>
- servlet
try {
foDir = getFoDir();
File userConfigFile = new File(foDir + "userconfig.xml");
Options options = new Options(userConfigFile);
FileInputStream foFile = new FileInputStream(foDir + file);
log = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
MessageHandler.setScreenLogger(log);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
Driver driver = new Driver(new InputSource(foFile), outStream);
driver.setLogger(log);
driver.setRenderer(Driver.RENDER_PDF);
driver.run();
byte[] binary = outStream.toByteArray();
response.setContentType("application/pdf");
response.setContentLength(binary.length);
response.getOutputStream().write(binary);
response.getOutputStream().flush();
}
catch (Exception exc) {
exc.printStackTrace();
}
The servlet works fine and the PDF is created but with the wrong font! Does anyone know how to fix this problem.
Thanks!
Florian