Html 使用angular在html中显示ms word文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35981094/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display ms word file in html using angular
提问by NNS
How can I display Microsoft Word file in HTML page using either Angular or JavaScript. Please suggest any libraries which provide this functionality.
如何使用 Angular 或 JavaScript 在 HTML 页面中显示 Microsoft Word 文件。请建议提供此功能的任何库。
采纳答案by NNS
So what I found from my research is you can not display a word file using java script or angular, it only opens up a dialog box to download the file.
所以我从我的研究中发现,你不能使用 java 脚本或 angular 显示一个 word 文件,它只会打开一个对话框来下载文件。
Here are some links backing my conclusion.
display doc file in HTML link1
display doc file in HTML link2
这里有一些链接支持我的结论。
在 HTML 链接 1 中
显示文档文件 在 HTML 链接 2 中显示文档文件
As an alternate what you can do is convert word file to HTML and preview it in browser. Mammoth.JS is the best option for this.
作为替代,您可以做的是将 word 文件转换为 HTML 并在浏览器中预览。Mammoth.JS 是最好的选择。
回答by R?sh?Kêsh Kümar
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 to display a remotely hosted .doc/.docx.
目前没有浏览器具有渲染 Word 文档所需的代码,据我所知,目前也没有用于渲染它们的客户端库
但是,如果您只需要显示 Word 文档,而不需要对其进行编辑,则可以通过 使用 Google 文档查看器来显示远程托管的 .doc/.docx。
<iframe src="http://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>
Example:jsfidle
示例:jsfiddle
However, if you'd rather have native support, in most, if not all browsers, I'd recommend resaving the .doc/.docx
as a PDF file Those can also be independently rendered using PDF.js by Mozilla.
但是,如果您希望获得本机支持,则在大多数(如果不是所有)浏览器中,我建议将其重新保存.doc/.docx
为 PDF 文件。这些文件也可以由 Mozilla 使用 PDF.js 独立呈现。
Edit:
编辑:
Huge thanks to fatbotdesigns for posting the Microsoft Office 365 viewer in the comments.
非常感谢 fatbotdesigns 在评论中发布了 Microsoft Office 365 查看器。
<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>
Live Examples:
现场示例: