Creates HTML document as string.

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


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

Return Value

HTML document as string.


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


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;
                htmlString = r.ToHtml();

            if (htmlString != null)
                File.WriteAllText(htmlFile, htmlString);
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
                htmlString = r.ToHtml()
            End Using

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

See Also