aspose file tools*
The moose likes Servlets and the fly likes Saving already opened pdf file in broswer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Saving already opened pdf file in broswer" Watch "Saving already opened pdf file in broswer" New topic
Author

Saving already opened pdf file in broswer

Veeren Jote
Greenhorn

Joined: Dec 01, 2009
Posts: 6
I have servlet which creates and send a pdf based file and i ask it to open inline inside of a browser window.
This works as intended, but when i try to "save" the file from the Adobe's menu, it just takes the servletname for the file name instead of actual filename i supplied.

Did anyone overcome this issue?
Veeren Jote
Greenhorn

Joined: Dec 01, 2009
Posts: 6
Code is something similar to below:

response.setContentType("application/pdf"); // MIME type for pdf doc
response.setContentLength(fileContent.length);
String downloadreportname = "CustomeFileNameGenerated.pdf";
//set response headers
response.addHeader("Content-Disposition", "inline; filename=" + downloadreportname);

response.getOutputStream().write(getFileContents());

This works like a charm, but when the actual file is downloaded by the broswer and opened up inside a broswer window by adobe plugin, I dont get the right file name when we hit "save"
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

It's doing exactly what you told it to. If you don't want it to be inline, don't specify inline. What you want is "attachment".


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Veeren Jote
Greenhorn

Joined: Dec 01, 2009
Posts: 6
Thanks for your reply, appreciate your help.
Well i know about inline & attachment clauses, and thats what my intention is... to display the pdf inline inside browser.

But after the PDF is loaded inside the browser and we want to hit save on the Adobe's plugin's menu inside the broswer, then it provides a dialog box which should prompt me to save the file.
So far so good, but the prompted name that is displayed is NOT the name i intended it to be, its with the servlet's name.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

I do not believe that that is something you will be able to control.
Veeren Jote
Greenhorn

Joined: Dec 01, 2009
Posts: 6
Thanks for your reply.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Saving already opened pdf file in broswer