Unplanned
Last Updated: 07 Nov 2018 08:12 by ADMIN
ADMIN
Tanya
Created on: 10 Jan 2017 10:46
Category: RichTextBox
Type: Bug Report
1
RichTextBox: An additional paragraph is added at the end when exporting content to RTF
When exporting with RtfFormatProvider (including when the users copy content), an additional \par tag is added at the end of the document.

Workaround: Process the RTF after it is generated. 

Here is an example how to achieve it when copying:

this.radRichTextBox.CommandExecuted += radRichTextBox_CommandExecuted;
...
void radRichTextBox_CommandExecuted(object sender, CommandExecutedEventArgs e)
{
    if (e.Command is CopyCommand)
    {
        DocumentPosition end = this.radRichTextBox.Document.Selection.Ranges.Last.EndPosition;
             
        RadDocument clipboardDocument = ClipboardEx.GetDocument().ToDocument();
        RtfFormatProvider provider = new RtfFormatProvider();
        string rtfString = provider.Export(clipboardDocument);
        int indexLastParOpening = rtfString.LastIndexOf("{");
        int indexLastParClosing = rtfString.IndexOf('}', indexLastParOpening);
        string newRtf = rtfString.Remove(indexLastParOpening, indexLastParClosing - indexLastParOpening + 1);
        Clipboard.SetData("Rich Text Format", newRtf);
    }
}
0 comments