我使用以下代码在JaseReports中执行批量导出:
JRExporter e = new JRPdfExporter();
e.setParameter(JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
e.setParameter(JRPdfExporterParameter.OUTPUT_STREAM, outStream);
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=test.pdf");
e.exportReport();
它成功地导出,但是每个“合并的pdf”都在单独的页面上。我想让每个合并的页面不断,而不是在一个单独的页面上。有什么建议吗?
发布于 2016-07-30 05:17:31
因为你喜欢保留页面布局,所以你不能不使用isIgnorePagination="true"
(它会创建一个连续的布局),JRPdfExporter
上没有任何设置可以不将单个JasperPrint
视为单独的页面。
您拥有的解决方案是:
JasperPrint
列表,将所有组件移动到一个JasperPrint
中,决定它们是应该在当前页面上还是添加到新页面上,这种方法相当复杂,所以我强烈建议使用第一种方法。BTW:您正在使用不推荐使用的代码,当前版本的代码应该是
JRExporter e = new JRPdfExporter();
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrints));
exporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outStrem));
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setMetadataAuthor("n1ckgun"); // set you configs
exporter.setConfiguration(configuration);
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=test.pdf");
exporter.exportReport();
https://stackoverflow.com/questions/38655743
复制相似问题