Hello ,
I want to open a PDF document in browser, which needs to have a specified filename when user tries to save it.
My web app sends an "application/pdf" document back to the browser.
I use the Content-Disposition HTTP header to instruct the browser to open the document inline, i.e. using the appropriate plugin, which is Adobe PDF in this case. When the user clicks Save As..., the document filename needs to be the one specified by the same HTTP header. Here is the code:
response.setContentType("application/pdf");
String contentDisposition = "inline; filename=\"filename.pdf\"";
response.setHeader ("Content-Disposition", contentDisposition);
response.setHeader ("Content-Length",new Long(file.length()).toString());
Unfortunately this does not work for me. Document opens fine, but I can't get it to have the name I specified. The plugin uses the default name, which is the full URL of the document. I tried several combinations of HTTP headers, but neither worked. I tried putting an additional GET request parameter at the end of the URL, like ...&filename=filename.pdf , but that didn't work either.
I tried Adobe 7.0 and 8.1.2.
Any suggestions ?
Thanks a lot!