How does PHP get word pages?

Source: Internet
Author: User
Keywords Openoffice pdf
Try to convert OpenOffice to PDF, but it takes a long time and the format changes

Reply content:

Thank you for your invitation. (please send me a question such as file format or protocol format analysis.)
It's simple if you just get the number of pages.

manual operation: (Code operation please refer to)
Because now it's all in docx format. I'll talk about the manual scheme.
1. Change the name of the docx file extension to zip;
2. Open this zip file, three folders and an XML file will appear by default;
3. Enter the Docprops folder, there are two files: Core.xml and app.xml;
4. Open the App.xml and find the " x "This line, here is the number of pages of the docx file.

principle:
The docx document is essentially a compressed file in a zip format, and the attribute information for the docx document is recorded in the corresponding XML file. Details can be explored on their own.

Microsoft Official definition: DOCX
Microsoft Corporation
Microsoft Official definition: DOC
Understanding Word Ms-doc Binary file formats
Thank you for your invitation.
Didn't do anything like that, but Baidu was handy ...
After 2007 Word files can refer to Faizhongxuan's answer ...
But he gave the manual version of the ...

It should not be a problem to change the manual version to automatic version. Then I say another method, PHP5 seems to be able to call COM, and Office has a COM interface, so you can directly from inside PHP call, the specific interface can refer to MSDN, directly to the name guess also sorta.
The disadvantage of course is that it must be run on Windows and install Office first, and it is slow to call (actually started a word process in the background), with the advantage of supporting all formats including Doc and docx. All word operations can be done in addition to the number of pages read.
Just get the file attributes, remember that there are some Windows API can be used, specifically needs to be supplemented by others. Why not try Phpoffice, Phpoffice Phpword Ah, actually someone and I like the demand. Look here, there are examples of Cheng:
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.