I have an RTF in the database that saves the colors, the enter, among other actions that the user gave. I'm using the following code to convert the RTF to show in HTML, however I'm missing all these formatting, is there any way to fix this?
public static string rtfToTxt(this string txtRtf) {
using(var generalRTF = new System.Windows.Forms.RichTextBox()) {
if(txtRtf.Length > 5 && txtRtf.Substring(0, 5).Equals("{\rtf")) {
try {
generalRTF.Rtf = txtRtf;
return generalRTF.Text;
} catch(ArgumentException) {
return txtRtf;
}
} else {
return txtRtf;
}
}
}
An example would be this RTF:
{\rtf1\ansi\ansicpg1252\deff0\deflang1046{\fonttbl{\f0\fnil\fcharset0 Verdana;}{\f1\fswiss\fcharset0 Arial;}} {\colortbl ;\red255\green0\blue0;} \viewkind4\uc1\pard\f0\fs17 ENTER \par \par \cf1\b\f1\fs22 Letra Colorida\cf0\b0\f0\fs17 \par }
Where I would have an enter and a colored letter and I eventually lose these formatting.