How can I create a Word document using Python? [closed]
A couple ways you can create Word documents using Python:
- Use COM automation to create a document using the MS Word object model (using
pywin32
). http://python.net/crew/pirx/spam7/ - Automate OpenOffice using Python: http://wiki.services.openoffice.org/wiki/Python
- If rtf format is OK, use the PyRTF library: http://pyrtf.sourceforge.net/
EDIT:
Since COM is out of the question, I suggest the following (inspired by @kcrumley's answer):
Using the UNO library to automate Open Office from python, open the HTML file in OOWriter, then save as .doc.
EDIT2:
There is now a pure Python python-docx project that looks nice (I have not used it).
1) If you want to just stick another step on the end of your current pipeline, there are several options out there now for converting PDF files to Word files. I haven't tried 123PDFConverter, but the CNET Editors recommend it (same link); it has a free trial; and it supports automation. As with any 3rd-party file converter, your mileage may vary, depending how complicated your PDFs are, and how good the software actually is.
2) Building on codeape's COM automation suggestion, if you COM automate Word, you can open your actual HTML file in Word, and call the "Save As" command, to save it as a DOC file.