Converts HTML, XHTML, ASPX file/URL to RTF or Text file. Output file will be overwritten.

Namespace:  SautinSoft
Assembly:  SautinSoft.HtmlToRtf (in SautinSoft.HtmlToRtf.dll) Version: 4.6.10.19

Syntax

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

Parameters

htmlFile
String
Path to local HTML file or URL
outFolder
String
Local path or folder to save output RTF or Text file

Return Value

0 - converting successfully
1 - can't open input file or URL, check the input path
2 - can't create output file, check the output path
3 - converting failed

Remarks



Examples

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

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {

            //Convert HTML file to Word-RTF file
            //If you need more information about HTML-to-RTF Pro DLL .Net email us at:
            //support[at]sautinsoft.com


            SautinSoft.HtmlToRtf objH = new SautinSoft.HtmlToRtf();
            //objH.Serial = "XXXXXXXXXXXXXXX";


            //set some converting options
            //set page size as Letter
            objH.PageStyle.PageSize.Letter();
            //set left margin 20 mm
            objH.PageStyle.PageMarginLeft.mm(20f);

            //convert HTML file to RTF file
            int ret = objH.ConvertFile(@"..\..\..\..\..\..\Testing HTMLs\UTF-8 Sampler.htm", @"..\..\..\..\..\..\Testing HTMLs\Word document.rtf");

            // 0 - converting successfully
            // 1 - can't open input file or URL, check the input path
            // 2 - can't create output file, check the output path
            // 3 - converting failed
            if(ret==0 )
            {
                //Show produced RTF file
                System.Diagnostics.Process.Start(@"..\..\..\..\..\..\Testing HTMLs\Word document.rtf");
            }
        }
    }
}
CopyHow to convert HTML file to RTF file in VB.Net
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        'Convert HTML file to Word-RTF file
        'If you need more information about HTML-to-RTF Pro DLL .Net email us at:
        'support[at]sautinsoft.com



        Dim objH As New SautinSoft.HtmlToRtf
        'objH.Serial = "XXXXXXXXXXXXXXX";



        'set some converting options
        'set page size as Letter
        objH.PageStyle.PageSize.Letter()
        'set left margin 20 mm
        objH.PageStyle.PageMarginLeft.mm(20.0F)

        'convert HTML file to RTF file
        Dim ret As Integer = objH.ConvertFile("..\..\..\..\..\Testing HTMLs\UTF-8 Sampler.htm", "..\..\..\..\..\Testing HTMLs\Word document.rtf")

        ' 0 - converting successfully
        ' 1 - can't open input file or URL, check the input path
        ' 2 - can't create output file, check the output path
        ' 3 - converting failed
        If ret = 0 Then
            'Show produced RTF file
            System.Diagnostics.Process.Start("..\..\..\..\..\Testing HTMLs\Word document.rtf")
        End If
    End Sub
End Module

See Also