Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set the default file name shown when trying to save PDF opened in inline view from browser ?  RSS feed

Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a website with links to PDF files. When a user clicks on the link, it should open the PDF in the browser.
But when the user clicks on the save button, I want a different name to be populated by default in the "Save As" dialog box.

Currently, it gives the entire URL (with some characters like : and / replaced by _) as the default file name.

Below is the code snippet I am using:

However, if I set the content-disposition to attachment, it pops up a dialog box with the name that I want to save. Here, if I click on Open it opens the PDF and then on trying to save the name that I want is shown by default.

Is there any other header that I need to set so that it works in the inline mode ?
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!