Hello,
I am having one doc file and I want to count its words & number of pages using PHP. Is there any way using PHP to accomplish this? I tried to search the stuff on google & I found the solution but it was in COM which requires windows server & my server is linux. So how can I do this? Please help me if anyone has solved such issue. Thanks in advance.

    computerzworld,

    Reading MS Word files can be a challenge.

    If you visit here, http://www.linux.com/archive/feed/52385 you will see a series of Linux based applications that can convert MS Word to plain text.

    From that output (for instance using Antiword you can use an exec() command to export the MS Word to a plain text file and parse from there.

    I have never used this - but there is a commercial addon - PHPWordLib that may also work for you -- and the price at $35.00 it isn't too bad.

    There are many other options, however require a ton of additional work, such as using a Java Bridge with PHP and using the OpenOffice Developer libraries.

    Best of luck!

      If you know that your webserver is on a Windows platform and has Microsoft Office installed, you could also use [man]COM[/man] to start an instance of "Word.application" and use Word's COM interface to analyze the document.

      Otherwise, big.nerd is right in that working with files in such a proprietary format is a bit tricky and you may have better luck if you first convert it into a different format.

        Write a Reply...