我使用JSF开发了一个web应用程序在使用jasperreports打印报告时,我遇到了一个问题。
当我尝试在客户端打印时,打印对话框显示在服务器端。
InputStream reportStream = ctx.getExternalContext().getResourceAsStream("/ressources/reports/DAreport.jasper");
JasperPrint fluxJasperPrint = JasperFillManager.fillReport(reportStream, parameters, connection);
JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, fluxJasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();
由于应用程序在服务器端运行,因此打印对话框显示在服务器上。
要么在客户端运行应用程序(如果你有一个胖客户端),要么在服务器上安装一个默认打印机,并使用默认设置打印,这样对话框就不会显示。