Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
afdded0
Add CSS Stylesheet support link to README
onizet Nov 13, 2026
5301853
Fix reference to nuget base package
onizet Nov 13, 2026
575f529
Wording and typo
onizet Nov 14, 2026
899f3e9
Svg now fallback to viewbox if width or height is not set
onizet Nov 16, 2026
07a5c64
Fix Svg not output in the header/footer
onizet Nov 16, 2026
6accca4
Fix the pack dependency
onizet Nov 16, 2026
6bbc01f
Add Extensibility entry point to the converter
onizet Nov 16, 2026
920061b
Use TryParse paradigm to avoid throwing error during parsing of Unit …
onizet Nov 17, 2026
4a1d115
Stop building the NuSpec.AI in debug
onizet Nov 17, 2026
90d16d2
Add comment
onizet Nov 18, 2026
b9627c5
Fix to continue augmenting the existing configuration
onizet Nov 21, 2026
8e2fa2c
Increment nuget deps version
onizet Nov 21, 2026
464ebae
Move expressions tests to their own folder
onizet Nov 21, 2026
94552f0
Create FUNDING.yml
onizet Nov 18, 2026
9d0c5a9
Update FUNDING.yml
onizet Nov 18, 2026
a43de49
Update FUNDING.yml
onizet Nov 18, 2026
b245c48
Clarify the license model
onizet Nov 22, 2026
c879a86
Remove the ILogger on DefaultWebRequest
onizet Nov 22, 2026
4ec1b3c
Stop mutating the received HttpClient
onizet Nov 22, 2026
bbd4288
Mark this implementation as Obsolete
onizet Nov 22, 2026
3403b74
Fix license mark
onizet Nov 23, 2026
8f4cb44
Simplify the code
onizet Nov 23, 2026
b3253e3
Use AppendChild and not AddChild to ensure the SectionProperties rema…
onizet Nov 23, 2026
4d716f4
Provide ability to register custom tag processors
onizet Nov 23, 2026
f4b71d7
Relocate docs into main API References
onizet Nov 23, 2026
3641bcd
Register heading 7-9, even if they are not supported in Html, they ar…
onizet Nov 23, 2026
775cc4c
Exposes the list of registred styles
onizet Nov 23, 2026
1813d91
Rewording the readme to highlight the features
onizet Nov 23, 2026
bb5671c
The detection of landscape layout is smarter and refine the max width…
onizet Nov 25, 2026
e458b54
Constrain image rendering to the available page content width, preser…
onizet Nov 26, 2026
86ccd32
Fix the KeepAspectRatio logic and update the precision output in the …
onizet Nov 27, 2026
55ab964
Update the documentation
onizet Nov 27, 2026
da2d7a7
Add LoadDocumentAync() method in changelog
onizet Nov 27, 2026
5747bfc
Merge branch 'master' of github.com:onizet/html2openxml into dev
onizet Nov 27, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## 4.3.0

- New `WordDocumentFactory.Create(orientation, paperSize)` helper.
- New `WordDocumentFactory.AddPage(orientation, paperSize)` helper.
- New `WordDocumentFactory.AddPageBreak()` helper.
- Add extensibility capabilities to the converter: `Transformers`, `ParserConfigurators` and `NodeProcessors`.
- New `LoadDocumentAsync(html)` which allow parsing once and converting multiple times.
- Image size expressed in percentage (max-width) consider the current page width (orientation and different paper size than A4).
- Image widths are automatically constrained to prevent overflow of the page.
- Fix SVG appended to the body rather than in the footer/header.

- **[BREAKING CHANGE]** Remove the non-standard attribute `page-orientation` on the body to change the orientation. Use `AddPage()` instead.
- Stop mutating the `HttpClient` in `DefaultWebRequest`.
- Remove `ILogger` from `DefaultWebRequest` which removes one extra package dependency.
- Prefer `converter.UseCssInliner()` rather than creating a new instance of `CssStyleHtmlConverter`.

## 4.2.0

Ease of Use Improvements:
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Version>4.2.0</Version>
<Version>4.3.0</Version>
</PropertyGroup>

<PropertyGroup Condition="'$(PackageVersion)' != ''">
Expand Down
21 changes: 8 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
<!-- Primitives -->
<PackageVersion Include="System.ValueTuple" Version="4.6.2" />
<!-- Html Parser -->
<PackageVersion Include="AngleSharp" Version="1.8.6" />
<PackageVersion Include="AngleSharp.Css" Version="1.3.0" />
<PackageVersion Include="AngleSharp" Version="1.10.4" />
<PackageVersion Include="AngleSharp.Css" Version="1.4.2" />
<!-- OpenXml SDK -->
<PackageVersion Include="DocumentFormat.OpenXml" Version="3.5.1" />
<!-- Framework Abstractions -->
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
<PackageVersion Include="PolySharp" Version="1.16.0" />
<PackageVersion Include="PolySharp" Version="1.17.1" />
</ItemGroup>

<ItemGroup Label="Build">
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.403" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.404" />
<PackageVersion Include="NuSpec.AI" Version="3.1.1" />
</ItemGroup>

<ItemGroup Label="Testing">
<PackageVersion Include="coverlet.msbuild" Version="10.1.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0" />
<PackageVersion Include="coverlet.msbuild" Version="10.1.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.12.0" />
<!-- NUnit -->
<PackageVersion Include="NUnit" Version="5.0.0" />
<PackageVersion Include="NUnit.Analyzers" Version="4.15.0" />
Expand All @@ -33,11 +32,7 @@
</ItemGroup>

<ItemGroup Label="Global Analyzers">
<GlobalPackageReference Include="Roslynator.Analyzers" Version="5.0.0" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.9.0" />
</ItemGroup>

<ItemGroup Label="Target for NuGet package">
<PackageVersion Include="HtmlToOpenXml" Version="1.0.0" />
<GlobalPackageReference Include="Roslynator.Analyzers" Version="5.0.1" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="5.12.0" />
</ItemGroup>
</Project>
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,38 @@
# HtmlToOpenXml&nbsp;[![Latest version](https://img.shields.io/nuget/v/HtmlToOpenXml.svg)](https://www.nuget.org/packages/HtmlToOpenXml/)&nbsp;[![Download Counts](https://img.shields.io/nuget/dt/HtmlToOpenXml.svg)](https://www.nuget.org/packages/HtmlToOpenXml/)&nbsp;[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/onizet/html2openxml/blob/dev/LICENSE)

HtmlToOpenXml is a mature, high-fidelity converter that translates complex HTML structures into native OpenXML elements, ensuring your content renders exactly as intended across all Microsoft Word users.
HtmlToOpenXml is a mature library for generating native OpenXML Word documents from HTML. It transforms simple or complete HTML into fully editable Word content while preserving document styles, numbering definitions, templates, and layout.

Originally created in 2009 to transform user-generated content into templated Word documents, it has evolved
into a mature HTML-to-OpenXML converter supporting styles, numbering, images, bookmarks, page layout, tables,
document template, and custom resource resolution.

![Logo](https://raw.githubusercontent.com/onizet/html2openxml/master/docs/images/html2openxml.png)

Supports **.Net Framework 4.6.2**, **.NET Standard 2.0**, **.NET 8** **.NET 10** which are all LTS.
## Features

Built on top of [DocumentFormat.OpenXml](https://www.nuget.org/packages/DocumentFormat.OpenXml/) and [AngleSharp](https://www.nuget.org/packages/AngleSharp).
- HTML → DOCX conversion
- Word template integration
- Portrait and landscape page sections
- Headers and footers
- Tables with RowSpan and ColSpan support
- Numbered and bulleted lists
- Images (PNG, JPEG, SVG, Data URI)
- Internal hyperlinks and bookmarks
- Right-to-left (RTL) documents
- CSS stylesheet support (optional package)

Supports **.NET Framework 4.6.2**, **.NET Standard 2.0**, **.NET 8** **.NET 10**.

-> [Official Nuget Package](https://www.nuget.org/packages/HtmlToOpenXml) (❗ **Update your bookmark**, suffix `.dll` removed)
Built on top of [DocumentFormat.OpenXml](https://www.nuget.org/packages/DocumentFormat.OpenXml/) and [AngleSharp](https://www.nuget.org/packages/AngleSharp).

-> [HtmlToOpenXml.CssInliner](https://www.nuget.org/packages/HtmlToOpenXml.CssInliner/) (companion library for extended CSS support)
| Package | NuGet Stable | Downloads |
| ------- | ------------ | --------- |
| [HtmlToOpenXml](https://www.nuget.org/packages/HtmlToOpenXml/) | [![HtmlToOpenXml](https://img.shields.io/nuget/v/HtmlToOpenXml.svg)](https://www.nuget.org/packages/HtmlToOpenXml/) | [![HtmlToOpenXml](https://img.shields.io/nuget/dt/HtmlToOpenXml.svg)](https://www.nuget.org/packages/HtmlToOpenXml/) |
| [HtmlToOpenXml.CssInliner](https://www.nuget.org/packages/HtmlToOpenXml.CssInliner/) | [![HtmlToOpenXml.CssInliner](https://img.shields.io/nuget/v/HtmlToOpenXml.CssInliner.svg)](https://www.nuget.org/packages/HtmlToOpenXml.CssInliner/) | [![HtmlToOpenXml.CssInliner](https://img.shields.io/nuget/dt/HtmlToOpenXml.CssInliner.svg)](https://www.nuget.org/packages/HtmlToOpenXml.CssInliner/) |

> **Note**
> The package was renamed from `HtmlToOpenXml.dll` to `HtmlToOpenXml`.
> NuGet download statistics were unfortunately not transferred to the new package.

## Quick Start

Expand Down
4 changes: 2 additions & 2 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default defineUserConfig({
navbar: ['/',
{ text: 'API Reference', link: '/guide/api',
prefix: 'guide/',
children: ['api', 'hyperlinks', 'images', 'styling', 'tables', 'numbering', 'pre', 'footnotes', 'pagebreak', 'rtl']
children: ['api', 'composition', 'hyperlinks', 'images', 'styling', 'tables', 'numbering', 'pre', 'footnotes', 'rtl']
},
{ text: 'LLM Docs Friendly', link: '/llmdoc' },
{ text: 'NuGet', link: 'https://www.nuget.org/packages/HtmlToOpenXml', ariaLabel: 'NuGet', target: '_blank' }
Expand All @@ -30,7 +30,7 @@ export default defineUserConfig({
{
text: 'API Reference',
prefix: 'guide/',
children: ['quickstart', 'api', 'hyperlinks', 'images', 'styling', 'tables', 'numbering', 'pre', 'footnotes', 'pagebreak', 'rtl'],
children: ['quickstart', 'api', 'composition', 'hyperlinks', 'images', 'styling', 'tables', 'numbering', 'pre', 'footnotes', 'rtl', 'extensibility'],
},
{
text: 'LLM Docs Friendly', link: 'llmdoc'
Expand Down
Loading
Loading