This article mainly introduces the method of PHP to read Word documents, the detailed analysis of the opening of COM components, property settings and the use of COM components to open and read Word document operation skills, the need for friends can refer to, hope to help everyone.
The PHP development process may be a Word document reading problems, where you can take advantage of COM components to complete this operation
First, open the php.ini com, the operation is as follows
1.
Extension=php_com_dotnet.dll
2.
Com.allow_dcom = True
Second, after opening, you can try the following actions
1. Create an index that points to the new COM component
$word = new COM ("Word.Application") or Die ("Can ' t start word!");
2. Displays the version number of the word that is currently in use
echo "Loading Word, v. {$word->version}";
3, set its visibility to 0 (false), if you want to make it open in the forefront, use 1 (true)
$word->visible = 0;
4. Open a document
$word->documents->open (DirName (__file__). " /1.doc ");
5. Read the contents of the document
$test = $word->activedocument->content->text;
6. Output document Content
Echo $test;