php将word转为html的方法:1、使用编辑器打开php.ini配置文件;2、找到【com.allow_dcom = true】,取消注释;3、重启服务器;4、将word转为html即可。

要想完美解决这个问题,office转pdf或者html,最好还是用windows office软件,libreoffice不能完美转换,wps没有api。
(学习视频推荐:java视频教程)
先确认com模块是不是开启,phpinfo里面如果有com_dotnet模块,说明已开启,如果没有,则修改PHP.ini文件,取消配置com.allow_dcom = true的注释并重启。
php官方网站说,php5.4.5之前,com模块是内置的,其实也不一定全是,官网下的php 5.3.39,com模块就没有内置。
如果不是内置模块的话,php.ini加上,前提你的ext文件夹下,有该扩展extension=php_com_dotnet.dll然后重启就OK了。
function word2html($wordname,$htmlname) { $word = new COM("word.application") or die("Unable to instanciate Word"); $word->Visible = 1; $word->Documents->Open($wordname); $word->Documents[1]->SaveAs($htmlname,8); $word->Quit(); $word = null; unset($word); } word2html('D:/www/test/6.docx','D:/www/test/6.html');
注意:
1、转换出来的html,查看源码,比较乱的
2、转换过程中会调用winword.exe
3、如果页面一直在加载,把文档重命名,然后再重新转。
相关推荐:php培训
Das obige ist der detaillierte Inhalt vonphp怎么将word转为html. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!
HTML-Copyright-Symbol
HTML-Online-Editor
So ändern Sie die Hintergrundfarbe eines Wortes in Weiß
So löschen Sie die letzte leere Seite in Word
Warum kann ich die letzte leere Seite in Word nicht löschen?
Eine einzelne Word-Seite ändert die Papierausrichtung
HTML-Webseitenproduktion
HTML-Speicherplatz