1
votes

I have a string like "lenovo", passing it to a simple method like this to convert it to RTF:

    RichTextBox rtx = new RichTextBox();
    rtx.Text = sText;
    string s = rtx.Rtf;
    return s;

the result is something like this:

"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}}\r\n\viewkind4\uc1\pard\f0\fs17 lenovo\par\r\n}\r\n"

it has a //par and then two \r\n at the end, this will become an issue later when I am getting this RTF and showing in a report, it will cause a line break :(

What is going wrong? and how can I fix it? Thanks

1

1 Answers

1
votes

Yes, annoying.

Annoying fix:

rtx.SelectAll();
string s = rtx.SelectedRtf;