Introduction


Imagine, that in 15 minutes after reading this text you will be able to provide API for your application to convert Text documents into HTML, using C# or VB.NET.

SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
string textFile = @"c:\The Egypt In My Looking Glass.txt";
string htmlFile = @"c:\The Egypt In My Looking Glass.html";

r.OutputFormat = RtfToHtml.eOutputFormat.HTML_5;
r.ConvertFile(textFile, htmlFile);}

This component provides you with a complete set of APIs for converting Text to HTML. In addition, during the conversion to HTML, you can configure the following parameters:

  • Various output formats: HTML 3.2, HTML 4.01, HTML5, XHTML, text.
  • Generating output document in plain HTML 3.2 without CSS.
  • Whether to store images on filesystem or embed them into HTML document using base64 encoding.
  • Save CSS data between tags <style>...</style> or as inline styles: <style="...">.
  • Specify encoding of output HTML.
  • Customize the document title; create only the HTML part between the <body>...</body> tags.
  • Customize the overall font, size, and color for the entire document.
  • Detect hyperlinks in the text and convert them to real ones.
  • Redefining the visibility of table borders.

Download


To see this functionality firsthand, download the freshest «RTF to HTML .Net» with code examples, 49.2 Mb.

Some examples to convert Text to HTML in C# and VB.Net

1. Convert Text file to HTML file in C#:

SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
string textFile = @"d:\The Librarian.txt";
string htmlFile = Path.ChangeExtension(textFile, ".html");

r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5;
if (r.ConvertFile(textFile, htmlFile)==0)
{
    // Open HTML in browser.
    System.Diagnostics.Process.Start(htmlFile);
}

2. Convert Text to HTML in memory using C#.

SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
string textFile = @"d:\The Lynx.txt";
string textString = File.ReadAllText(textFile);

string htmlString = r.ConvertString(textString);

3. Convert Text to HTML in VB.Net; make all CSS styles inline, i.e. put within the attribute <style="...">.

Dim r As New SautinSoft.RtfToHtml()

' Set HTML5 format.
r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.HTML_5
' Set utf-8 encoding.
r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8
' Make all CSS inline.
r.TextStyle.InlineCSS = True

Dim textFile As String = "e:\Returns and Exchanges.txt"
Dim htmlFile As String = Path.ChangeExtension(textFile, ".html")
r.ConvertFile(textFile, htmlFile)

Technical information and requirements


Requires only .NET Framework 4.0 and up or .NET Core 2.0 and up. Our product is compatible with all languages .NET and supports all Operating Systems where .NET Framework and .NET Core can be used.

Note, that «HTML to RTF .Net» is entirely written in managed C#, which makes it absolutely standalone and an independent library.

.NET Framework, .NET Core
  • .NET Framework 4.0, 4.5, 4.6.1 and higher.
  • .NET Standard 2.0
  • .NET Core and .NET 5.0

Multi-platform component, runs on:

  • Windows
  • Linux
  • Mac OS
WindowsLinuxMac OS

Our component has proven itself on cloud platforms and services:

SharePoint Google Cloud AWS Microsoft Azure Docker
  • SharePoint
  • Google Cloud Platform
  • Amazon Web Services (AWS)
  • Microsoft Azure
  • Docker etc.