Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

streaming PDF document to the browser

 
nikil shar
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
am trying to stream a PDF doco to the browser via a servlet :




but in the browser it displays garbage characters !!

please advise what could be wrong.

ta.


forgot to say i am using I.E 6
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does the same thing happen with other browsers ? Is your server setting the mime type correctly when the browser displays the PDF ?

Looks like your browser gets the data but it unaware about how to handle the data correctly. If the MIME type is set correctly, it would open as a PDF.
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is your browser is not detecting the mime-type or you do not have a adobe-plugin with your version of IE6.

A fool proof method for this is to mention the content-disposition as an attachment, that way it will ask you how you want to use the file: open it or save it.



In case you want to directly open it in the window. use the disposition as inline instead of attachment. However for that make sure that the mime-type is set correctly.




 
prav ba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply. can you please advise how to set the mime type so pdf can be displayed directly to the IE browser ??

my code so far is



but it still displays garbage characters e.g %PDF-1.4 %???܍ 4 0 obj <>>>>> endobj ......
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you also show the code that you use to stream back the pdf..?
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prav ba wrote:but it still displays garbage characters e.g %PDF-1.4 %???܍ 4 0 obj <>>>>> endobj ......

Yep, that's what a PDF document looks like if you display it as text. So that's the problem, the browser doesn't know it's PDF. You appear to be setting the content type correctly so perhaps there's something else resetting it incorrectly later. Perhaps you have a filter which resets it to text/html for example. Look at the headers which the browser receives to find out what content type is actually being sent.
 
prav ba
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i stream the pdf back to the browser as such :



can you please point out how to look at the header which the IE browser receives in order to find out thet content type being sent to the browser??

thanks again for your help.
 
Paul Clapham
Sheriff
Posts: 21581
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prav ba wrote:can you please point out how to look at the header which the IE browser receives in order to find out thet content type being sent to the browser??


No, I can't. I don't use IE for web development, I use Firefox. Which has the free Live HTTP Headers plugin for doing exactly that. One time when I was forced to use IE, I had to track down tools which cost $99 to do the same thing.
 
Aditya Keyal
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To check the header and other details on IE use the TCP/IP Monitor available with eclipse IDE. Its FREE and really easy to use. That will help you identify the final header being set.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic