MarkdownToDocxGenerator 1.2.0

dotnet add package MarkdownToDocxGenerator --version 1.2.0
                    
NuGet\Install-Package MarkdownToDocxGenerator -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MarkdownToDocxGenerator" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkdownToDocxGenerator" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="MarkdownToDocxGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MarkdownToDocxGenerator --version 1.2.0
                    
#r "nuget: MarkdownToDocxGenerator, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MarkdownToDocxGenerator@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MarkdownToDocxGenerator&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=MarkdownToDocxGenerator&version=1.2.0
                    
Install as a Cake Tool

MarkdownToDocxGenerator

Generate professional DOCX (Word) documents from a folder of Markdown files with .NET. Easily integrate into your .NET applications, use custom templates, and automate documentation workflows.


Features

  • Convert Markdown to DOCX: Transform a folder of .md files into a single Word document.
  • Custom Templates: Use your own .dotx Word template for consistent branding.
  • Dependency Injection Ready: Register as singleton or transient in your DI container.
  • Logging: Integrates with ILogger for diagnostics.
  • Pre/Post Processing Hooks: Customize the Word document before/after Markdown integration.
  • Stream Support: Generate documents in-memory for advanced scenarios.

Installation

Install the NuGet package:

Install-Package MarkdownToDocxGenerator

Supported frameworks: netstandard2.0, net9.0, net10.0


Dependencies


Platform Requirements

Linux/Containers: You must install libgdiplus for DOCX/image processing. For example, in your Dockerfile:

RUN apt-get update && apt-get install -y libgdiplus

For Alpine Linux, use:

RUN apk add --no-cache libgdiplus

If you see errors related to GDI+ or image processing, ensure this library is present.


Quick Start

1. Register the Service

In your Program.cs or Startup.cs:

services.AddMarkdownToDocxGenerator();
// or for advanced control:
// services.RegisterMarkdownToDocxGenerator(asSingleton: true);

Note: You must register a logger (ILogger) before calling AddMarkdownToDocxGenerator.

2. Inject and Use the Generator

public class MyService
{
    private readonly MdReportGenenerator reportGenerator;

    public MyService(MdReportGenenerator reportGenerator)
    {
        this.reportGenerator = reportGenerator;
    }

    public void GenerateReport()
    {
        var rootFolder = Path.Combine(Environment.CurrentDirectory, "MdFiles");
        var templatePath = Path.Combine(Environment.CurrentDirectory, "Dotx/sample.dotx");
        var outputPath = Path.Combine(Environment.CurrentDirectory, "Dotx/sample.docx");

        reportGenerator.Transform(outputPath, rootFolder, templatePath);
    }
}
Transform Parameters
  • outputPath: Path to the output DOCX file
  • rootFolder: Path to the folder containing Markdown files
  • templatePath: (Optional) Path to a .dotx template file

Advanced Usage

In-Memory Document Generation

Use TransformWithStream to generate a DOCX as a Stream (for web APIs, etc):

var markdownContents = new List<string> { "# Title", "Some content..." };
using var templateStream = File.OpenRead("template.dotx");
using var docxStream = reportGenerator.TransformWithStream(markdownContents, templateStream);
// Save or return docxStream as needed

Pre/Post Processing Hooks

You can pass actions to run before or after Markdown integration:

reportGenerator.Transform(
    outputPath,
    rootFolder,
    templatePath,
    preHook: word => { /* customize WordManager before content */ },
    postHook: word => { /* finalize document */ }
);

Testing & Samples

  • Check the unit tests in the repository for real-world usage and edge cases.

Troubleshooting

  • Linux/Containers: Ensure libgdiplus is installed if you see GDI+ or image errors.
  • Logging: The library uses ILogger for diagnostics. Make sure logging is configured in your app.
  • Template Issues: If the template file is missing or invalid, the generator will log a warning and skip it.

Contributing & Support

  • Found a bug or have a feature request? Open an issue or submit a PR.
  • Contributions are welcome! Please see the contribution guidelines if available.
  • If you like this project, please star it!

Badges

Quality Gate Status .NET NuGet Version


Support the Author

If you find this project useful, you can support the author with a coffee:

alternate text is missing from this package README image

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MarkdownToDocxGenerator:

Package Downloads
MDev.Dotnet.SemanticKernel.Plugins.Oxml.Docx

Plugin for semantic kernel that let you (or the LLM) to create docx documents

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.0 25 9/12/2025
1.2.0-preview-027 24 9/12/2025
1.2.0-preview-026 23 9/12/2025
1.2.0-preview-025 26 9/12/2025
1.2.0-preview-024 24 9/12/2025
1.2.0-preview-023 108 9/11/2025
1.1.0 1,927 12/16/2024
1.1.0-preview-8 1,715 7/3/2023
1.1.0-preview-7 177 7/3/2023
1.1.0-preview-6 181 6/30/2023
1.1.0-preview-5 158 6/30/2023
1.1.0-preview-4 171 6/26/2023
1.1.0-preview-3 167 6/26/2023
1.1.0-preview-12 129 12/18/2023
1.1.0-preview-021 91 12/16/2024
1.1.0-preview-020 99 12/4/2024
1.1.0-preview-019 87 12/4/2024
1.0.0 242 6/26/2023