Markdown is a popular, lightweight markup language to create formatted text in a simple way. Specifically for developers, it became a standard to describe projects such as in Readme files in GitHub repositories and other resources.

This article shows how convert Markdown files to Office Open XML and PDF documents using TX Text Control and Markdig - a powerful and extensible Markdown processor for .NET.

Use the following steps to create a console application to convert Markdown to Office Open XML and PDF documents.

Prerequisites

A trial version of TX Text Control .NET Server for ASP.NET is required for this tutorial.

Creating the Application

  1. In Visual Studio, create a new Console App.
    Markdown to DOCX

  2. In the Solution Explorer, select the created project and choose Manage NuGet Packages... from the Project main menu. Set the Package source to nuget.org and search for Markdig. Select the package Markdig and click Install.
    Markdown to DOCX

  3. Switch the Package source to Text Control Offline Packages and install the package TXTextControl.TextControl.ASP.SDK.
    Markdown to DOCX

  4. Create a new class named TXMarkdown and paste the following code into the class:

    Loading...
  5. Now, you can use this class in your application to convert any Markdown file to an Office Open XML (DOCX) file:

    Loading...

The converted results of the following sample Markdown file can be seen in the screenshot below:

Loading...
Markdown to DOCX