I want to open a .doc file and print out using php (or only count lines and words). I tried with the COM library, but it didn't work (I'm using linux server). I also tried installing Antiword
but it doesn't work, because in my server safe_mode=off
and i can't change it.
Are there any solution, how can I open and view this file or simple count how many lines or words does it have?
Asked
Active
Viewed 1,903 times
1
-
6If it's a word '07 .docx file, then it's just a bunch of XML you can read using PHP's dom. For the old school OLE-based files, then you're probably SOL. Even MS can't read them properly. Some reasons why here: http://www.joelonsoftware.com/items/2008/02/19.html – Marc B Sep 13 '11 at 20:45
-
possible duplicate of [Reading DOC file in php](http://stackoverflow.com/questions/7358637/reading-doc-file-in-php) – Gordon Sep 13 '11 at 20:46
-
possible duplicate of [Opening a MS Word Document without using COM object](http://stackoverflow.com/questions/2902154/opening-ms-word-document-without-using-com-object) – Gordon Sep 13 '11 at 20:47
-
2possible duplicate of http://stackoverflow.com/search?q=open+word+document+php – Gordon Sep 13 '11 at 20:48
-
@Gordon: +1 for making me laugh with that last one... – Cyclone Sep 13 '11 at 21:11
-
Okey, i saw every possible question that looks like mine, and as i said i need to open or count the lines from a .doc file (not .docX, which can be find in the answers above) . Thanks @Marc B for the explanation – Biggy Sep 13 '11 at 21:22
-
possible duplicate of [Reading/writing a MS word file in PHP](http://stackoverflow.com/questions/188452/reading-writing-a-ms-word-file-in-php) – Gordon Sep 14 '11 at 07:54
1 Answers
0
Install catdoc
on your server and use shell_exec
to invoke it. With the converted plain text you can do your word and line counts.

cweiske
- 30,033
- 14
- 133
- 194