Convert Word DOC DOCX to HTML MHTML

If you need to embed a Word document into the webpages then Word DOC to HTML conversion is one of the best suitable options. In this article, you will learn the easiest way to convert a Word document to HTML in C#. So let’s have a look at how to perform high-speed and high-quality Word to HTML conversion in a couple of steps. You can use the provided code samples for converting both, DOC and DOCX documents.

How to Convert Word DOC to HTML in C#

To convert a Word document to HTML format, we will first install Aspose.Words for .NET. It is one of the best Word document conversion libraries that provides free Word to HTML conversion. You can download it from New Releases section, or by installing it from NuGet using the command below:

PM> Install-Package Aspose.Words

Convert a Word Document to HTML in C#

The following are the steps to convert a Word document to HTML in C#. The document could either be a DOC or DOCX file.

  1. Load the Word document using Document class.
  2. Initialize an instance of HtmlSaveOptions and set save format.
  3. Save the Word document as HTML using Document.Save() method.

The following code snippet shows how to convert a Word document to HTML in C#.

Save a DOCX to HTML - Round-trip Information

Round-trip information is useful for the scenarios where the converted HTML file is again rendered as a Word document. For such cases, you can enable exporting this information dynamically. Below are the steps to export round-trip information in Word to HTML conversion.

  1. Load the Word document using Document class.
  2. Initialize an instance of HtmlSaveOptions
  3. Set HtmlSaveOptions.ExportRoundtripInformation to true
  4. Convert Word document as HTML using Document.Save() method.

The code snippet below explains how to export round-trip information in Word DOC to HTML conversion in C#.

Export Word DOC to MHTML in C#

MHTML format is worth mentioning when you need a single HTML file with embedded images and fonts. So if you need to convert Word documents to MHTML format, no need to worry. You can do it by following the steps below.

  1. Load the Word document using Document class.
  2. Initialize an instance of HtmlSaveOptions and set SaveFormat to MHTML.
  3. Export Word document as MHTML using Document.Save() method.

The code snippet below shows how to convert a Word DOCX to MHTML in C#.

Free Word to HTML Converter

Get an absolutely free temporary license to convert Word documents to HTML without any evaluation limitations.

C# Word Converter - Read More

You may take a look at API references and Documentation of Aspose.Words for .NET. Moreover, you can write back to us and ask about anything on Free Support Forum.

Conclusion

In this article, we have covered how to convert Word documents to HTML or MHTML files in C#. You can do it without installing the Microsoft Word application. Furthermore, you can use the same C# code to convert DOC to HTML or DOCX to HTML from within your .NET applications.

See Also