我正在尝试使用 JasperReports 连接两个报告,我有一个包含来自报告“A”和报告“B”的两个 jasperPrint 的列表。问题是它只打印第一个报告,第二页是空的。我虽然问题出在报告“B”中,但如果我先打印报告“B”,我也会遇到同样的问题:打印报告“B”,而应该是报告“A”的第二页是空的。
这是我的代码:
public static InputStream generatePdfByteArrayFromJasper(List<InputStream> reportStreams, Collection dataSource, HashMap<String, Object> parameters)
throws JRException {
List<JasperPrint> jasperPrints = new ArrayList<>();
JRDataSource datasource = new JRBeanCollectionDataSource(dataSource, true);
for (InputStream is : reportStreams) {
JasperPrint jasperPrint = JasperFillManager.fillReport(is, parameters, datasource);
jasperPrints.add(jasperPrint);
}
JRPdfExporter exporter = new JRPdfExporter();
ByteArrayOutputStream out = new ByteArrayOutputStream();
SimpleOutputStreamExporterOutput exporterOutput = new SimpleOutputStreamExporterOutput(out);
SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();
configuration.setCreatingBatchModeBookmarks(true);
exporter.setConfiguration(configuration);
exporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrints));
exporter.setExporterOutput(exporterOutput);
exporter.exportReport();
return new ByteArrayInputStream(out.toByteArray());
}
有人可以帮助我吗?谢谢!
Cats萌萌
相关分类