Take the 2-minute tour ×

I am using pisa, that is a python html to pdf convertion library, Does it exist same thing for word document : a html to .doc python conversion library ?

share|improve this question
Why would you want this? MS Word can read HTML. –  MSalters Nov 19 '10 at 15:08
I have the same problem: I have a html that uses pisa to convert to pdf and I want to do the same thing with word. its a big document, ~20 pages, using the same piece of code to generate the html and then export thru pisa or something else would be great. –  Rafael Barros Jun 12 '12 at 17:24
@Eric: Recently, I had the same problem. Just wondering, did you find a solution to convert HTML to Word .docx? Thanks. –  tao.hong Apr 8 '13 at 21:42
add comment

3 Answers

You could use win32com from the pywin32 python extensions for windows, to let MS Word convert it for you. A simple example:

import win32com.client

word = win32com.client.Dispatch('Word.Application')

doc = word.Documents.Add('example.html')
doc.SaveAs('example.doc', FileFormat=0)

share|improve this answer
add comment

Though I am not aware of a direct module that can allow you to convert this, however:

  1. You can convert HTML to plain text first using the html2text module.
  2. After that, you can use this the python-docx module to convert the text to a doc or a docx file.
share|improve this answer
add comment

In case anybody else lands here attempting to convert the other way around, the above code works, but you need to modify the FileFormat value.


Example: Filtered html is 10, instead of 0.

share|improve this answer
add comment

Your Answer


