tags:

views:

59

answers:

0

Hello!

I tried to write an applet that is able to create a PDF with an embedded font. Everything works as long as it is not in an JAR file.

The following code part shows that I first create the AWT Font (which works fine with and without beeing stored in a JAR-file). Then I want to register an iText (5.0.3) font. But here comes the error: access denied (java.io.FilePermission http:\host\jarfile\fonts\EXAMPLE.ttf read) java.security.AccessControlException).

private String font = "fonts/EXAMPLE.ttf";

/* iText font */
private Font pdfFont;

/* AWT font */
private java.awt.Font javaFont;

private DefaultFontMapper mapper = new DefaultFontMapper();

javaFont = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, getClass().getResourceAsStream(font));

FontFactory.register(getClass().getClassLoader().getResource(font).getPath(), javaFont.getFontName());
pdfFont = FontFactory.getFont(javaFont.getFontName(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 40);

/* Map the fonts */
BaseFontParameters params = new BaseFontParameters(font);
params.encoding = BaseFont.IDENTITY_H;
params.embedded = true;
mapper.putName(javaFont.getFontName(), params);

So I thought signing my applet would be a good idea but it had no effect. The same error message appears. Am I doing something wrong or is this a security setting that cannot be deactivated? (without changing JRE policys)

Thank you! Daniel