views:

881

answers:

7

Hi,

I want to add an word import function to our CMS, the only problem I cannot seems to find a good library for reading docx files (Word 2007).

Do anyone has some recommendations, the library should be able to extract content of the document and basic styling like italic, bold, superscript?

Thanks for your help

+2  A: 

docx files are actually just containers for the document's XML. You should be able to unzip the docx file and then go to the word folder inside, then to the document.xml. This has the actual text. But things like the fonts and styles are in other xml files in the docx container, so you'll probably want to mess around a bit and figure out what is what and how to match it up (start by using namespaces, I bet).

But yea, unzip the file, then use simplexml to convert it into something you can actually mess around with.

Anthony
Thanks but I am wondering if someone didn't came with a library to do that. I would do some XSLT processing if I really need.
RageZ
See my other answer. The only thing that I don't like about it is the lack of easy to find API
Anthony
+1  A: 

Or, since you requested a library, you may want to look into something like Docvert. I was just looking around based on your question, and it's my favorite so far for PHP. You input the word file location, it transforms it into something simple with the attributes and all that good stuff.

Anthony
looks promising but I would have to make an API of it.
RageZ
+1  A: 

There is a library to do this but it work with Zend framwork may be it will help you It is called phpLiveDocx : http://www.phplivedocx.org/downloads/ The library is licensed under New Bcd

sohaibafifi
+1  A: 

There is a free PHP library for managing docx: You may find it in http://www.phpdocx.com I hope ti can be useful :-)

Eduardo
+1  A: 

I have just find a library that has both reading and writing support check it on the codeplex forge http://openxmlapi.codeplex.com and it is licensed under GPLv2 .

sohaibafifi
+1  A: 

You can try using Aspose.Words for .NET or Aspose.Words for Java. You can use one via COM Interop and another via Java Bridge as described in our documentation.

romeok
+1  A: 

Convert a docx document to a odt using OpenOffice. Use then eZ Components to do the parsing and import. They actually use the import in their CMZ eZ Publish.

DrDol