开发者

How to register a font in iText FontFactory in self signed Java applet?

开发者 https://www.devze.com 2023-02-02 06:31 出处:网络
In my self signed java applet, I get following error: uncaught exception: java.security.AccessControlException: access denied (java.io.FilePermission resources/fonts/n开发者_运维技巧ew_font.TTF read)

In my self signed java applet, I get following error:

uncaught exception: java.security.AccessControlException: access denied (java.io.FilePermission resources/fonts/n开发者_运维技巧ew_font.TTF read)

resources/fonts/new_font.TTF file is packed inside jar.

I also tried Privileged methods mentioned here and here, but I'm still getting the error.

My code after alteration:

java.security.AccessController.doPrivileged(
        new java.security.PrivilegedAction() {
            public Object run() {
                FontFactory.register("resources/fonts/new_font.TTF", "new_font");
                return null;
            }
        }
);

Any help would be appreciated. Thanks.

Edit Very similar question was asked here without any answer.


I placed all the Font calls inside PrivilegedAction() and it works now.

0

精彩评论

暂无评论...
验证码 换一张
取 消