For a perfect solution, it is best to use windows office software to convert office to pdf or html. Libreoffice cannot convert perfectly, and wps does not have an API.
First confirm whether the com module is turned on. If there is a com_dotnet module in phpinfo, it means it is turned on. If not, modify php.ini,
com.allow_dcom = true
Remove the previous comment and restart and it will be OK. The official PHP website says, Before php5.4.5, the COM module was built-in, but not necessarily all. In PHP 5.3.39 on the official website, the COM module was not built-in.
If it is not a built-in module, add it to php.ini, provided that your ext folder has the extension
extension=php_com_dotnet.dll
Then restart and it will be 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');
Note:
1, the converted html, check the source code, it is quite messy
2, the conversion process winword.exe will be called
3. If the page keeps loading, rename the document and then transfer it again
The above has introduced the conversion of php word to html, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.