File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response Header for PDF?

 
Ryan Forman
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set the response header in my code as follows:

response.setHeader("Content-disposition", "attachment; filename=" + reportName);

If I remove "attachment" from the line above, the PDF will display in the browser. If I leave the code as-is, then the user is prompted to either save or view the PDF. If the user chooses to view the PDF, the PDF is displayed in Acrobat. I would like to find a middle ground. I would like to prompt the user to either save or view the PDF, however; if the user chooses to view the PDF, I would like to display it in the browser...not in seperate Acrobat. Is this possible? How? Thank you for the help.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't. Either you force a save-as prompt like that or let the browser decide what to do.
In the latter case the browser will display the PDF in some way if it can (meaning it has a PDF reader plugin or built-in capability) and otherwise will prevent a prompt asking the user what to do.

PS, this has nothing at all to do with Java per se.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic