I have have to generate a 2003 compatible doc file from python without using external program like OpenOffice or embedded language like java using Jasper, but I have not found a way to do it. Creating a docx is quite simple and not suppose a problem, but the doc file is another history. As an alternative solution I tried to generate a rtf file, but the unicode incompatibility (there is a library out there solving this) and the lack of features don't allow me to go further and meet my needs. Any advice or solution? Thanks in advance!
3 Answers
Because it's a binary format you have few options. JODReports or Docmosis might be both sit over OpenOffice so can generate real doc-format files. You should be able to run either from Python and optionally bridging into Java if that improves your performance.
A google for python generate word document
lead to a lot of good results. It seems that either py docx or win32com.client are useful libraries.
To read docx files with Word 2003 you have to install a plugin.
You could generate HTML first, then automatize pandoc to convert it into an ODT. Then, using the PyUNO bridge, convert it to a Doc. It's a pretty long chain but I did not figure out a better way of doing it. Also have a look at http://wiki.services.openoffice.org/wiki/Python.
The specification of .doc files is, in my opinion, quite a mess and won't be easy to generate it directly with python. Although there have been some attempts of python libs for writing doc files, they are in very early stage and might not serve you...