Creates HTML file.

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

Syntax

      
 C#  Visual Basic 
public bool ToHtml(
	string fileName
)
Public Function ToHtml ( _
	fileName As String _
) As Boolean

Parameters

fileName
String
Path to store HTML file.

Return Value

true - in case of successful conversion.

false - in case of failed conversion.

Remarks

This method works paired with OpenRtf() and OpenDocx() methods.

Examples

CopyHow to convert DOCX file to HTML file using C#
using System;
using System.IO;
using System.Text;

namespace SampleConvert
{
    class sample
    {
        static void Main(string[] args)
        {
            // Convert DOCX file to HTML file
            SautinSoft.RtfToHtml r = new SautinSoft.RtfToHtml();

            string docxFile = Path.GetFullPath(@"..\..\..\..\..\test.docx");
            string htmlFile = Path.ChangeExtension(docxFile, ".html");

            try
            {
                r.OpenDocx(docxFile);
                r.ToHtml(htmlFile);
                System.Diagnostics.Process.Start(htmlFile);
            }
            catch (Exception e)
            {
                Console.WriteLine("An error occured: {0}", e.Message);
                Console.ReadLine();
            }

        }
    }
}
CopyHow to convert DOCX file to HTML file using VB.Net
Imports System.IO
Imports System.Text

Namespace SampleConvert
    Friend Class sample
        Shared Sub Main(ByVal args() As String)
            ' Convert DOCX to HTML in memory
            Dim r As New SautinSoft.RtfToHtml()


            Dim docxFile As String = Path.GetFullPath("..\..\..\..\..\test.docx")
            Dim htmlFile As String = Path.ChangeExtension(docxFile, ".html")
            Dim htmlString As String = Nothing

            Using docxStream As New MemoryStream(File.ReadAllBytes(docxFile))
                r.ImageStyle.IncludeImageInHtml = True
                r.OpenDocx(docxStream)
                htmlString = r.ToHtml()
            End Using

            If htmlString IsNot Nothing Then
                File.WriteAllText(htmlFile, htmlString)
                System.Diagnostics.Process.Start(htmlFile)
            End If
        End Sub
    End Class
End Namespace

See Also