MarkdownToDocxGenerator 1.2.0
dotnet add package MarkdownToDocxGenerator --version 1.2.0
NuGet\Install-Package MarkdownToDocxGenerator -Version 1.2.0
<PackageReference Include="MarkdownToDocxGenerator" Version="1.2.0" />
<PackageVersion Include="MarkdownToDocxGenerator" Version="1.2.0" />
<PackageReference Include="MarkdownToDocxGenerator" />
paket add MarkdownToDocxGenerator --version 1.2.0
#r "nuget: MarkdownToDocxGenerator, 1.2.0"
#:package MarkdownToDocxGenerator@1.2.0
#addin nuget:?package=MarkdownToDocxGenerator&version=1.2.0
#tool nuget:?package=MarkdownToDocxGenerator&version=1.2.0
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
- .NET Standard 2.0+ / .NET 8+ / .NET 9+ / .NET 10+
- Markdig
- OpenXMLSDK.Engine
- Microsoft.Extensions.DependencyInjection
- Microsoft.Extensions.Logging
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 filerootFolder
: Path to the folder containing Markdown filestemplatePath
: (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
Support the Author
If you find this project useful, you can support the author with a coffee:
Product | Versions 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. |
-
.NETStandard 2.0
- Markdig (>= 0.42.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Console (>= 10.0.0-rc.1.25451.107)
- OpenXMLSDK.Engine (>= 2022.10313.0-preview-044)
-
net10.0
- Markdig (>= 0.42.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Console (>= 10.0.0-rc.1.25451.107)
- OpenXMLSDK.Engine (>= 2022.10313.0-preview-044)
-
net9.0
- Markdig (>= 0.42.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0-rc.1.25451.107)
- Microsoft.Extensions.Logging.Console (>= 10.0.0-rc.1.25451.107)
- OpenXMLSDK.Engine (>= 2022.10313.0-preview-044)
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 |