我用jasperreport做了一个模板,只有一些汉字和字母,但是在java里引用导出的时候,pdf可以生成但是是空白页怎么回事?环境什么的都是好的,我猜测是我代码的问题,但我不知道错在了哪里,求助
以下是我的代码,是我代码写的不对吗?望指正。
@Service
public class CAuditService {
@Autowired
B1Service b1Service;
@Autowired
C0Repository c0Repo;
private final String CONST_TEMPLATE_NAME = "AuditStatement.jrxml";
private final String CONST_REPORT_NAME = "監査文";
@Value("${jasper.jrxml.file.path}")
private String jasperJrxmlFilePath;
@Value("${report.output.path}")
private String reportOutputPath;
public void print() {
String filePath = generatePdfReport();
try {
ReportUtil.openPdf(filePath);
} catch (IOException e) {
e.printStackTrace();
}
}
private String generatePdfReport() {
String filePath = ReportUtil.getReportFilePath(reportOutputPath, CONST_REPORT_NAME);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("","");
try (InputStream template = new ClassPathResource(jasperJrxmlFilePath + CONST_TEMPLATE_NAME).getInputStream()) {
JasperReport report = JasperCompileManager.compileReport(template);
//JRBeanCollectionDataSource collectionDataSource = new JRBeanCollectionDataSource(null);
JasperPrint jasperPrint = JasperFillManager.fillReport(report,parameters);
JasperExportManager.exportReportToPdfFile(jasperPrint, filePath);
} catch (Exception e) {
e.printStackTrace();
}
return filePath;
}
}
不知道你这个问题是否已经解决, 如果还没有解决的话: