Display word .doc file content with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
winter2009
Forum Newbie
Posts: 1
Joined: Tue Nov 17, 2009 12:02 am

Display word .doc file content with php

Post by winter2009 »

Is it possible to read word document content and display it on a webpage with php? I searched and found that COM can do this. But COM can only be used on windows server. I am using apache server now, is it possible to achieve this?

Thanks so much.
User avatar
iankent
Forum Contributor
Posts: 333
Joined: Mon Nov 16, 2009 4:23 pm
Location: Wales, United Kingdom

Re: Display word .doc file content with php

Post by iankent »

Is it a Word 97-2003 or Word 2007?

If its a 2007 (.docx) file then you can use gzip to uncompress and use PHP's XML functions to read the data and display as you like (getting it to display as Word displays it would be a bit trickier!)

If it's a 97-2003 (.doc) file then you're probably out of luck

Alternatively, you could convert your .doc/.docx files to RTF or HTML using Word and display those instead? HTML you could output as-is, and RTF is pretty well documented online.

hth
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Display word .doc file content with php

Post by Eran »

You can use a shell application such as AbiWord that converts the .doc file to a format you can work with.
Shellyyin
Forum Newbie
Posts: 8
Joined: Thu Sep 10, 2015 1:49 am

Re: Display word .doc file content with php

Post by Shellyyin »

You can use google docs to display Word document content online. Or if you want this function works in some system, you can just use aceoffix.
Post Reply