What is the best solution for converting RichTextFormat information to HTML in C #?

What is the best solution for converting RichTextFormat information to HTML in C #?

I know that there are libraries that do this, and I was curious to find out if you guys have any advice on which ones are better.

Thanks Jeff

+6
html c # rtf
source share
3 answers

I recently used RTF for HTML conRTverter, which worked fine under the name DocFrac.

It can be used with a graphical interface to convert files, but it is also a DLL.

I have converted over 400 RTF files to HTML in a few minutes, so the performance is good too. I used a graphical interface, so I have no information about the DLL. According to the site, the DLL works with .NET.

DocFrac at SourceForge

Update: fixed link because www.docfrac.net no longer exists.

+2
source share

Try using this RTF library for HTML.Net. It supports RTF for HTML and text to HTML conversion. The full version is not free, but there is a free trial.

This code may be useful:

SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml(); //specify some options r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10; r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8; string rtfFile = @"d:\test.rtf"; string htmlFile = @"d:\test.html"; string rtfString = null; ReadFromFile(rtfFile,ref rtfString); int i = r.ConvertStringToFile(rtfString,htmlFile); if (i == 0) { System.Console.WriteLine("Converted successfully!"); System.Diagnostics.Process.Start(htmlFile); } else System.Console.WriteLine("Converting Error!"); } public static int ReadFromFile(string fileName,ref string fileStr) { try { FileInfo fi = new FileInfo(fileName); StreamReader strmRead = fi.OpenText(); fileStr = strmRead.ReadToEnd(); strmRead.Close(); return 0; } catch { //error open file System.Console.WriteLine("Error in open file"); return 1; } } 
+1
source share

ScroogeXHTML, a small library for converting RTF to HTML / XHTML, may be useful. However, it only supports a subset of the RTF standard. There are other libraries for reports with tables and other advanced layouts, such as Logictran R2Net Converter.

0
source share

All Articles