Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Open pdf in browser

 
R Sawant
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
My servlet is sending pdf in the response. I want this pdf to open the pdf in the browser only, instead of opening in the Acrobat reader. Can i control this. Please help me out. Its urgent.

Thanks
Ramdas
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramdas Sawant
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular, please see EaseUp to find out how adding the word "urgent" to your posts will usually slow down or stop responses.

Again, welcome to JavaRanch and good luck with your question.
-Ben


As to your question:
Browsers can't display PDFs on their own. A PDF viewer (such as Acrobat) is needed. Some browsers can embed Acrobat as a plugin and will appear to display your PDF in the browser.
To do this, you need to add a Content-Dispostion header with the 'inline' keyword.
Search this and the JSP forum with keyword 'Content-Dispostion' for more information.
If you're only providing a link to the PDF (as opposed to streaming it with your own code) you may not be able to control what headers are sent.
 
Ajay Krishnamurthy
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramdas,
To display the PDF file in your browser you must have any one of the following things..
1) Your Desktop must have the (PDF reader like Acrobat)
other wise
2) Your Browser must have the plug in to display the .PDF files.

okie come to the point .. in your Servlet or JSP .. first you to set the content type as (MIME) txt/pdf and you to read tat stream as well as u have to write it in your page ..
You can get the source code from the "Google" Search.. If u cant get the code please feel free to ask me ..

regards
Ajay Krishnamurthy
 
Praveen Babu
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can also do two things :

1. Use the embed tag
2. Use the object tag

However these two will work only if acrobat plugin is installed.

Bye & Regards,

Praveen
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic