Convert Word from/to HTML with Embedded Image

Convert Word document to HTML is popular and widely used by programmers and developers. With the help of Spire.Doc for .NET, a professional word component, without installing MS Word, developers can convert word to html with only two lines of key code in C#. At the same time, Spire.Doc supports convert HTML to word document easily and quickly.

This article still focuses on convert word from/to HTML, while it mainly about the supports of embed image in the word document and HTML. With the improvements of Spire.Doc (starts from Spire.Doc V. 4.9.32), now it supports the new function of ImageEmbedded.

Please download Spire.Doc (version 4.9.32 or above) with .NET framework together and follow the simple steps as below:

Convert Word to HTML in C#:

Step 1: Create the word document.

[C#]
Document document = new Document();

Step 2: Set the value of imageEmbedded attribute.

[C#]
doc.HtmlExportOptions.ImageEmbedded=true;

Step 3: Save word document to HTML.

[C#]
doc.SaveToFile("result.html",FileFormat.Html);

Spire.Doc also supports load the result HTML page and convert it into word document in only three lines of codes as below.

[C#]
doc.SaveToFile("htmltoword.docx",FileFormat.Docx);

Besides conversion of word from/to HTML, Spire.Doc also supports Convert Word to PDF, Convert Word to Image and Convert Word to XPS in C#.