Converts Text/RTF file to Text/HTML/XHTML file. Output file will be overwritten.

Namespace:  SautinSoft
Assembly:  SautinSoft.RtfToHtml (in SautinSoft.RtfToHtml.dll) Version: 3.3.8.15

Syntax

      
 C#  Visual Basic 
public int ConvertFile(
	string inputFileName,
	string outputFileName
)
Public Function ConvertFile ( _
	inputFileName As String, _
	outputFileName As String _
) As Integer

Parameters

inputFileName
String
Path to Text/RTF file, not URL
outputFileName
String
Path to output file

Return Value

0 - converting succesfully
1 - can't open input Text/RTF file, check the input path
2 - can't create output file, check the output path
3 - converting failed

Examples

CopyHow to convert RTF file into HTML file in C#
using System;
using System.IO;
using System.Text;

namespace SampleConvert
{
    class sample
    {
        static void Main(string[] args)
        {
            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();
            //this property is necessary only for registered version
            //r.Serial = "XXXXXXXXXXXXX";

            //specify some options
            r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10;
            r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8;

            //specify image options
            r.ImageStyle.ImageFolder = @"c:\";      //this folder must exist
            r.ImageStyle.ImageSubFolder = "webs";   //this folder will be created by the component
            r.ImageStyle.ImageFileName = "picture"; //template name for images
            r.ImageStyle.IncludeImageInHtml = false;//false - save images on HDD, true - save images inside HTML


            string rtfFile = @"..\..\..\..\..\test.rtf";
            string htmlFile = @"..\..\..\..\..\test.html";

            int i = r.ConvertFile(rtfFile,htmlFile);
            if (i==0)
            {
                System.Console.WriteLine("Converted successfully!");
                System.Diagnostics.Process.Start(htmlFile);
            }
            else
                System.Console.WriteLine("Converting Error!");
        }
    }
}
CopyHow to convert RTF file into HTML file in VB.Net
Imports System
Imports System.IO
Imports System.Text

Module sample

    Sub Main()

        Dim r As New SautinSoft.RtfToHtml()
        'this property is necessary only for registered version
        'r.Serial = "XXXXXXXXXXXXX";


        'specify some options
        r.OutputFormat = SautinSoft.RtfToHtml.eOutputFormat.XHTML_10
        r.Encoding = SautinSoft.RtfToHtml.eEncoding.UTF_8

        'specify image options
        r.ImageStyle.ImageFolder = "c:\"        'this folder must exist
        r.ImageStyle.ImageSubFolder = "webs"    'this folder will be created by the component
        r.ImageStyle.ImageFileName = "picture"  'template name for images
        r.ImageStyle.IncludeImageInHtml = False 'False - save images on HDD, True - save images inside HTML


        Dim rtfFile As String = "..\..\..\..\test.rtf"
        Dim htmlFile As String = "..\..\..\..\test.html"

        Dim i As Integer = r.ConvertFile(rtfFile, htmlFile)
        If i = 0 Then
            System.Console.WriteLine("Converted successfully!")
            System.Diagnostics.Process.Start(htmlFile)
        Else
            System.Console.WriteLine("Converting Error!")
        End If
    End Sub
End Module

See Also