简体   繁体   English

Spring Boot Jasper报告空白PDF

[英]Spring Boot Jasper Report Blank PDF

I have an web application. 我有一个Web应用程序。 I use Spring Boot 1.3.3, AngularJS, and Jasper 5.6.0. 我使用Spring Boot 1.3.3,AngularJS和Jasper 5.6.0。 When i try to download jasper report, i get blank PDF page. 当我尝试下载jasper报告时,我得到空白的PDF页面。 My code is: 我的代码是:

String jasperAdi = "yillikPlan.jasper";
StringBuffer pathMain = new StringBuffer();
pathMain.append(this.getClass().getResource("/static/jasper").getPath());
String jasperFileName = pathMain.toString() + File.separator + jasperAdi;
File jasperFile = new File(jasperFileName);
JasperReport report = (JasperReport) JRLoader.loadObject(jasperFile);
JasperPrint jasperPrint = JasperFillManager.fillReport(report, param, new JRBeanCollectionDataSource(ckModelList));
if (jasperPrint != null) {
    byte[] pdfReport = JasperExportManager.exportReportToPdf(jasperPrint);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.parseMediaType("application/pdf"));
    headers.setContentDispositionFormData("yillikPlan.pdf", "yillikPlan.pdf");
    ResponseEntity<byte[]> respon = new ResponseEntity<byte[]>(pdfReport, headers, HttpStatus.OK);
    return respon;

}

My jasper file location is /static/jasper. 我的jasper文件位置是/ static / jasper。 ckModelList is a java.util.List. ckModelList是一个java.util.List。 param is a Hashmap which i push report parameters. param是一个Hashmap,我可以推送报告参数。

How i fix this problem. 我如何解决这个问题。

空白碧玉报告

I was with the same issue when I tried to start using jasper in my Spring Boot application but it had nothing wrong with my java code it was just the propertie 'When no Data type' of the report. 当我尝试在Spring Boot应用程序中开始使用jasper时,我遇到了同样的问题,但是我的Java代码没有问题,这只是报告的“何时无数据类型”。 I was just testing, therefore I don't have any data only a label it took some hours to realize it. 我只是在测试,因此我没有任何数据,只是花了几个小时才意识到的标签。

If you have any problem understanding my "improving" english, please let me know that I'll try to explain better. 如果您在理解我的“提高”英语时遇到任何问题,请告诉我,我将尽力解释得更好。

Report Properties Image 报告属性图像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM