Nedev.FileConverters.HtmlToDocx
0.1.0
.NET 8.0
This package targets .NET 8.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package Nedev.FileConverters.HtmlToDocx --version 0.1.0
NuGet\Install-Package Nedev.FileConverters.HtmlToDocx -Version 0.1.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="Nedev.FileConverters.HtmlToDocx" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nedev.FileConverters.HtmlToDocx" Version="0.1.0" />
<PackageReference Include="Nedev.FileConverters.HtmlToDocx" />
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 Nedev.FileConverters.HtmlToDocx --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nedev.FileConverters.HtmlToDocx, 0.1.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 Nedev.FileConverters.HtmlToDocx@0.1.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=Nedev.FileConverters.HtmlToDocx&version=0.1.0
#tool nuget:?package=Nedev.FileConverters.HtmlToDocx&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Nedev.FileConverters.HtmlToDocx
High-performance HTML to DOCX converter built on .NET 10 with zero third-party dependencies. Achieves high-fidelity conversion through a custom CSS engine and robust OpenXML generation.
✨ Features
- 🚀 Extreme Performance - Zero-allocation parsing using
Span<T>andReadOnlySpan<char>. - 📦 Zero Dependencies - Pure .NET implementation, no third-party libraries (no OpenXML SDK).
- 🎨 Full CSS Engine - Custom cascading style resolution supporting
<style>blocks and inline attributes. - 📊 Advanced Tables - Sophisticated grid mapping for complex
colspanandrowspanstructures. - 🔢 Nested Lists - Support for multi-level
<ul>and<ol>with correct numbering indentation. - 🖼️ Multimedia - Automatic embedding of local, remote (HTTP/S), and Base64 data URI images.
- 📐 Page Layout - Configurable page size (A4, Letter, etc.) and margins.
- 📄 Headers & Footers - HTML
<header>and<footer>mapped to Word header/footer parts. - 🔢 Page Numbering - Dynamic PAGE / NUMPAGES fields.
- 📖 Table of Contents - Auto-generated TOC field from headings.
📦 Installation
NuGet Package
dotnet add package Nedev.FileConverters.HtmlToDocx
CLI Tool
dotnet tool install --global Nedev.FileConverters.HtmlToDocx.Cli
🚀 Quick Start
Basic Usage
using Nedev.FileConverters.HtmlToDocx;
// Simple conversion
string html = "<h1>Hello World</h1><p>This is a test.</p>";
byte[] docxBytes = html.ToDocx();
File.WriteAllBytes("output.docx", docxBytes);
// Using service with options
var options = new ConverterOptions { PageWidth = 11906, PageHeight = 16838 }; // A4
using var service = new HtmlToDocxService(options);
byte[] result = service.Convert(html);
Async Conversion
byte[] asyncResult = await html.ToDocxAsync();
⚙️ Configuration Options
var options = new ConverterOptions
{
PreserveStyles = true, // Enable CSS engine
DownloadImages = true, // Download remote images
MaxImageSize = 10 * 1024 * 1024, // 10MB
PageWidth = 11906, // A4 Width
Margins = new PageMargins { Top = 1440, Bottom = 1440 }
};
📋 Supported HTML Elements
Text & Formatting
<p>,<h1>~<h6>,<br>,<hr>,<span>,<div><strong>/<b>,<em>/<i>,<u>,<s>,<font>
Links and Media
<a>- Hyperlinks with relationship management.<img>- Supports.jpg,.png,.gif(local, remote, base64).
Lists
<ul>(Bullet) and<ol>(Numbered) with nested levels.
Tables
<table>,<thead>,<tbody>,<tr>,<th>,<td>.- Full
colspan/rowspansupport with grid stabilization.
🎨 Supported CSS Properties
- Typography:
color,font-size(pt/px),font-family,font-weight,font-style,text-decoration,text-align. - Layout:
width,height,margin(page-level). - Inheritance: Styles correctly cascade from parent containers to text runs.
⚡ Performance
Verified performance on .NET 10:
| File Size | Conversion Time | Throughput |
|---|---|---|
| 10 KB | ~3 ms | 3,300 chars/ms |
| 100 KB | ~15 ms | 6,600 chars/ms |
| 1 MB | ~120 ms | 8,300 chars/ms |
Test environment: Intel i7-12700, Windows 11, .NET 10.0
🏗️ Architecture
Nedev.FileConverters.HtmlToDocx/
├── Html/ # Span-based HTML Tokenizer & Tree Builder
├── Css/ # Custom CSS Parser & Cascade Resolver
├── Docx/ # OpenXML (WordprocessingML) Generator
├── Models/ # Shared Converter & Layout Models
├── Utils/ # ZipArchiveHelper & IO Utilities
└── HtmlToDocxService.cs
📝 Roadmap
Medium Priority
- SVG to EMF conversion support
Low Priority
- MathML support
- RTF export support
📄 License
MIT License - see LICENSE file for details
| 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 is compatible. 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 was computed. 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 was computed. 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | 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.
-
.NETStandard 2.1
- Nedev.FileConverters.Core (>= 0.1.0)
-
net8.0
- Nedev.FileConverters.Core (>= 0.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 84 | 3/6/2026 |