Tuesday, January 17, 2006

RTF to HTML using C#

I have searched for a code snippet or an (.net) open source utility to convert an RTF string into an HTML string

Many stuff are there, but all has some limitations to what I need exactly.

Here is some of the search result

ExRichtextBox with lite HTML
http://www.codeproject.com/cs/miscctrl/htmlrichtextbox.asp

Use IRichEditOle from C#
http://www.codeproject.com/cs/miscctrl/richtextboxplus.asp

Insert Plain Text and Images into RichTextBox at Runtime
http://www.codeproject.com/cs/miscctrl/csexrichtextbox.asp

AutoFormatter
http://blogs.vbcity.com/hotdog/archive/2004/09/11/280.aspx?Pending=true

The HtmlEditor - a C# control that wraps MSHTML
http://www.itwriting.com/htmleditor/index.php

MSWord Automation Converting RTF to TXT format
http://www.codeproject.com/csharp/rtftotxtconvertor.asp#xx1196725xx

Copy as Html (VS Add-in)
http://www.jtleigh.com/people/colin/software/CopySourceAsHtml/

VB.net function to convert rtf to html
http://www.developer.com/net/vb/article.php/10926_1576561_3

5 comments:

Anonymous said...

Hi,

I Find a good site whit e-books free: www.ebook-here.com

SautinSoft said...

To solve this task try a C# component which names RTF-to-HTML DLL .Net to convert RTF to HTML.

Anonymous said...

This converts Html to RTF

(blogger won't let me post html so pretend DocumentText has html tags)

webBrowser1.DocumentText = " h1 p some HTML text /p /h1 p something else /p ";
webBrowser1.Document.ExecCommand("SelectAll", false, null);
webBrowser1.Document.ExecCommand("Copy", false, null);

richTextBox1.Clear();
richTextBox1.Paste();

MessageBox.Show(richTextBox1.Rtf);


Only problem is that WebBrowser actually takes some time to render, and the richTextBox tries to paste before it's finished. I am not sure how to programmatically wait for WebBrowser to finish rendering. (I know this, because I tied the pasting code to a button and clicked it, and it worked, but when I just execute it immediately after changing content of the webBrowser, it pastes what was previously contained in the webBrowser)

Anonymous said...

This component exports HTML to RTF:

http://www.sautinsoft.com/components/htmltortf_pro_net.zip


SautinSoft.HtmlToRtf h - new SautinSoft.HtmlToRtf();
string rtf = h.ConvertString("Any String in HTML format!");

Anonymous said...

RtfFormatProvider C# class import and export content of KetticRichTextBox to/from RTF documents.