PHP 在不丢失样式和图像的情况下将 Word 文件转换为 HTML

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14996527/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:20:38  来源:igfitidea点击:

PHP Convert Word file to HTML without losing styling and images

phpms-worddocxdoc

提问by Herr

Is there an API for converting word files to HTML without losing the format?

是否有用于将 word 文件转换为 HTML 而不丢失格式的 API?

Can the google documents API be used for this?

谷歌文档 API 可以用于此吗?

I tried saaspose but the returning result is always a server error.

我试过 saaspose 但返回的结果总是服务器错误。

Solutions that did not work for me:

对我不起作用的解决方案:

采纳答案by alexpls

I've spent a bit of time loking into this, and the best solution that I've found was to install unoconvon the server, and using PHP to interface with it through system calls.

我花了一些时间研究这个问题,我发现的最佳解决方案是在服务器上安装unoconv,并使用 PHP 通过系统调用与它交互。

I would have loved to find a good native PHP solution for this, but unfortunately I couldn't.

我很想为此找到一个很好的原生 PHP 解决方案,但不幸的是我不能。

EditSince originally answering this, I've come across a web service which presents an API for converting documents. I haven't tested it very thoroughly but it does seem to produce decent results at converting Word to HTML: CloudConvert.

编辑自从最初回答这个问题以来,我遇到了一个 Web 服务,它提供了一个用于转换文档的 API。我还没有对它进行非常彻底的测试,但它在将 Word 转换为 HTML 时似乎确实产生了不错的结果:CloudConvert

回答by Yavor

The best solution I've found so far is http://www.phplivedocx.org/. You use it with the Zend framework. Very easy to set up and you get minimal deviation from the actual word format. It converts word docs to html very well.

到目前为止,我找到的最佳解决方案是http://www.phplivedocx.org/。您可以将它与 Zend 框架一起使用。非常容易设置,您与实际单词格式的偏差最小。它可以很好地将 word 文档转换为 html。

回答by kuldeep.kamboj

Try PHPWordlib. According to site it is based on PHPExcel Lib which perfectly read/write excelsheets.

试试PHPWord库。根据网站,它基于 PHPExcel Lib,它可以完美地读/写 excelsheets。

回答by krishna

PHPDocxhas a solution. According to site you may extract data directly from any database or spreadsheet and export them to other popular formats (PDF, DOC, HTML, ODT, ...) with the help of the conversion plugin. These reports may include editable graphs (only docx), images, tables, headers, footers, etcetera.

PHPDocx有一个解决方案。根据站点,您可以直接从任何数据库或电子表格中提取数据,并在转换插件的帮助下将它们导出为其他流行格式(PDF、DOC、HTML、ODT 等)。这些报告可能包括可编辑的图表(仅限 docx)、图像、表格、页眉、页脚等。

Am not sure how good it can convert word to html

我不确定它可以将 word 转换为 html 有多好