本地已配置好打印机,以非applet的方式调用java.awt.print.PrinterJob可以打印,但以applet方式即使用程序选择打印机,java plug-in控制台还是抛出PrinterException:no print service found
public static PrintService getPrintService()
{
PrintService ps = PrintServiceLookup.lookupDefaultPrintService();
if ( ps == null )
{
PrintService[] pss = PrintServiceLookup.lookupPrintServices( null, null );
if ( pss.length > 0 )
ps = pss[0];
}
return ps;
}
上面的程序在applet里始终返回null,也就是说applet始终无法得到PrintService
如何解决
applet安全设限制,很多操作被禁止了
up
你把安全权限调高试试
ie的安全权限.工具->internet选项->安全
应该是权限的问题,去查这方面的资料吧!
http://www.cjsdn.com/post/print?bid=1&id=76339
1) Sign the applet granting file read permission
2) Modify the applet to show the print dialog first. This works because
there is an outer doPrivileged block surrounding the code that pops up the
dialog, and it grants the file permssion too. Printing works in this case
3) Move to JDK 1.5
帮顶