Creates HTML document as string.

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

Syntax

      
 C#  Visual Basic 
public string ToHtml()
Public Function ToHtml As String

Return Value

HTML document as string.

Remarks

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

Examples

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

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


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

            using (MemoryStream docxStream = new MemoryStream(File.ReadAllBytes(docxFile)))
            {
                r.ImageStyle.IncludeImageInHtml = true;
                r.OpenDocx(docxStream);
                htmlString = r.ToHtml();
            }

            if (htmlString != null)
            {
                File.WriteAllText(htmlFile, htmlString);
                System.Diagnostics.Process.Start(htmlFile);
            }
        }
    }
}
CopyHow to convert DOCX to HTML in memory 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