Search code examples
.nethtmlrtf

Convert RTF to HTML in .NET


I've managed to do the reverse using WebBrowser and RichTextBox.

But how would I convert RTF to HTML?


Solution

  • Disclaimer: I'm working for this company.

    As I see, the question is old but maybe someone search solution for this too. Our component RTF to HTML allows to convert RTF to HTML. You may download a component or try online-demo. Try the trial version first if you have a doubt. :) Trial is free.

    Here's the code sample for the converting from RTF to HTML in ASP.NET:

        SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
        r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_401;
        r.ImageStyle.IncludeImageInHtml = false; //To save images inside HTML as binary data specify this property to 'true'
    
        r.ImageStyle.ImageFolder = Server.MapPath(""); 
        r.ImageStyle.ImageSubFolder = "images";
        r.ImageStyle.ImageFileName = "picture";       
    
        string rtf = ".....";
        string html = r.ConvertString(rtf);        
    
        //show HTML
        if (html.Length>0)
        {
            Response.Buffer = true;
            Response.Clear();
            Response.ContentType = "text/html";
            Response.Write(html);
            Response.Flush();
            Response.End();
        }