I tried to write an applet that can create a PDF with an embedded font. Everything works as long as it is not in the JAR file.
The next part of the code shows that I first create an AWT font (which works fine with and does not write to the JAR file). Then I want to register the iText font (5.0.3). But here an error occurs: access denied (java.io.FilePermission http:\host\jarfile\fonts\EXAMPLE.ttf read) java.security.AccessControlException) .
private String font = "fonts/EXAMPLE.ttf"; private Font pdfFont; 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); 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 didn’t affect. The same error message will appear. Am I doing something wrong or is it a security setting that cannot be disabled? (without changing the rules of the JRE)
Thanks! Daniel
source share