I\'ve managed to do the reverse using WebBrowser
and RichTextBox
.
But how would I convert RTF to HTML?
If you pop-up NuGet and search for "RTF", the most popular result right now looks like RtfPipe
; you can install it right there, or via the package manager console via:
Install-Package RtfPipe
Then in your C#, you can convert RTF to HTML super easily:
var html = RtfPipe.Rtf.ToHtml(rtf);
According to the readme.md on their GitHub page:
This library attempts to support the core RTF features documented in the RTF Specification 1.9.1. These features include:
- Character formatting (bold, italics, color, ...)
- Tables (including nested tables)
- Lists
- Hyperlinks
- Pictures
- Heading levels
- HTML encapsulation (e.g. as performed by Outlook)
With that said, there are numerous cases for non-trivial documents where the library will not produce the "correct" visual representation when compared to other RTF readers (such as MS Word).
I piped my RTF into it, and it worked amazingly. YYMV.