views:

155

answers:

2

How can you dynamically generate a .doc file using AJAX? Python? Adobe AIR? I'm thinking of a situation where an online program/desktop app takes in user feedback in article form (a la wiki) in Icelandic character encoding and then upon pressing a button releases a .doc file containing the user input for the webpage. Any solutions/suggestions would be much appreciated.

PS- I don't want to go the C#/Java way with this.

A: 

It don't have to do much with ajax(in th sense that ajax is generally used for dynamic client side interactions)

You need a server side script which takes the input and converts it to doc.

You may use something like openoffice and python if it has some interface see http://wiki.services.openoffice.org/wiki/Python

or on windows you can directly use Word COM objects to create doc using win32apis but it is less probable, that a windows server serving python :)

I think better alternative is to generate PDF which would be nicer and easier. Reportlab has a wonderful pdf generation library and it works like charm from python. Once you have pdf you may use some pdf to doc converter, but I think PDF would be good enough.

Edit: Doc generation On second thought if you are insisting on DOC you may have windows server in that case you can use COM objets to generate DOC, xls or whatever see http://win32com.goermezer.de/content/view/173/284/

Anurag Uniyal
thanks. i'm not great at Python, so that seems like a lot of work though! never dabbled in OO.o either, but this seems like a good opportunity.
SSingh
You don't really want to do .doc at all, you especially don't want to do COM interop to office on a server (licensing and performance issues). The newer office 2007 "standard" formats - .docx, .xlsx. - are worth considering because that can be generated without a copy of office.
Murph
+2  A: 

The problem with the *.doc MS word format is, that it isn't documented enough, therefor it can't have a very good support like, for example, PDF, which is a standard.

Except of the problems with generating the doc, you're users might have problems reading the doc files. For example users on linux machines.

You should consider producing RTF on the server. It is more standard, and thus more supported both for document generation, and for reading the document afterwards. Unless you need very specific features, it should suffice for most of documents types, and MS word opens it by default, just like it opens its own native format.

PyRTF is an project you can use for RTF generation with python.

Elazar Leibovich
I had completely forgot about .rtf. Am okay using it instead of .doc, thanks!
SSingh
Word also supports a well-documented XML format.
ChrisW
Do you mean docx?
SSingh
I actually ment doc. Since docx is relatively new, and not everyone have the newest word. So I thought you ment doc. docx is actually open format, but I'm not sure it have a great tool support yet.
Elazar Leibovich

related questions