• Post Reply Bookmark Topic Watch Topic
  • New Topic

Open PDF or word doc or text file from byte array data using JSF.  RSS feed

 
Srinivas Kasani
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have byte array data available. Along with byte array, I do get the property information like what the bytearray stands for like PDF or Word or JPG etc. How can I display or open this data in the browser accordingly. An action in JSF is causing me to read the bytearray data. Now I want to navigate to a new page to display or open the byte array content.
 
Tim Holloway
Bartender
Posts: 18663
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Internet Explorer is legally restricted against opening PDF's and Office documents in the IE browser Window due to a patent on that technology. The best you can do is set up for the document to be opened in its application (Adobe Reader or Office).

To do that, you need a "pure" data stream, not an HTML data stream, so JSF is not a good choice to output this data. It's better to have a servlet do this output.

To get the proper application to open output data, you need to let the browser know what type of data it is, and you do that by setting the MIME type for the output data before you start outputting the data itself. Normal web pages have a MIME type of "text/html". There are special MIME types for PDF's and Office documents, and although I don't remember their exact values, they tend to begin with "x-vnd/".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!