Word to HTML C#

In various cases, you need to display the content of the Word files in your web or desktop applications. One of the suitable options in such cases is the conversion of Word to HTML. To achieve this from within the .NET applications, this article covers how to convert Word files to HTML in C#. Moreover, you will learn how to control Word to HTML conversion dynamically using different options.

C# Word to HTML Converter API - Free Download

To perform Word to HTML conversion from within the .NET applications, we will use Aspose.Words for .NET. It is a powerful class library that lets you create and manipulate Word documents. Also, it allows you to convert Word documents to various other file formats. You can either download the API or install it using NuGet.

PM> Install-Package Aspose.Words 

Convert Word to HTML in C#

Aspose.Words for .NET makes it quite easier for you to convert a Word document to HTML. Simply load the Word document and save it as an HTML file. The following are the steps to convert a Word file to HTML in C#.

The following code sample shows how to convert a Word to HTML using C#.

C# Customize Word to HTML Conversion

Aspose.Words for .NET also allows you to customize the Word to HTML conversion using different options. For example, you can specify a folder to keep the resource files (CSS, fonts, and image) separately. In addition, you can export round-trip information of the document. The following sections demonstrate how to use these options.

C# Word to HTML - Export Round-trip Information

MS Word provides a wide range of features and not all of these are supported by HTML. Therefore, to make the content of HTML close to the original document, round-trip information is used. The following steps show how to export round-trip information in Word to HTML conversion in C#.

The following code sample shows how to export round-trip information in Word to HTML conversion in C# .NET.

C# Word to HTML Conversion - Specify Resource Folder

While performing Word to HTML conversion, you can save the resource files in a separate folder. Also, you can specify folders to keep fonts and images separately. The following are the steps to achieve this.

The following code sample shows how to keep resources in a separate folder in C# Word to HTML conversion.

Read more about working with resource folders in Word to HTML conversion.

C# API for Word to HTML Conversion - Get a Free License

You can get a temporary license in order to use Aspose.Words for .NET without evaluation limitations.

Conclusion

In this article, you have learned how to convert Word files to HTML in C#. Furthermore, you have seen how to use different options to customize Word to HTML conversion. You can also explore other features of Aspose.Words for .NET using the documentation. In addition, you can post your queries on our forum.

See Also