我使用库jasper报告导出文件pdf,结果是通过文件jrxml简单的hello world文件pdf空白。这是我的代码生成器PDF:
@Cachable
然后我使用oracle jdk进行检查:
@Override
public byte[] generatePDFReport(String inputFileName, Map<String, Object> params, JRDataSource dataSource) {
byte[] bytes = null;
JasperReport jasperReport = null;
try (ByteArrayOutputStream byteArray = new ByteArrayOutputStream()) {
// Check if a compiled report exists
if (storageService.jasperFileExists(inputFileName)) {
jasperReport = (JasperReport) JRLoader.loadObject(storageService.loadJasperFile(inputFileName));
}
// Compile report from source and save
else {
String jrxml = storageService.loadJrxmlFile(inputFileName);
jasperReport = JasperCompileManager.compileReport(jrxml);
// Save compiled report. Compiled report is loaded next time
JRSaver.saveObject(jasperReport, storageService.loadJasperFile(inputFileName));
}
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, dataSource);
// return the PDF in bytes
bytes = JasperExportManager.exportReportToPdf(jasperPrint);
} catch (JRException | IOException e) {
log.error("Encountered error when loading jasper file", e);
}
return bytes;
}
@Override
public byte[] generatePDFReport(String inputFileName, Map<String, Object> params) {
return generatePDFReport(inputFileName, params, new JREmptyDataSource());
}
您能告诉我问题以及如何解决吗?