Convert contents of Rich Text box control to html

mcostello

Member
Joined
Dec 12, 2005
Messages
6
Programming Experience
5-10
Is there a simple way to convert formatted text in a rich text Box control to HTML in a winforms app?
 
A RichTextBox contains RTF code. It is a completely different format to HTML. Have a look at the controls Rtf property to see what it contains. To the best of my knowledge there is no in-built functionality in the Framework to convert from one to the other. You'll need to either parse the RTF text yourself and write out the equivalent HTML or find a third-party tool that will do it for you.
 
The simplest way (using a third party) is to save the RTF file, use MS Office automation to load it into Word, then make Word save as html.
 
Thanks guys,
I need the process to be seamless so saving out to a file and using word is not an option. Does anyone know of a good 3rd party app that can do the conversion?

Mark
 
If you mean by seamless that user will never know, you're right because it will be a requirement that also Word is installed, but running the automation itself will not be visible to user.

Moving on, I found this small function that does the job integrated and free, at least the basics of rich text to html, pretty neat: More Windows Secrets for Visual Basic - Developer.com

Searching the web you will find loads of "rtf to html" providers both pay and free.
 
Back
Top