Format Conversion is always the hot issue. As is known, there are specified tools used to open different kind of document. For example, Word document is opened with Microsoft Word, while PDF document is opened with PDF viewer. So sometimes, people may choose to convert document format to make sure that the document can be opened with tools which has been installed on system. In this post, I will share a method about how to convert RTF to HTML with C#/VB.NET.
When talking about RTF, we can remind of Word. Although RTF is similar to Word, it uses plain text to describe contents and can be opened by many tools, for example, Microsoft Word, Notepad etc.
In my example, I prepare a RTF document and set format for the contents. And, I use a .NET Word component, Spire.Doc for .NET to realize the conversion more quickly and easily. So, I have added its dll file as reference in project.
The following screenshot presents parts of contents of my RTF document.
Just with two steps, we can convert RTF file to HTML.
- Declare a document and load it by using document.LoadFromFile(filename, fileformat) method. Please note that the file forma must be chosen as Rtf.
- Use document.SaveToFile(filename, fileformat) method to convert. In this method, file format must be selected as HTML.
Use the Code:
static void Main(string args)
Document document = new Document();
//Convert to HTML
Friend Class Program
Shared Sub Main(ByVal args() As String)
Dim document As New Document()
‘Convert to HTML
Freely Download Spire.Doc for .NET