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.
A trial version of TX Text Control .NET Server for ASP.NET is required for this tutorial.
- Download Trial Version
Setup download and installation required.
Creating the Application
In Visual Studio, create a new Console App.
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.
Switch the Package source to Text Control Offline Packages and install the package TXTextControl.TextControl.ASP.SDK.
Create a new class named TXMarkdown and paste the following code into the class:
Now, you can use this class in your application to convert any Markdown file to an Office Open XML (DOCX) file:
The converted results of the following sample Markdown file can be seen in the screenshot below: