使用php进行Word到html的转换


Word to html conversion using php

我正在linux服务器上工作。我需要将一个word文件转换为html,并按照word文档中显示的方式显示。

可以在没有的情况下在Linux机器中转换它。NET支持?任何人对此有任何想法,请帮帮我。我试过很多脚本,但它只会显示没有对齐的文本内容。

您可以从命令行使用LibreOffice。

soffice --headless --convert-to html file.doc

在PHP中,只需使用shell_exec或其他东西来调用它。

最终我得到了Abiword 的解决方案

安装带有的abiword

 yum install abiword

然后,这是代码

<?php
 $path=getcwd();
 $cmd  = 'abiword --to=html '.$path.'/test.docx';
 exec($cmd);
 $content=file_get_contents($path.'/test.html');
 unlink($path.'/test.html');
echo urldecode($content);
?>