Asked • 05/20/19

Issue downloading report exported to PPTX when deployed on server?

We are generating our reports using JasperReports 5.6.1, and allow exporting the same template to PDF or PowerPoint. When running locally, the PDF and PPTX file downloaded work perfectly. When we deploy to our servers PDF works fine, but PPTX files cannot be opened. When we run locally, it is deployed to tomcat, but when deployed to the server it is running on Websphere. Things I tried and noticed: - I have checked the logs, and there are no exceptions or anything to raise any eyebrows. - The file downloaded is usually slightly larger than the one we get when we run locally. - If I changed the extension of the files to zip, and unarchived them. The file structure and file names are the same, along with the files actually being the same file size. The contents seem to only be different in the names for the objects found in each slide. - thinking it may be a problem with the `x` type files I tried exporting to xlsx also, just to see what would happen, and it works fine with the same template. - I added a static pptx file that was known good, and can download it without issue from the server. I did this to try to eliminate a server config from the issue, and sense it worked, I am assuming it is something with my code, just not sure what. Here is the code for where we write the response: 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 ideas on troubleshooting steps, and without being able to reproduce it locally, I am finding it difficult to diagnose.

1 Expert Answer

By:

Jam N. answered • 09/03/23

Tutor
0 (0)

Dynamic Academic Pathfinder: Excellence in Leadership and Learning

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.