Announcement Announcement Module
Collapse
No announcement yet.
spring form location Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring form location

    Hi,

    I am wondering what is the correct way of locate external fonts files in the spring application.

    I have overwritten my own class ITextTableWriter of iText library and in this class I am using something like that:

    Code:
    BaseFont arial = BaseFont.createFont("home/pawel/arialuni.ttf",
    BaseFont.IDENTITY_H, BaseFont.CACHED);
    grrrr it's a terrible way of hard-coding. So I have changed that to:

    Code:
    URL url =  ClassLoader.getSystemResource("config.properties");
    Properties p = new Properties();
    p.load(new FileInputStream(new File(url.getFile())));
    BaseFont arial = BaseFont.createFont(p.getProperty("font.arial.ttf"),
    BaseFont.IDENTITY_H, BaseFont.CACHED);
    But it does not work and ends with a NullPointerException although I have config.properties in my classpath. I should mention that my ITextTableWriter class is not a bean so I can not use the property configurer (?).

    Anybody have a suggestion how this could be done? Or maybe there is a way to include font file inside the war file and to use this in the way like this:

    Code:
    BaseFont arial = BaseFont.createFont(new FontFile?("classpath:arialuni.ttf")???,
    BaseFont.IDENTITY_H, BaseFont.CACHED);
    ?

    Regards,
    Pawel
    Last edited by gandalf0777; Dec 11th, 2008, 10:46 AM.
Working...
X