MarkdownToDocxGenerator 1.2.0-preview-045

This is a prerelease version of MarkdownToDocxGenerator.
There is a newer version of this package available.
See the version list below for details.
dotnet add package MarkdownToDocxGenerator --version 1.2.0-preview-045
                    
NuGet\Install-Package MarkdownToDocxGenerator -Version 1.2.0-preview-045
                    
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-preview-045" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkdownToDocxGenerator" Version="1.2.0-preview-045" />
                    
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-preview-045
                    
#r "nuget: MarkdownToDocxGenerator, 1.2.0-preview-045"
                    
#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-preview-045
                    
#: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-preview-045&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=MarkdownToDocxGenerator&version=1.2.0-preview-045&prerelease
                    
Install as a Cake Tool

MarkdownToDocxGenerator

.NET NuGet Version

Transform your Markdown documentation into professional Word documents effortlessly.
Stop manual document creation. Automate your documentation workflow with .NET.


๐Ÿ“– What is MarkdownToDocxGenerator?

MarkdownToDocxGenerator is a powerful .NET library that converts Markdown files into professional DOCX (Word) documents. Whether you're generating technical documentation, reports, or automated documentation workflows, this library seamlessly integrates into your .NET applications with minimal configuration.

โœจ Key Features

  • ๐Ÿ“„ Markdown to DOCX Conversion: Transform a folder of .md files into a single, formatted Word document
  • ๐ŸŽจ Custom Templates: Apply your own .dotx Word template for consistent branding and styling
  • ๐Ÿ’‰ Dependency Injection Ready: Easily register as singleton or transient in your DI container
  • ๐Ÿ“Š Logging Support: Integrates with ILogger for comprehensive diagnostics and monitoring
  • ๐Ÿ”ง Pre/Post Processing Hooks: Customize the Word document before and after Markdown integration
  • ๐Ÿš€ Stream Support: Generate documents in-memory for web APIs and advanced scenarios
  • ๐ŸŒ Cross-Platform: Works on Windows, Linux, and containers with proper configuration

๐Ÿš€ Getting Started

Prerequisites

  • .NET Requirements: .NET Standard 2.0+, .NET 9+, .NET 10+
  • Linux/Containers: Install libgdiplus for DOCX/image processing

Installation

Install the NuGet package via the Package Manager Console:

Install-Package MarkdownToDocxGenerator

Or using the .NET CLI:

dotnet add package MarkdownToDocxGenerator

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

Platform-Specific Configuration

Linux/Docker Containers

You must install libgdiplus for DOCX and image processing. Add this to your Dockerfile:

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

For Alpine Linux:

RUN apk add --no-cache libgdiplus

๐Ÿ’ก Tip: If you encounter GDI+ or image processing errors, ensure this library is installed.

Dependencies

This library uses the following packages:


๐Ÿ’ป Usage

Basic Usage

1. Register the Service

In your Program.cs or Startup.cs:

services.AddMarkdownToDocxGenerator();

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

โš ๏ธ Important: 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 (ideal for web APIs and cloud services):

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

Customize the Word document before or after Markdown integration:

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

๐ŸŽฏ What You Get

Benefits

  • โฑ๏ธ Time Savings: Automate documentation generation instead of manual Word editing
  • ๐Ÿ“ Consistency: Use templates to ensure uniform formatting across all documents
  • ๐Ÿ”„ Automation: Integrate into CI/CD pipelines for automatic documentation updates
  • ๐Ÿงช Testable: Unit tests included - see the test project for real-world examples
  • ๐Ÿ›ก๏ธ Well-Tested: Comprehensive unit tests ensure reliability and code quality

Real-World Use Cases

  • Technical Documentation: Generate API documentation, user guides, and technical specifications
  • Report Generation: Create automated business reports, project status updates
  • Documentation Pipelines: Integrate with CI/CD to keep documentation in sync with code
  • Multi-Format Publishing: Convert Markdown content to Word for further distribution

๐Ÿงช Testing & Examples

Explore the unit tests in the repository for real-world usage examples and edge cases.


๐Ÿ”ง Troubleshooting

Issue Solution
GDI+ or Image Errors (Linux/Containers) Ensure libgdiplus is installed in your environment
Logging Not Working The library uses ILogger - verify logging is configured in your application
Template Issues If the template file is missing or invalid, check logs for warnings. The generator will skip invalid templates

๐Ÿค Contributing

We welcome contributions! Here's how you can help:

If you find this project useful, please โญ star it on GitHub!


๐Ÿ“„ License

This project is licensed under the terms specified in the LICENSE file.


โ˜• Support the Author

If you find this project helpful, consider supporting the author:

Buy Me A Coffee

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 726 9/12/2025
1.2.0-preview-045 63 3/26/2026
1.2.0-preview-034 391 12/11/2025
1.2.0-preview-033 390 12/11/2025
1.2.0-preview-032 394 12/11/2025
1.2.0-preview-031 394 12/11/2025
1.2.0-preview-030 122 10/24/2025
1.2.0-preview-029 154 10/23/2025
1.2.0-preview-027 98 9/12/2025
1.2.0-preview-026 94 9/12/2025
1.2.0-preview-025 91 9/12/2025
1.2.0-preview-024 92 9/12/2025
1.2.0-preview-023 157 9/11/2025
1.1.0 2,390 12/16/2024
1.1.0-preview-8 1,774 7/3/2023
1.1.0-preview-7 238 7/3/2023
1.1.0-preview-12 175 12/18/2023
1.1.0-preview-021 148 12/16/2024
1.1.0-preview-020 156 12/4/2024
1.1.0-preview-019 146 12/4/2024
Loading failed