How to write RTF from Python?
Howard Lightstone
howard at eegsoftware.com
Sat Apr 26 11:59:00 EDT 2003
achrist at easystreet.com wrote in news:3EAA13D3.F7B4B9A6 at easystreet.com:
> kkennedy wrote:
>>
>> 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).
>>
>
> That's one reason why I asked if there were any solutions already
> available. If someone had already identified the forms of rtf
> markup that worked well in all those versions, I would not want
> to rediscover the same set of tires.
[snip]
About 8 years ago I did sort of the opposite. We wanted a way to keep
documentation, specifications, and code aligned so I dreamed up a method of
using Word as a (semi-)literate editor with different (defined by me)
styles for each kind of thing. Of course, then I had to write code to
extract out the various headers, code segments, build instructions , etc.
which had to feed to the many existing compilers, linkers, and such. I
made them keep the code in RTF so I could *just* write an ASCII parser for
it.
Right.
Every version of Word and many different combinations of operating systems
kept me constantly updating the parser. The RTF "rules" (all three
versions I downloaded from Microsoft) do NOT contain all the different
possibilities that Word expects/generates nor do they explain just how you
need to order various pieces. We resolved most of our issues by smacking
the knuckles of anyone who tried a "new" way of formatting and by making
them responsible for proper code extraction (although they did a lot of
whining at me).
If you have simple boilerplate requirements, try making a simple file with
one example of each formatting kind and then dumping the RTF. You will
then see..... (I used a package for parsing RTF which I HIGHLY recommend
http://www.dubois.ws/software/RTF
that happens to have the RTF spec with it).
More information about the Python-list
mailing list