explainthat, do you mean to tell me RTF actually supports multi level bulletting? because the one from 'word' that came with windows doesn't.
If it does, then yes i'm willing to take a look at it.
It has been a few months since I had anything to do with outputing RTF so I took a quick look at RTF lists. I think there shouldn't be any problem with outputting multilevel lists. Take a look at the RTF documentation - available on MSDN. The information you want is Pages 21-23.
Briefly, an RTF document is made up of a header section, a document information section and then the actual document. The header section contains lists of fonts, colors, styles etc which are then referenced in the docuement itself.
RTF is a
vast standard. Most word processors offer pretty good support for reading RTF but what they can
write is only a subset of this standard. This applies to Word too. What this means in practice is that just because you cannod do something in Word, either directly or via automation, does not mean that it is not supported.
Just one word of caution - in my experience the number of people using Word 97 is still very significant. There have been some significant changes in the way later versions of the RTF standard so make sure you use the RTF 1.7 spec to ensure maximum compatibility.
There are almost certainly "components" out there that will help you output RTF from Delphi but I am not a great fan of such black box solutions. If you are creating relatively simple documents, here is the approach I suggest
- Create a simple Word document - get as close to the output you actually want
- This is your template. Keep your template really simple since you will be exporting it as RTF. Word RTF is VERY verbose so you need to keep your task simple.
- Now export the template as an RTF document.
- Reformat the document with carriage returns in the RTF markup to make your subsequent steps easier. Each bit of markup is wrapped in braces, {}. You should be able to use any decent text editor to help you with the process of finding matching braces. I use an excellent freebie called PSPad.
- Now start examining the reformatted RTF while refering to the RTF standard and take out all the garbage that Word put in. Typically, you can reduce the file size by a factor of 5 to 10.
- Now focus on the bit you need to customize - in your case lists - and hand code the RTF to get the precise effects you are after.
Once you get this far you can consider how you can best use your template in your Delphi App to automate the process of generating the document you desire - without ever having to do near Word automation. Quite apart from the feeling of better control you will end up with an application that is slimmer and more responsive.
A couple of comments on the code you posted
- Are you aware of the with keyword? You could use it to make your code execute more efficiently. Not to mention the fact that it diminishes time lost through correcting typos.
- You are doing a lot of wdUnDefined assignments. Do you know of FillChar? This could make things faster and cleaner.
- Also, I suppose you realize that Delphi will automatically initialize all record structures and variables declared in your procedures? Initialization is typically to zero, the lowest member of an enumeration etc. So no point doing it all over again yourself.