Opens a DOCX document from an array of bytes. Works under .Net 4.0 or higher.

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


 C#  Visual Basic 
public void OpenDocx(
	byte[] bytes
Public Sub OpenDocx ( _
	bytes As Byte() _


array< Byte >[]()[]
DOCX documents as array of bytes.


This method works paired with ToHtml() 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