user3114347
user3114347

Reputation: 369

Converting RTF format to HTML tags

Maybe someone can help me with the following problem. I have a rich textbox control: RichTxtDescription. I fill the text like:

String _description = “Some text with rft tags like \\ine , \b,  \b01 etc.”;
 RichTxtDescription.Rft = @"{\rtf1\ansi " + _Description + "\\line \\line Query: \\line .}";

In my winform application, the richtextbox control gets filled as it should be(text with new lines, bolds etc). Now, I want to convert the richTxtDescription.Rft to html tags, to show it on a rtf field what only accepts html tags.

Any suggestions?

Thanks!

Upvotes: 3

Views: 7231

Answers (1)

Vijay Gill
Vijay Gill

Reputation: 1518

I used this RTF Converter yesterday :) and I am very happy about it.

  • Download that project
  • Compile the solution "RtfWinForms2010.sln".
  • In the bin folder (same level as the solution), you will find the DLL's that you can use. Their names start with "Itenso". The one you might be interested in will be "Itenso.Rtf.Converter.Html.dll" and the ones that this DLL depends on.
  • Add reference to your project and use the following snippet as starting point.

    IRtfDocument rtfDocument = RtfInterpreterTool.BuildDoc( yourRtfVariable );

    RtfHtmlConverter htmlConverter = new RtfHtmlConverter(rtfDocument);

    string html = htmlConverter.Convert();

Upvotes: 9

Related Questions