How to write RTF from Python?

kkennedy titanrebel at comcast.net
Sat Apr 26 00:32:13 EDT 2003


achrist at easystreet.com wrote in message news:<3EA97D61.3CC9FE74 at easystreet.com>...
> Any suggestions of the shortest path from a Python program to RTF
> output?  RTF seems to be the best (reasonable combination of 
> features and compatability) common denominator for exporting
> data so that (windows) users can bring it into their own word
> processing program, whatever that may be.  (Any problem with
> that?)
> 
> Requirements are about like this:
> 
> 1. Don't need an edit control, just want to write a file, but if
> I have to open an edit window, I can.
> 
> 2. Don't want to do too much fancy.  Text, headings, bulleted
> lists,  maybe some variations in font size.
> 
> 3. Development platform is WinNT, target platform is any reasonably
> recent Windows machine (eg either anything newer than Win95 release 1
> or Win98 or better). 
> 
> TIA,
> 
> 
> Al


Be sure to code to the least common RTF spec.  From my experience, the
RTF format (MS open format???) is a moving target.  RTF files created
by MS Word 97 will look odd or worse in MS Word 95, and be completely
unreadable in WordPad. Either find out what version of RTF WordPad
uses and use that, or require your users to have a specific version of
MS Word (or the free download - MS Word viewer).

Just a thought...HTML would be a far easier solution for simple
formating.  You said MS Word ruined the formatting of your HTML file,
but why do your users have to open the document in a word processor if
it isn't going to be edited?  Why not just open to document in a
browser.  It would be far simpler to code IE 3 compatable HTML code
than WordPad x.x version of RTF.




More information about the Python-list mailing list