{"id":21811190,"url":"https://github.com/mathieumack/markdowntodocxgenerator","last_synced_at":"2026-05-08T18:35:30.314Z","repository":{"id":177713738,"uuid":"658692718","full_name":"mathieumack/MarkdownToDocxGenerator","owner":"mathieumack","description":"Markdown to docx library that let you to transform one (or more) files to a Docx (Microsoft Word) document.","archived":false,"fork":false,"pushed_at":"2026-03-26T22:26:19.000Z","size":3080,"stargazers_count":4,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-27T10:31:37.687Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathieumack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-06-26T09:53:17.000Z","updated_at":"2026-03-26T22:26:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"e3c8f9e9-c54b-4129-9f34-c741c75b260c","html_url":"https://github.com/mathieumack/MarkdownToDocxGenerator","commit_stats":null,"previous_names":["mathieumack/markdowntodocxgenerator"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mathieumack/MarkdownToDocxGenerator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieumack%2FMarkdownToDocxGenerator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieumack%2FMarkdownToDocxGenerator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieumack%2FMarkdownToDocxGenerator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieumack%2FMarkdownToDocxGenerator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathieumack","download_url":"https://codeload.github.com/mathieumack/MarkdownToDocxGenerator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieumack%2FMarkdownToDocxGenerator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32792391,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-27T13:43:41.915Z","updated_at":"2026-05-08T18:35:30.303Z","avatar_url":"https://github.com/mathieumack.png","language":"C#","funding_links":["https://www.buymeacoffee.com/mathieumack"],"categories":[],"sub_categories":[],"readme":"\n# MarkdownToDocxGenerator\n\n[![.NET](https://github.com/mathieumack/MarkdownToDocxGenerator/actions/workflows/ci.yml/badge.svg)](https://github.com/mathieumack/MarkdownToDocxGenerator/actions/workflows/ci.yml)\n![NuGet Version](https://img.shields.io/nuget/v/MarkdownToDocxGenerator)\n\n\u003e **Transform your Markdown documentation into professional Word documents effortlessly.**  \n\u003e Stop manual document creation. Automate your documentation workflow with .NET.\n\n---\n\n## 📖 What is MarkdownToDocxGenerator?\n\n**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.\n\n### ✨ Key Features\n\n- **📄 Markdown to DOCX Conversion**: Transform a folder of `.md` files into a single, formatted Word document\n- **🎨 Custom Templates**: Apply your own `.dotx` Word template for consistent branding and styling\n- **💉 Dependency Injection Ready**: Easily register as singleton or transient in your DI container\n- **📊 Logging Support**: Integrates with `ILogger` for comprehensive diagnostics and monitoring\n- **🔧 Pre/Post Processing Hooks**: Customize the Word document before and after Markdown integration\n- **🚀 Stream Support**: Generate documents in-memory for web APIs and advanced scenarios\n- **🌐 Cross-Platform**: Works on Windows, Linux, and containers with proper configuration\n\n---\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n- **.NET Requirements**: .NET Standard 2.0+, .NET 9+, .NET 10+\n- **Linux/Containers**: Install `libgdiplus` for DOCX/image processing\n\n### Installation\n\nInstall the NuGet package via the Package Manager Console:\n\n```powershell\nInstall-Package MarkdownToDocxGenerator\n```\n\nOr using the .NET CLI:\n\n```bash\ndotnet add package MarkdownToDocxGenerator\n```\n\n**Supported frameworks**: `netstandard2.0`, `net9.0`, `net10.0`\n\n### Platform-Specific Configuration\n\n#### Linux/Docker Containers\n\nYou must install `libgdiplus` for DOCX and image processing. Add this to your Dockerfile:\n\n```dockerfile\nRUN apt-get update \u0026\u0026 apt-get install -y libgdiplus\n```\n\nFor Alpine Linux:\n\n```dockerfile\nRUN apk add --no-cache libgdiplus\n```\n\n\u003e **💡 Tip**: If you encounter GDI+ or image processing errors, ensure this library is installed.\n\n### Dependencies\n\nThis library uses the following packages:\n- [Markdig](https://github.com/xoofx/markdig) - Fast and extensible Markdown processor\n- [OpenXMLSDK.Engine](https://github.com/OfficeDev/Open-XML-SDK) - Office document manipulation\n- [Microsoft.Extensions.DependencyInjection](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection) - DI support\n- [Microsoft.Extensions.Logging](https://learn.microsoft.com/en-us/dotnet/core/extensions/logging) - Logging infrastructure\n\n---\n\n## 💻 Usage\n\n### Basic Usage\n\n#### 1. Register the Service\n\nIn your `Program.cs` or `Startup.cs`:\n\n```csharp\nservices.AddMarkdownToDocxGenerator();\n\n// Or for advanced control:\n// services.RegisterMarkdownToDocxGenerator(asSingleton: true);\n```\n\n\u003e **⚠️ Important**: You must register a logger (`ILogger`) before calling `AddMarkdownToDocxGenerator`.\n\n#### 2. Inject and Use the Generator\n\n```csharp\npublic class MyService\n{\n    private readonly MdReportGenenerator reportGenerator;\n\n    public MyService(MdReportGenenerator reportGenerator)\n    {\n        this.reportGenerator = reportGenerator;\n    }\n\n    public void GenerateReport()\n    {\n        var rootFolder = Path.Combine(Environment.CurrentDirectory, \"MdFiles\");\n        var templatePath = Path.Combine(Environment.CurrentDirectory, \"Dotx/sample.dotx\");\n        var outputPath = Path.Combine(Environment.CurrentDirectory, \"Dotx/sample.docx\");\n\n        reportGenerator.Transform(outputPath, rootFolder, templatePath);\n    }\n}\n```\n\n**Transform Parameters:**\n- `outputPath`: Path to the output DOCX file\n- `rootFolder`: Path to the folder containing Markdown files\n- `templatePath`: (Optional) Path to a `.dotx` template file\n\n---\n\n### Advanced Usage\n\n#### In-Memory Document Generation\n\nUse `TransformWithStream` to generate a DOCX as a `Stream` (ideal for web APIs and cloud services):\n\n```csharp\nvar markdownContents = new List\u003cstring\u003e { \"# Title\", \"Some content...\" };\nusing var templateStream = File.OpenRead(\"template.dotx\");\nusing var docxStream = reportGenerator.TransformWithStream(markdownContents, templateStream);\n// Save or return docxStream as needed\n```\n\n#### Pre/Post Processing Hooks\n\nCustomize the Word document before or after Markdown integration:\n\n```csharp\nreportGenerator.Transform(\n    outputPath,\n    rootFolder,\n    templatePath,\n    preHook: word =\u003e { /* customize WordManager before content */ },\n    postHook: word =\u003e { /* finalize document */ }\n);\n```\n\n---\n\n## 🎯 What You Get\n\n### Benefits\n\n- **⏱️ Time Savings**: Automate documentation generation instead of manual Word editing\n- **📝 Consistency**: Use templates to ensure uniform formatting across all documents\n- **🔄 Automation**: Integrate into CI/CD pipelines for automatic documentation updates\n- **🧪 Testable**: Unit tests included - see the test project for real-world examples\n- **🛡️ Well-Tested**: Comprehensive unit tests ensure reliability and code quality\n\n### Real-World Use Cases\n\n- **Technical Documentation**: Generate API documentation, user guides, and technical specifications\n- **Report Generation**: Create automated business reports, project status updates\n- **Documentation Pipelines**: Integrate with CI/CD to keep documentation in sync with code\n- **Multi-Format Publishing**: Convert Markdown content to Word for further distribution\n\n---\n\n## 🧪 Testing \u0026 Examples\n\nExplore the [unit tests](./src/MarkdownToDocxGenerator.UnitTests) in the repository for real-world usage examples and edge cases.\n\n---\n\n## 🔧 Troubleshooting\n\n| Issue | Solution |\n|-------|----------|\n| **GDI+ or Image Errors (Linux/Containers)** | Ensure `libgdiplus` is installed in your environment |\n| **Logging Not Working** | The library uses `ILogger` - verify logging is configured in your application |\n| **Template Issues** | If the template file is missing or invalid, check logs for warnings. The generator will skip invalid templates |\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions! Here's how you can help:\n\n- 🐛 **Found a bug?** [Open an issue](https://github.com/mathieumack/MarkdownToDocxGenerator/issues)\n- 💡 **Have a feature idea?** [Submit a feature request](https://github.com/mathieumack/MarkdownToDocxGenerator/issues/new)\n- 🔧 **Want to contribute code?** Check out our [contribution guidelines](./CONTRIBUTING.md)\n\nIf you find this project useful, please ⭐ star it on GitHub!\n\n---\n\n## 📄 License\n\nThis project is licensed under the terms specified in the [LICENSE](./LICENSE) file.\n\n---\n\n## ☕ Support the Author\n\nIf you find this project helpful, consider supporting the author:\n\n[![Buy Me A Coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/mathieumack)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieumack%2Fmarkdowntodocxgenerator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathieumack%2Fmarkdowntodocxgenerator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieumack%2Fmarkdowntodocxgenerator/lists"}