How do I convert HTML to RTF (Rich Text) in .NET without paying for a component?
Check out this CodeProject article on XHTML2RTF.
Expanding on Spartaco's answer I implimented the following which works GREAT!
Using reportWebBrowser As New WebBrowser
reportWebBrowser.CreateControl()
reportWebBrowser.DocumentText = sbHTMLDoc.ToString
While reportWebBrowser.DocumentText <> sbHTMLDoc.ToString
Application.DoEvents()
End While
reportWebBrowser.Document.ExecCommand("SelectAll", False, Nothing)
reportWebBrowser.Document.ExecCommand("Copy", False, Nothing)
Using reportRichTextBox As New RichTextBox
reportRichTextBox.Paste()
reportRichTextBox.SaveFile(DocumentFileName)
End Using
End Using
Actually there is a simple and free solution: use your browser, ok this is the trick I used:
var webBrowser = new WebBrowser();
webBrowser.CreateControl(); // only if needed
webBrowser.DocumentText = *yourhtmlstring*;
while (_webBrowser.DocumentText != *yourhtmlstring*)
Application.DoEvents();
webBrowser.Document.ExecCommand("SelectAll", false, null);
webBrowser.Document.ExecCommand("Copy", false, null);
*yourRichTextControl*.Paste();
This could be slower than other methods but at least it's free and works!