我正在尝试从我的 JSF Web 应用程序打印一个 pdf 文档。
当我findPrinter()
从主方法调用该方法时,PrintServices
找到了,但是当我从网页调用该方法时却PrintService
找不到。下面提到的代码..
public static void main(final String[] args) throws Exception {
PrintTest printTest = new PrintTest();
printTest.findPrinter();
}
public void findPrinter() {
PrintService[] printServices = PrinterJob.lookupPrintServices();
System.out.println("Print Services Length :: " + printServices.length);
for (PrintService printService : printServices) {
System.out.println("PrintService :: " + printService);
}
<h:form>
<p:commandButton value="Print" action="#{printTest.findPrinter()}"/>
</h:form>
有什么建议么...