OfficeIMO.Word.Html
1.0.34
Prefix Reserved
dotnet add package OfficeIMO.Word.Html --version 1.0.34
NuGet\Install-Package OfficeIMO.Word.Html -Version 1.0.34
<PackageReference Include="OfficeIMO.Word.Html" Version="1.0.34" />
<PackageVersion Include="OfficeIMO.Word.Html" Version="1.0.34" />
<PackageReference Include="OfficeIMO.Word.Html" />
paket add OfficeIMO.Word.Html --version 1.0.34
#r "nuget: OfficeIMO.Word.Html, 1.0.34"
#:package OfficeIMO.Word.Html@1.0.34
#addin nuget:?package=OfficeIMO.Word.Html&version=1.0.34
#tool nuget:?package=OfficeIMO.Word.Html&version=1.0.34
OfficeIMO.Word.Html
Bidirectional HTML conversion for OfficeIMO.Word.
What It Does Today
- Converts HTML into
WordDocumentwith headings, paragraphs, inline formatting, links, images, SVG, lists, tables, captions, form controls, notes, headers, footers, and sections. - Converts
WordDocumentback to HTML with document metadata, optional custom property metadata, optional headers and footers, optional comments, paragraph/run styles, optional list definition CSS, lists, tables, images, SVG, footnotes, endnotes, disabled form controls, and optional default CSS. - Preserves document-level language metadata between HTML
langattributes andWordDocument.Settings.Language. - Supports inline CSS, embedded stylesheet content, external stylesheet paths, remote stylesheet loading through a caller-provided
HttpClient, stylesheet URI scheme/host policy controls, stylesheet content-type validation, aggregate CSS byte limits, and common CSS page-break declarations. - Reuses parsed stylesheet rules by CSS content hash, while changed local or remote stylesheet content is parsed as fresh input.
- Supports image embedding, external image links, data URI images, resource timeouts, optional per-image and total image byte limits, declared image content-type validation, and image URI scheme/host policy controls.
- Supports optional HTML node, HTML depth, per-stylesheet CSS byte, aggregate CSS byte, and table-cell limits for safer conversion of large or hostile inputs.
- Provides named import profiles through
HtmlToWordOptions.CreateOfficeIMOProfile(),CreateUntrustedHtmlProfile(), andCreateTrustedDocumentProfile(), plusClone()for reusable option templates. - Reports HTML import diagnostics through
HtmlToWordOptions.DiagnosticsandDiagnosticHandlerwhen content is skipped, degraded, or not mapped, such as image load failures, raw HTML comments, disabled or invalid stylesheet links, stylesheet policy/HTTP/transport/timeout failures, and unsupported CSS declarations or values. - Can opt in to import non-empty raw HTML comments as native Word comments with configurable author and initials metadata.
- Skips unsupported embedded media/widget elements such as
iframe,object,embed,video,audio, andcanvaswith diagnostics instead of importing fallback text as document content. - Can emit opt-in accessibility diagnostics for missing image alternate text, weak or empty link text, skipped heading levels, and data tables without header cells.
- Lets callers choose unsupported CSS behavior with
HtmlToWordOptions.UnsupportedCssHandling: ignore, warn by default, or stop conversion withHtmlUnsupportedCssException. - Maps common document-table styling, including table/cell widths, borders, padding, horizontal and vertical alignment, captions, column groups, header/footer row groups, HTML
cellspacing, and CSSborder-spacing. - Imports text and visible value-bearing inputs, dates, text areas, meter/progress values, single-select dropdowns, named radio groups, multi-select values, datalist-backed combo boxes, and checkbox markers into Word content controls where Word has a practical equivalent.
- Targets
netstandard2.0,net8.0,net10.0, andnet472on Windows.
The current supported feature set is tracked in Docs/officeimo.word-html-support-matrix.md.
Entry Points
using OfficeIMO.Word.Html;
WordDocument document = html.LoadFromHtml(new HtmlToWordOptions());
string roundTrip = document.ToHtml(new WordToHtmlOptions {
IncludeDefaultCss = true,
IncludeRunColorStyles = true,
IncludeRunHighlightStyles = true,
ExportEndnotes = true,
ExportComments = true,
ExportHeadersAndFooters = true,
IncludeTableColumnGroups = true
});
HTML can also be appended to an existing body, header, or footer with the AddHtmlToBody, AddHtmlToHeader, and AddHtmlToFooter extension methods.
Import Profiles
var safeOptions = HtmlToWordOptions.CreateUntrustedHtmlProfile();
safeOptions.MaxHtmlNodes = 5000;
safeOptions.DiagnosticHandler = diagnostic => Console.WriteLine($"{diagnostic.Code}: {diagnostic.Source}");
WordDocument safeDocument = html.LoadFromHtml(safeOptions);
var trustedOptions = HtmlToWordOptions.CreateTrustedDocumentProfile();
trustedOptions.AllowedStylesheetHosts.Add("cdn.example.com");
WordDocument trustedDocument = trustedHtml.LoadFromHtml(trustedOptions);
CreateOfficeIMOProfile()preserves the default compatibility-oriented behavior.CreateUntrustedHtmlProfile()keeps external document resources offline by default, enables accessibility diagnostics, and applies bounded HTML, CSS, image, and table limits.CreateTrustedDocumentProfile()enables document-provided stylesheet links for known-good HTML while retaining the current resource validation defaults.Clone()copies configuration values, allow-lists, configured stylesheets, and callbacks while starting with an empty diagnostics collection.
Roadmap
The current plan for making this the market-leading HTML and Word conversion surface is tracked in Docs/officeimo.word-html-roadmap.md.
| 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
- AngleSharp (>= 1.4.0)
- AngleSharp.Css (>= 1.0.0-beta.216)
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.14)
- OfficeIMO.Word (>= 1.0.60)
-
.NETStandard 2.0
- AngleSharp (>= 1.4.0)
- AngleSharp.Css (>= 1.0.0-beta.216)
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.14)
- OfficeIMO.Word (>= 1.0.60)
-
net10.0
- AngleSharp (>= 1.4.0)
- AngleSharp.Css (>= 1.0.0-beta.216)
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.14)
- OfficeIMO.Word (>= 1.0.60)
-
net8.0
- AngleSharp (>= 1.4.0)
- AngleSharp.Css (>= 1.0.0-beta.216)
- DocumentFormat.OpenXml (>= 3.5.1 && < 4.0.0)
- OfficeIMO.Drawing (>= 1.0.14)
- OfficeIMO.Word (>= 1.0.60)
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
PowerShell Module to create and edit Microsoft Word, Microsoft Excel, and Microsoft PowerPoint documents without having Microsoft Office installed.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.34 | 51 | 6/5/2026 |
| 1.0.33 | 490 | 5/27/2026 |
| 1.0.32 | 484 | 5/26/2026 |
| 1.0.31 | 398 | 5/26/2026 |
| 1.0.30 | 483 | 5/23/2026 |
| 1.0.29 | 424 | 5/22/2026 |
| 1.0.28 | 403 | 5/21/2026 |
| 1.0.27 | 387 | 5/21/2026 |
| 1.0.26 | 421 | 5/20/2026 |
| 1.0.25 | 405 | 5/19/2026 |
| 1.0.24 | 386 | 5/18/2026 |
| 1.0.23 | 631 | 5/16/2026 |
| 1.0.22 | 374 | 5/14/2026 |
| 1.0.21 | 585 | 5/14/2026 |
| 1.0.20 | 613 | 5/7/2026 |
| 1.0.19 | 531 | 5/1/2026 |
| 1.0.18 | 403 | 4/27/2026 |
| 1.0.17 | 683 | 4/10/2026 |
| 1.0.16 | 139 | 4/9/2026 |
| 1.0.15 | 373 | 4/3/2026 |