Click here to Skip to main content
15,890,946 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi all,


i have a webpage and i wish to view documents like doc,pdf in that web paeg.how to do that. please help me.

thanks in advance

more clearly

consider if i have an html page and which contains a div tag.i need to display the doc in that specified div in html.



i need to display our PDF in my web page without any plugin and it needs to view in all browsers

Regards,
shefeek
Posted
Updated 28-Aug-13 19:01pm
v3

"DOC" probably means obsolete Microsoft Word document (present-days format is Open XML, files are named *.docx), and PDF is PDF. Even though PDF is the standard, it's not a part of W3 standards, so not all systems/browsers support it, and those supporting the standard may use some plug-ins which some user may not want to install (I personally use the PDF viewer not supported by browser, cannot view those documents on the Web pages and don't care a bit about it). So, you should never assume that all users will view PDFs in a browser. I don't think this is a problem though. And forget about proprietary Word documents.

Nevertheless, Word documents are also often supported by Web sites. In some areas this is even very typical (one example is job hunting sites). The secret is simple: the documents are supported internally, only on server side. Viewing and edition of the documents are always presented through HTML which mimics Word document look and styling, with some degree of similarity.

For parsing Word document, you would need to use Microsoft Open XML file format. You can always learn the formats, as they are standardized. Please see:
http://en.wikipedia.org/wiki/Office_Open_XML[^],
http://en.wikipedia.org/wiki/Microsoft_Office_XML_formats[^],
http://en.wikipedia.org/wiki/Office_Open_XML_file_formats[^].

(Don't mix them up with OpenDocument, http://en.wikipedia.org/wiki/OpenDocument[^].)

Now, there is another approach to it. There are third-party products working with Microsoft Office document. If they can do it, you can, too. You just need to download source code of some open-source products and find out how it works. The only open-source code I know is OpenOffice itself (where .odt came from) and its fork LibreOffice. Please see:
http://en.wikipedia.org/wiki/OpenOffice.org[^],
http://www.openoffice.org/[^],
http://en.wikipedia.org/wiki/LibreOffice[^],
http://www.libreoffice.org/[^].

You can download the source and find the code working with nearly all versions of Office documents. And, of course, .ODT and all other OpenOffice/LibreOffice documents.

It is not recommended to use Office Interop assemblies on the server side. Please see these Microsoft articles:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2[^],
http://support.microsoft.com/kb/257757/en-us[^].

Instead, Microsoft Open XML SDK is recommended:
Alternatively, you can use Open XML SDK:

http://www.microsoft.com/en-us/download/details.aspx?id=30425[^].

This way, you can support new XML-based Office formats (such as .DOCX, .XLSX), ECMA-376 standard.

And this is another approach: http://npoi.codeplex.com[^].

Please also see my past answers:
Convert Office-Documents to PDF without interop[^],
Hi how can i display word file in windows application using c#.net[^].

—SA
 
Share this answer
 
v2
Comments
shefeekcm 23-Aug-13 1:36am    
pls see my comment..thanks for your reply
Sergey Alexandrovich Kryukov 23-Aug-13 10:52am    
Excuse me, which comment?
Are you accepting the answer formally (green button)?
—SA
anu katari 19-Dec-17 2:57am    
Is there any new way that can help me to view word document in web browser ?
Use Google Doc Viewer! just add a markup like the following inside your DIV:

HTML
<iframe src="http://docs.google.com/gview?url=http://infolab.stanford.edu/pub/papers/google.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0"></iframe>


Just set up your own documents file to the "url" query string param and that's it! I use it in many project and it works like a charm.
 
Share this answer
 
Comments
shefeekcm 29-Aug-13 0:58am    
i think it need reader plugin in our machine
???
shefeekcm 29-Aug-13 0:58am    
in my case client does not bothered about these type of things
Marc Gabrie 29-Aug-13 13:08pm    
it does not need any plug-in installed at the client machine as Google Viewer render the PDF as an image! have you tried it? if not, then do it

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900