• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

FOP and fonts

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Florian Fogl:
- 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);
Florian


The servlet code seems to be fine. Please print foDir and see whether its points to right location..
Check whether the Arial.xml and Arial.ttf are reachable by servlet and userconfig.xml files ??
 
Florian Fogl
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know how to test it properly! Obviously the servlet can't find them. But I don't have a clue why because it works fin from the command line! Any ideas?
 
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic