How To Convert RTF To HTML In ASP.NET

Learn how to convert a rtf file to html file using SautinSoft.RtfToHtml.dll DLL in C# and ASP.NET.

Step 1: Download SautinSoft.RtfToHtml.dll DLL from given link
 
http://downloads.zdnet.com/product/2066-10708032/
 
Step 2: Add reference to SautinSoft.RtfToHtml.dl to your project.
 
Step 3: Add namespaces
 
using SautinSoft;
using System.IO;
 
Step 4: Write below code on a button click event handler.
  1. protected void Button1_Click(object sender, EventArgs e)  
  2. {  
  3. SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();  
  4. r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_401;  
  5. r.ImageStyle.IncludeImageInHtml = false//To save images inside HTML as binary data specify this property to 'true'  
  6. r.ImageStyle.ImageFolder = Server.MapPath("");  
  7. r.ImageStyle.ImageSubFolder = "images";  
  8. r.ImageStyle.ImageFileName = "picture";  
  9. string rtf = File.ReadAllText(@"C:\Documents\633868836830039716_d50a2ee6-4dad-4911-aaa8-692b24ed8734.rtf");  
  10. string html = r.ConvertString(rtf);  
  11. //show HTML  
  12. if (html.Length > 0)  
  13. {  
  14. File.WriteAllText(@"C:\myfile.html", html);  
  15. }  
  16. }