I must be doing something really stupid or I’m totally blind today but I am having trouble appending to an RTF file.
Essentially, I have an offscreen textarea that I am sending data to and giving it style information before writing it to an RTF file. The problem I have is that only the first set of data gets written to the file. Here’s the code (‘file’ is the folderitem that has already been successfully created):
After running this, looking at the resulting file shows only the first line. If I comment out the first section, after the creation of the TextOutputStream, the second part gets sent to the file correctly so I know the text is being sent to the offscreen textarea. If I look at it in the debugger, I do see the correct text in the textarea at the right time.
Is there some reason I can only write to the RTF file once? Am I missing something?
{\\rtf1\\ansi\\ansicpg1252{\\fonttbl{\\f0\\fnil Calibri;}}{\\colortbl\\red0\\green0\\blue0;}\\uc0 \\ql\\ul\\f0\\fs72 The title}
{\\rtf1\\ansi\\ansicpg1252{\\fonttbl{\\f0\\fnil Calibri;}}{\\colortbl\\red0\\green0\\blue0;}\\uc0 \\ql\\ul\\f0\\fs72 The information}
If you look at it, it contains twice the header {\\rtf1 and immediately after the text a closing brace } which means end of document. So in practice the RTF contains two documents, and as a result you see only one, because the interpreter encountered the closing brace and stopped loading data.
The proper way is to concatenate in taOffScreen, then write the RTFData from that :
[code] taOffScreen.Text = “The title”+EndOfLine+“The Information” // Or use .AppendText
TextArea2.AppendText(taOffScreen.StyledText.RTFData)