We generate our reports using JasperReports 5.6.1 and allow to export the same template to PDF or Powerpoint. When working on a local computer, the downloaded PDF and PPTX file works fine. When we deploy our servers, PDF works fine, but PPTX files cannot be opened. When we run locally, it deploys to tomcat, but when deployed to a server, it launches on Websphere.
Things I tried and noticed:
- I checked the logs and there are no exceptions or anything to raise any eyebrows.
- The downloaded file is usually a little larger than the one we get when we run locally.
- If I changed the file extension to zip and unzipped them. The file structure and file names are the same, and the files actually have the same file size. The content, apparently, differs only in the names of the objects found on each slide.
- I think this may be a problem with files of type
x , which I also tried to export to xlsx, just to find out what will happen and works fine with the same template. - I added a static pptx file that was well known and can download it without any problems from the server. I did this to try to fix the server configuration from the problem, and felt that it worked, I assume that this is something with my code, just not sure what.
Here is the code for where we write the answer:
if ("xlsx".equals(type)) { response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".xlsx"); } else if ("pptx".equals(type)) { response.setContentType("application/vnd.openxmlformats-officedocument.presentationml.presentation"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pptx"); response.setCharacterEncoding("UTF-8"); } else { response.setContentType("application/pdf"); response.setHeader("Content-Disposition", "attachment; filename=" + filename + ".pdf"); } try (final ByteArrayOutputStream reportResult = reportsService.generateReport( getDeal(userId, dealId, sessionStore), getScenarioModel(userId, dealId, scenarioId, sessionStore), reportId, type)) { configureResponse(response, type, reportResult, dealId + "-" + scenarioId); // Write to http response reportResult.writeTo(response.getOutputStream()); } response.flushBuffer();
I have run out of troubleshooting ideas, and not being able to reproduce them locally, it's hard for me to diagnose.
java jasper-reports powerpoint
Jacob schoen
source share