Syncfusion Feedback


Trusted by the world’s leading companies

Overview

The .NET Word Library allows you to convert Word documents to Markdown and Markdown to Word documents in C# with just a few lines of code, without installing Microsoft Word on your machine.


How to convert a Word document to a Markdown file in C#

  1. Install NuGet package: Install the Syncfusion.DocIO.Net.Core NuGet package in your project.
  2. Open Word document: Create a FileStream object to represent the input Word document.
  3. Load in .NET Word Library: Create a WordDocument object by passing the FileStream object.
  4. Convert Word to Markdown: Save the WordDocument object to the FileStream object in Markdown format.

Here is an example of how to convert a Word document to a Markdown file in C# by using the Syncfusion® .NET Word Library.

//Load an existing Word document.
using FileStream inputStream = new FileStream("Template.docx", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(inputStream, FormatType.Docx);

//Save the Word document as a Markdown file.
using FileStream outputStream = new FileStream("Sample.md", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Markdown);

How to convert a Markdown file to a Word document in C#

  1. Install NuGet package: Install the Syncfusion.DocIO.Net.Core NuGet package in your project.
  2. Open Markdown file: Create a FileStream object to represent the input Markdown file.
  3. Load in .NET Word library: Create a WordDocument object by passing the FileStream object.
  4. Convert Markdown to Word: Save the WordDocument object to the FileStream object in DOCX format.

Here is an example of how to convert a Markdown file to a Word document in C# using the Syncfusion .NET Word Library (DocIO).

//Load an existing Markdown file.
using FileStream fileStreamPath = new FileStream("Template.md", FileMode.Open, FileAccess.Read);
using WordDocument document = new WordDocument(fileStreamPath, FormatType.Txt);

//Save as a Word document.
using FileStream outputStream = new FileStream("Sample.docx", FileMode.Create, FileAccess.Write);
document.Save(outputStream, FormatType.Docx);

Customize Markdown conversion

Word to Markdown

Utilize the event handler to customize image saving during Word-to-Markdown conversion. Use the handler to save images locally or upload them to cloud storage, and use the generated path as the image source in the final Markdown.

Markdown to Word

Simply define your custom logic and handle the event to replace image sources with the content from local storage, online websites, or cloud storage.




Awards

Greatness—it’s one thing to say you have it, but it means more when others recognize it. Syncfusion® is proud to hold the following industry awards.

Scroll up icon