OfficeIMO.Word.Html
3.0.3
Prefix Reserved
dotnet add package OfficeIMO.Word.Html --version 3.0.3
NuGet\Install-Package OfficeIMO.Word.Html -Version 3.0.3
<PackageReference Include="OfficeIMO.Word.Html" Version="3.0.3" />
<PackageVersion Include="OfficeIMO.Word.Html" Version="3.0.3" />
<PackageReference Include="OfficeIMO.Word.Html" />
paket add OfficeIMO.Word.Html --version 3.0.3
#r "nuget: OfficeIMO.Word.Html, 3.0.3"
#:package OfficeIMO.Word.Html@3.0.3
#addin nuget:?package=OfficeIMO.Word.Html&version=3.0.3
#tool nuget:?package=OfficeIMO.Word.Html&version=3.0.3
OfficeIMO.Word.Html - Word and HTML conversion
OfficeIMO.Word.Html converts between HTML and OfficeIMO.Word documents. It is for document-shaped HTML that should become editable Word content, and for Word documents that should be exported as HTML.
Install
dotnet add package OfficeIMO.Word.Html
Quick start
using OfficeIMO.Word;
using OfficeIMO.Html;
using OfficeIMO.Word.Html;
HtmlConversionDocument source = HtmlConversionDocument.Parse("<h1>Hello</h1><p>Body</p>");
using WordDocument document = source.ToWordDocument(new HtmlToWordOptions());
string html = document.ToHtml(new WordToHtmlOptions {
IncludeDefaultCss = true,
ExportFootnotes = true,
ExportEndnotes = true,
ExportComments = true
});
HtmlTextConversionResult export = document.ToHtmlResult();
Console.WriteLine(export.RequireValue());
HTML can also be appended to an existing body, header, footer, or table cell with
AddHtmlToBody, AddHtmlToHeader, AddHtmlToFooter, and WordTableCell.AddHtml.
Use the result API when conversion evidence matters:
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
HtmlToWordResult result = source.ToWordDocumentResult(options);
using WordDocument document = result.RequireValue();
foreach (HtmlDiagnostic diagnostic in result.Report.Diagnostics) {
Console.WriteLine($"{diagnostic.Code}: {diagnostic.LossKind}");
}
HtmlConversionDocument is the required source model. It keeps parsing, base-URI handling, resource policy, and source diagnostics in one owner. HtmlToWordOptions.Limits uses the shared HtmlConversionLimits contract; MaxHtmlNodes, MaxHtmlDepth, MaxCssBytes, and MaxTotalCssBytes remain forwarding properties for compatibility. HtmlToWordOptions.StyleMissingHandler scopes custom class mapping to one conversion.
What it maps
- HTML headings, paragraphs, inline formatting, links, images, SVG, lists, tables, captions, form controls, notes, headers, footers, and sections into Word content where supported.
- Word document metadata, paragraph/run styles, lists, tables, images, SVG, footnotes, endnotes, disabled form controls, comments, headers, footers, and optional CSS back to HTML.
- Stylesheets, inline CSS, local/remote resources, image policies, resource limits, and diagnostics through explicit options.
- Document language metadata between HTML
langand Word settings.
Import profiles
var safeOptions = HtmlToWordOptions.CreateUntrustedHtmlProfile();
safeOptions.MaxHtmlNodes = 5000;
safeOptions.DiagnosticHandler = diagnostic =>
Console.WriteLine($"{diagnostic.Code}: {diagnostic.Source}");
HtmlConversionDocument source = HtmlConversionDocument.Parse(html);
using WordDocument safeDocument = source.ToWordDocument(safeOptions);
Remote images and stylesheets require the async API:
HtmlToWordResult remote = await source.ToWordDocumentResultAsync(options, cancellationToken);
using WordDocument remoteDocument = remote.RequireValue();
Remote image prefetch uses at most HtmlToWordOptions.MaxConcurrentResourceLoads requests at
once. Imports with MaxTotalImageBytes stay sequential so responses that exceed the remaining
budget can be rejected before their bodies are read.
CreateOfficeIMOProfile()keeps the compatibility-oriented defaults.CreateUntrustedHtmlProfile()keeps external document resources offline by default and enables bounded conversion.CreateTrustedDocumentProfile()enables document-provided stylesheet links for known-good HTML while keeping resource validation.new HtmlToWordOptions()embeds data URI images only; use a trusted/compatibility profile or setImageProcessing = ImageProcessingMode.Embedfor trusted remote image fetching.- Local file images are not loaded by default; use a trusted/compatibility profile or add
Uri.UriSchemeFiletoAllowedImageUriSchemesfor trusted local files.
Boundaries
- Word document modeling belongs in
OfficeIMO.Word. - HTML-to-Markdown ingestion belongs in
OfficeIMO.Markdown.Html. - HTML-to-PDF bridge behavior belongs in
OfficeIMO.Html.Pdf. - Full support matrices and roadmap detail belong in
Docs/, not this README.
Deeper docs
Targets and license
- Targets:
netstandard2.0,net8.0,net10.0;net472is included when building on Windows. - License: MIT.
- Repository: EvotecIT/OfficeIMO
Dependency footprint
- External: Open XML SDK already used by the Word package; HTML DOM/CSS parsing comes through
OfficeIMO.Html. - OfficeIMO:
OfficeIMO.Word,OfficeIMO.Html, andOfficeIMO.Drawing. The bidirectional mapping, resource policy, and diagnostics are first-party.
See the complete OfficeIMO package map for related formats and conversion paths.
| 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 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 is compatible. 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. |
-
.NETFramework 4.7.2
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 3.0.3)
- OfficeIMO.Html (>= 3.0.3)
- OfficeIMO.Word (>= 3.0.3)
-
.NETStandard 2.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 3.0.3)
- OfficeIMO.Html (>= 3.0.3)
- OfficeIMO.Word (>= 3.0.3)
-
net10.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 3.0.3)
- OfficeIMO.Html (>= 3.0.3)
- OfficeIMO.Word (>= 3.0.3)
-
net8.0
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 3.0.3)
- OfficeIMO.Html (>= 3.0.3)
- OfficeIMO.Word (>= 3.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OfficeIMO.Word.Html:
| Package | Downloads |
|---|---|
|
OfficeIMO.Word.Markdown
Markdown converter for OfficeIMO.Word - Convert Word documents to/from Markdown using OfficeIMO.Markdown |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on OfficeIMO.Word.Html:
| Repository | Stars |
|---|---|
|
EvotecIT/PSWriteOffice
MIT-licensed PowerShell document automation for Word, Excel, PowerPoint, PDF, email, PST/OST, OneNote, Visio, OpenDocument, and mixed-format Reader workflows.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.3 | 132 | 7/27/2026 |
| 3.0.2 | 136 | 7/26/2026 |
| 3.0.1 | 366 | 7/26/2026 |
| 3.0.0 | 513 | 7/20/2026 |
| 2.0.1 | 1,258 | 7/14/2026 |
| 2.0.0 | 723 | 7/14/2026 |
| 1.0.49 | 871 | 7/9/2026 |
| 1.0.48 | 775 | 7/8/2026 |
| 1.0.47 | 961 | 7/5/2026 |
| 1.0.46 | 733 | 7/4/2026 |
| 1.0.45 | 1,597 | 6/27/2026 |
| 1.0.44 | 639 | 6/27/2026 |
| 1.0.43 | 922 | 6/24/2026 |
| 1.0.42 | 716 | 6/23/2026 |
| 1.0.41 | 813 | 6/21/2026 |
| 1.0.40 | 684 | 6/16/2026 |
| 1.0.39 | 793 | 6/16/2026 |
| 1.0.38 | 642 | 6/15/2026 |
| 1.0.37 | 631 | 6/13/2026 |
| 1.0.36 | 639 | 6/12/2026 |