【问题标题】:Display ms word file in html using angular使用角度在html中显示ms word文件
【发布时间】:2016-06-29 02:39:47
【问题描述】:

如何使用 Angular 或 JavaScript 在 HTML 页面中显示 Microsoft Word 文件。请推荐任何提供此功能的库。

【问题讨论】:

  • 使用I帧并传递你的文件来源
  • @Fryank 我已经尝试过使用 I 框架,但它只会打开一个对话框来下载文件。永远不要在浏览器中显示它。请提出任何其他方法。

标签: angularjs html


【解决方案1】:

目前没有浏览器具有呈现 Word 所需的代码 文档,据我所知,没有客户端库 目前存在用于渲染它们的任何一种

但是,如果只需要显示 Word 文档,而不需要 要对其进行编辑,您可以通过 to 使用 Google Documents 的查看器 显示远程托管的 .doc/.docx。

<iframe src="http://docs.google.com/gview?url=http://remote.url.tld/path/to/document.doc&embedded=true"></iframe>

示例: jsfidle

但是,如果您希望在大多数(如果不是所有)浏览器中获得本机支持,我建议您将 .doc/.docx 重新保存为 PDF 文件。这些也可以使用 Mozilla 的 PDF.js 独立呈现。

编辑:

非常感谢 fatbotdesigns 在 cmets 中发布 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>

活生生的例子:

Google Docs Viewer

Microsoft Office Viewer

【讨论】:

【解决方案2】:

所以我从研究中发现,你不能使用 java script 或 angular 显示 word 文件,它只会打开一个对话框来下载文件。

这里有一些链接支持我的结论。 display doc file in HTML link1
display doc file in HTML link2

您还可以将 word 文件转换为 HTML 并在浏览器中预览。 Mammoth.JS 是最好的选择。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-19
    • 2023-04-03
    • 2013-04-13
    • 2021-02-23
    相关资源
    最近更新 更多