Appending RTF
Posted: Wed Jan 04, 2006 7:03 am
Hello Sergey,
i am still trying to find the best method for creating some complex documents that my app requires and i thought of using rtf.
The fact is that the document is actually a concatenation of many small paragraphs. Each paragraph has some XML tags that denote formatting (for example html tags, etc).
Since the methods so far (use the AddNL and ApplyStyleConversion, i described in previous post) seem complicated, i thought that i could use the LoadRTFFromStream.
This method seems to work also (and might be simpler for my case). What i want to ask is this: can i use an RTF fragment or should i use a complete RTF document?
For example:
it tried adding (with a Memory stream) the following: " This is a {\b bold } word". Unfortunately no bold appeared, although the plain text was there. The minimum code i needed to see the bold was this:
"{\rtf1{\fonttbl{\f0}}This is a \b bold \b0 word}".
Now, i suppose that if i need to also add colors and more fonts, i will need to create a colortbl and proper fonttbl.
My questions are these:
1. Why the first RTF fragment didn't work?
2. Do i need to always supply the rtf headers? For example, say that cf2 is blue. Do i need to have a colortbl for each fragment? Wouldn't be easier to say "{\cf2 This is blue}" and define once (for all fragments) that cf2 is for blue?. Is there a way to do this?
3. Since i suppose that adding always the RTF headers will have a deep impact on parsing time, is there a better solution than this?
4. Should i try to use RVF instead? Will it be faster? Is it easy to convert from RTF to RVF (string conversion)?
5. A last question: when using the LoadRTFFromStream method, a new paragraph is created for each fragment i insert: how can i avoid this? If not, how i could join the lines (even after formatting)?
Thanks for your help,
Costas
i am still trying to find the best method for creating some complex documents that my app requires and i thought of using rtf.
The fact is that the document is actually a concatenation of many small paragraphs. Each paragraph has some XML tags that denote formatting (for example html tags, etc).
Since the methods so far (use the AddNL and ApplyStyleConversion, i described in previous post) seem complicated, i thought that i could use the LoadRTFFromStream.
This method seems to work also (and might be simpler for my case). What i want to ask is this: can i use an RTF fragment or should i use a complete RTF document?
For example:
it tried adding (with a Memory stream) the following: " This is a {\b bold } word". Unfortunately no bold appeared, although the plain text was there. The minimum code i needed to see the bold was this:
"{\rtf1{\fonttbl{\f0}}This is a \b bold \b0 word}".
Now, i suppose that if i need to also add colors and more fonts, i will need to create a colortbl and proper fonttbl.
My questions are these:
1. Why the first RTF fragment didn't work?
2. Do i need to always supply the rtf headers? For example, say that cf2 is blue. Do i need to have a colortbl for each fragment? Wouldn't be easier to say "{\cf2 This is blue}" and define once (for all fragments) that cf2 is for blue?. Is there a way to do this?
3. Since i suppose that adding always the RTF headers will have a deep impact on parsing time, is there a better solution than this?
4. Should i try to use RVF instead? Will it be faster? Is it easy to convert from RTF to RVF (string conversion)?
5. A last question: when using the LoadRTFFromStream method, a new paragraph is created for each fragment i insert: how can i avoid this? If not, how i could join the lines (even after formatting)?
Thanks for your help,
Costas