How to convert docx file to html

I’d like to upload a docx file using yii, and display it on web page with all the data and style. Later on, perform some editing on it.

  1. can you suggest a web site with similar functionality?

  2. What is the best library to convert docx to html?

    I didn’t find any yii extension for this purpose.

Thank you!

  • Nick

Well, .docx mainly consists of zipped XML. It should be possible to apply some XSL/T magix to turn it into HTML.

have you done it before? How hard it is to do it?

Google gives this in a pretty high position:

No. But it should be very well possible: .docx is an open and documented format.

I have recently been looking for a similar solution but without much luck.

At the moment has given me some ideas.

In the examples, look at createHTML.php

Unfortunately there are many things not working as I would like.

It fails to create embedded links and images don’t seem to work either.

I haven’t spent much time with it but did manage to get the links working by hacking one of the classes, ‘’.

You see the assets, including links and images, are actually stored as ‘relationships’ in other xml files within the docx structure.

As soon as I get more time, I’m sure I can get the images to work in a similar way, although sizing and positioning may be an issue if you need it to look the same as the source.

Give me a shout if you need to see how I got links to work. It’s not elegant because I’m just playing around at the moment.