我正在使用JasperReports 1.3.1打印报告。我正在为开发目的唱歌 eclipse 和 tomcat。
在 Eclipse 中,当我运行应用程序时,下面的代码将显示列出的打印机设备和打印按钮。如果我单击打印按钮,则报告将由所选设备打印。
PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();
printRequestAttributeSet.add(MediaSizeName.ISO_A5);
PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();
在这里,我将 jasperPrint 作为我手动构造的参数传递。它工作得很好
我的问题是:
我创建了 war 文件并粘贴在 tomcatApache Software Foundation\Tomcat 6.0\webapps
目录中,并使用services.msc启动了 tomcat 。
此时,它不显示列出的打印机详细信息,也不打印。
我放了一些记录器,我发现,exporter.exportReport();
在这行代码没有执行之后,代码就挂了。请建议我如何使用 jasper 从客户端打印