2

How can i display word documents, pdf documents in the browser using files from the web folder? So if a user uploads a pdf report and wants to see it in the browser, how can i allow that to happen? Can HTML5 be of use?

AAA
  • 3,120
  • 11
  • 53
  • 71
  • 1
    I attempted something like this a couple years ago but gave up. The problem I ran into was that the browser didn't that to recognize the mime type header. To serve up the document itself (via a link) won't be an issue, its trying to serve up content from a db or from outside your web folders that may be problem. – Fatmuemoo Jan 23 '11 at 04:09
  • like for example when you display an image its usually from your web folder like So is there a similar format to present pdf or word docs? – AAA Jan 23 '11 at 04:14

1 Answers1

1

From your comment about displaying images, it seems like what you want is to embed the PDF or Word file in the page. The easiest thing to do is use an iframe, like so:

<iframe src="http://myserver.com/userUploads/foobar.doc" width="500px" height="500px">
</iframe>

However, the different widgets for different document types will look substantially different and may not provide all the functionality you would expect (as in this example). In addition, not all browsers will be configured with a way to display the document inline - some will prompt the user to download the file.

Uploading the documents to something like Scribd will provide a more uniform experience across document types and browsers; however, depending on how important it is for these documents to be private, Scribd may not be a good solution.

Community
  • 1
  • 1
Arkaaito
  • 7,347
  • 3
  • 39
  • 56