Convert RTF to HTML in .NET

后端 未结 4 849
陌清茗
陌清茗 2021-01-19 18:47

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

But how would I convert RTF to HTML?

4条回答
  •  生来不讨喜
    2021-01-19 19:37

    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();
        }
    

提交回复
热议问题