how to display a word document (.doc) file in html page
preview doc file in html
how to display docx file in html
jquery display word document
I have successfully done code to display a PDF file in the browser instead of the "Open/Save" dialog. Now, I'm stuck trying to display a Word document in the browser. I want to display a Word document in Firefox, IE7+, Chrome etc.
No browsers currently have the code necessary to render Word Documents, and as far as I know, there are no client-side libraries that currently exist for rendering them either.
However, if you only need to display the Word Document, but don't need to edit it, you can use Google Documents' Viewer via an
<iframe> to display a remotely hosted
Solution adapted from "How to display a word document using fancybox".
However, if you'd rather have native support, in most, if not all browsers, I'd recommend resaving the
.docx as a PDF file Those can also be independently rendered using PDF.js by Mozilla.
Huge thanks to fatbotdesigns for posting the Microsoft Office 365 viewer in the comments.
<iframe src='https://view.officeapps.live.com/op/embed.aspx?src=http://remote.url.tld/path/to/document.doc' width='1366px' height='623px' frameborder='0'>This is an embedded <a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by <a target='_blank' href='http://office.com/webapps'>Office Online</a>.</iframe>
One more important caveat to keep in mind, as pointed out by lightswitch05, is that this will upload your document to a third-party server. If this is unacceptable, then this method of display isn't the proper course of action.
The answers by Brandon and fatbotdesigns are both correct, but having implemented the Google docs preview, we found multiple .docx files that couldn't be handled by Google. Switched to the MS Office Online preview and works likes a charm.
My recommendation would be to use the MS Office Preview URL over Google's.
ViewerJS is helpful to view/embed openoffice format like odt,odp,ods and also pdf.
For embed openoffice/pdf document
<iframe src = "/ViewerJS/#../demo/ohm2013.odp" width='700' height='550' allowfullscreen webkitallowfullscreen></iframe>
/ViewerJS/ is the path of ViewerJS
#../demo/ohm2013 is the path of your file want to embed
How to render word document(DOC,DOCX) in browser using , mammoth.js render word docx on Browser Example demo | word docx preview in client web browser | How do I render a Word document (.doc, .docx) in the No browsers currently have the code necessary to render Word Documents, and as far as I know, there are no client-side libraries that currently exist for rendering them either. However, if you only need to display the Word Document, but don't need to edit it, you can use Google Documents' Viewer via an <iframe> to display a remotely hosted .doc / .docx .
Native Documents (in which I have an interest) makes a viewer (and editor) specifically for Word documents (both legacy binary .doc and modern docx formats). It does so without lossy conversion to HTML. Here's how to get started https://github.com/NativeDocuments/nd-WordFileEditor/blob/master/README.md
- @Pankaj You do not have to upload it to Google Drive. You can just change the
urlparamteter to the full URL to the .doc file, either hosted on your server, or anywhere it can be directly linked to. Google Docs handles the conversion to a format that can be handled by the browser on the fly, and does not require it to be uploaded or stored on Google Docs, instead performing a server-side request to grab the file.
- @Pankaj Even if you're hosting a local server, Google cannot access
localhost. It needs a publicly accessible URL. You could use a basic forwarding service like Finch.
- You could also use the office live apps viewer: //view.officeapps.live.com/op/embed.aspx?src=your_url_here put this url in an iframe
- @BonifacePereira If you're setting up an intranet, you'll probably have to do some conversion locally, since GDocs and Live would both have to fetch the document from somewhere. If you're able to, you might be able to set up a server for conversion with OpenOffice or something: stackoverflow.com/questions/5538584/…
- Just want to point out that both of these methods definitely upload the files to Google's and Microsoft's servers. If you are dealing with sensitive information that should have limited access- do not do this. Use the alternative solution with PDF.js to generate a PDF version of the file to view in the browser and offer a link to download the various excel/doc versions.
- Is there any restriction to use this ? support.microsoft.com/en-us/help/2769380/…
- to provide a counter narrative - we chose the google version because the microsoft renderer takes a lot longer to load in both chrome and ff
- I will note that my library is completely unmaintained. It was able to convert docx files to something that could be rendered in the browser. I don't know if this is true anymore.
- Shall i able use the link url from aws s3