How does php obtain the number of word pages?

Source: Internet
Author: User
It takes a long time to convert openoffice to pdf and then read the number of pages. In addition, it takes a long time to convert openoffice to pdf and then read the number of pages. In addition, the format is changed. Reply: Thank you. (if you have file format or Protocol format analysis, please send it to me .)
It is easy to obtain the page number.

Manual Operation: (for code operation, refer)
Because all documents are in docx format now. Let's talk about the manual solution.
1. Change the docx file extension to zip;
2. Open the zip file. By default, three folders and one xml file are displayed;
3. Enter the docProps folder, which has two files: core. xml and app. xml;
4. Open app. xml and find" X "This line is the number of pages in the docx file.

Principle:
Docx is essentially a zip compressed file. All the attribute information of docx is recorded in the corresponding xml file.

Microsoft official definition: docx
Microsoft Corporation
Microsoft official definition: DOC
Understanding Word MS-DOC binary file formats
Thank you ......
I have never done similar content, but I just clicked Baidu ......
For more information about word files after 2007, please refer to the answer provided by Fei zhuangxuan ......
But he gave a manual version ......

Changing the manual version to an automatic version is not a problem ...... For another method, PHP5 seems to be able to call COM, while Office has a COM interface, so it can be called directly from PHP. For specific interfaces, refer to MSDN, you can guess the name.
Of course, the disadvantage is obviously that you must run on Windows and install the Office first, and the call is very slow (in fact, a Word process is started in the background ), the advantage is that all formats including doc and docx are supported. In addition to reading pages, you can perform all Word operations.
If you only want to obtain file attributes, remember that some Windows APIs can be used. You need to add them. Why don't you try phpword in phpoffice? Someone has the same requirements as me. Here, there is a routine:
Php-How to get the number of pages in a Word Document on linux?

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.