This article mainly introduces the example of PHP in the HTML word of the method of the transfer of relevant information, involving PHP HTML word transfer of knowledge, this article is very detailed, with reference value
The following piece of code to introduce PHP to the HTML into Word, the specific content is as follows:
This is tested, this method is a bit bad, HTML page code to write in PHP, but somehow can run, see the program
<?php class Word{function Start () {Ob_start (); Echo '
Let's share a piece of code PHP implementation of Word to HTML method
For a perfect solution, office to PDF or HTML, preferably with Windows Office software, LibreOffice cannot be transformed perfectly, WPS has no API.
First confirm that the COM module is not open, phpinfo inside if there is com_dotnet module, the description has been turned on, if not, modify PHP.ini,
The code is as follows:
Com.allow_dcom = True
Before the comments removed, restart on OK, PHP official website said, php5.4.5 before, COM module is built-in, in fact, is not necessarily all, the official website of the PHP 5.3.39,com module is not built-in.
If not the built-in module, PHP.ini Plus, the premise of your Ext folder, there is the extension
The code is as follows:
Extension=php_com_dotnet.dll
And then reboot is 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 ');
Attention:
1. Converted HTML, view the source code, the more chaotic
2. Winword.exe is called during the conversion process
3. If the page has been loaded, rename the document and then go back.