How PHP reads a Word document

Source: Internet
Author: User
This article mainly introduces the method of PHP to read Word documents, analyzes the opening of COM components, property settings and the operation skills of opening and reading Word documents based on COM components, and needs friends to refer to the following

Specific as follows:

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;

Related recommendations:

Python reads the text content in Word

PHP Read Word document method sharing

PHP reads Word documents and shows _php tutorials through the Baihui Web API

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.