Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to rename the outputted PDF file in the Response object?

Hi,

Every report that I export in my servlet app will have the filename of the java class file plus the pdf extension, for example, the page "printreport" will generate "printreport.pdf", how can I rename the outputted file?

This is my code, which does not change the filename right now:

ReportClientDocument reportClientDoc = new ReportClientDocument();
reportClientDoc.open(reportname, OpenReportOptions._openAsReadOnly);
Object reportSource = reportClientDoc.getReportSource();
...
...
response.reset();
response.setContentType("application/pdf");
response.addHeader("content-disposition", "inline; filename=MyCustomReportName.pdf");
response.addHeader("Content-Disposition", "attachment;.filename=MyCustomReportName.pdf");
response.flushBuffer();      
exportControl.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

Thank you!

replied

> response.addHeader("Content-Disposition", "attachment;.filename=MyCustomReportName.pdf");

What happens if you replace .filename with filename?

Sincerely,

Ted Ueda

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question