.NET Word Examples
- Create Word Document
- Perform Mail Merge
- Manage Bookmarks
- Find and Replace Text
- Format Tables
- Split Word Documents
- Merge Multiple Word Documents
- Fill and Manage Form Fields
- Generate and Update Table of Contents
- Compare Word Documents
- Encrypt and Decrypt Documents with Password
- Convert Word Documents to PDF
- Convert Word Documents to Images
- Word-HTML Conversions
- Word-Markdown Conversions
- Word-Text Conversions
HTML Conversions Using the Syncfusion .NET Word Library
HTML, the standard markup language that shapes the structure of webpages, serves as the foundation for online content. Now with the use of the Syncfusion® .NET Word Library you can seamlessly convert HTML to Word documents and Word documents to HTML in C#. Simplify your HTML conversion tasks without installing Microsoft Office on your machine.
Watch this video to earn how to convert Word files to HTML and HTML files to Word using the Syncfusion .NET Word Library.
Perform HTML conversions using C#
Learn how to convert HTML to Word documents and Word documents to HTML programmatically using C# with the Syncfusion .NET Word Library. This guide demonstrates bidirectional conversion between Word and HTML formats.
Step 1: Create a new project
Start by creating a new C# Console Application project.
Step 2: Install the NuGet package
Add the Syncfusion.DocIO.Net.Core package to your project from NuGet.org.
Step 3: Add required namespaces to perform HTML conversion
Add the following namespaces to your Program.cs file:
using Syncfusion.DocIO;
using Syncfusion.DocIO.DLS;
using System.IO;Step 4: Open a Word document
Open an existing Word document from a file stream.
FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
WordDocument document = new WordDocument(fileStreamPath, FormatType.Docx);Step 5: Save as HTML file
Convert and save the Word document as an HTML file.
//Create file stream
FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.html"), FileMode.Create, FileAccess.ReadWrite);
//Save the Word document to file stream
document.Save(outputFileStream, FormatType.Html);
document.Close();
fileStreamPath.Close();
outputFileStream.Close();Step 6: Open an HTML file
Open an existing HTML file and load it as a Word document.
FileStream fileStreamPath = new FileStream(Path.GetFullPath(@"Data/Input.html"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
WordDocument document = new WordDocument(fileStreamPath, FormatType.Html);Step 7: Save the Word document
Convert and save the HTML content as a Word document.
//Create file stream
FileStream outputFileStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite);
//Save the Word document to file stream
document.Save(outputFileStream, FormatType.Docx);
document.Close();
fileStreamPath.Close();
outputFileStream.Close();GitHub project
NuGet installation
Get started quickly by downloading the installer and checking license information on the Downloads page.
Table of contents
Explore these resources for comprehensive guides, knowledge base articles, insightful blogs, and ebooks.
Learning
Technical Support
