CuteEditor for .NET

RTF to HTML, HTML to RTF

RTF to HTML, HTML to RTF

You can use Cute Editor to convert an HTML document into an RTF file and RTF file/string into HTML or XHTML document

1. RTF to HTML

In order to convert RTF to HTML, you would use LoadRTF Method: 

LoadRTF Method
Loads the contents of an RTF into the CuteEditor control

// Load RTF string

string t = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}} {\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 Hello\par } "; 

Editor1.LoadRTF(t);
// Load RTF file
Editor1.LoadRTF("document.rtf");

2. HTML to RTF

In order to convert HTML to RTF, you would use SaveRTF Method:

SaveRTF Method
Saves the contents of the Cute Editor to a RTF file.  The SaveRTF method enables you to save the entire contents of the control to a RTF file. If the file name that is passed to the path parameter already exists at the specified directory, the file will be overwritten without notice. You can use the LoadFile, LoadWord, LoadRTF, LoadText method to load the contents of a file into the CuteEditor

// Saves the contents of the Cute Editor to a RTF file

Editor1.SaveRTF("document.rtf");

3. Convert HTML to RTF directly

//Convert HTML to RTF directly

string t="<b>Hello world</b>"; 
CuteEditor.Convertor.RTF.HTML2RTF html2rtf = new CuteEditor.Convertor.RTF.HTML2RTF(t);
textbox1.Text = html2rtf.RTF; // Get the RTF string using the RTF property