API Reference
HtmlToWordOptions
Options controlling HTML to Word conversion.
Inheritance
- Object
- HtmlToWordOptions
Usage
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by
Accepted by parameters
- Method WordHtmlConverterExtensions.AddHtml
- Method WordHtmlConverterExtensions.AddHtmlAsync
- Method WordHtmlConverterExtensions.AddHtmlToBody
- Method WordHtmlConverterExtensions.AddHtmlToBodyAsync
- Method WordHtmlConverterExtensions.AddHtmlToFooter
- Method WordHtmlConverterExtensions.AddHtmlToFooterAsync
- Method WordHtmlConverterExtensions.AddHtmlToHeader
- Method WordHtmlConverterExtensions.AddHtmlToHeaderAsync
- Method WordHtmlConverterExtensions.ToWordDocument
- Method WordHtmlConverterExtensions.ToWordDocumentAsync
- Method WordHtmlConverterExtensions.ToWordDocumentResult
- Method WordHtmlConverterExtensions.ToWordDocumentResultAsync
Constructors
public HtmlToWordOptions() #Methods
public HtmlToWordOptions Clone() #HtmlToWordOptionsCreates a copy of the current options instance so callers can reuse option templates safely.
Returns
A new HtmlToWordOptions with the same configuration values.
public static HtmlToWordOptions CreateOfficeIMOProfile() #HtmlToWordOptionsCreates the default OfficeIMO HTML import profile.
Returns
A new HtmlToWordOptions instance with the default compatibility-oriented settings.
public static HtmlToWordOptions CreateTrustedDocumentProfile() #HtmlToWordOptionsCreates a profile for trusted HTML documents whose own linked stylesheets may be loaded.
Returns
A new HtmlToWordOptions instance configured for trusted document links.
public static HtmlToWordOptions CreateUntrustedHtmlProfile() #HtmlToWordOptionsCreates a bounded offline profile for untrusted HTML ingestion.
Returns
A new HtmlToWordOptions instance configured for untrusted HTML.
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public String FontFamily { get; set; } #Optional font family applied to created runs during conversion.
public String QuotePrefix { get; set; } #Character inserted before inline quoted text. Defaults to left double quotation mark.
public String QuoteSuffix { get; set; } #Character inserted after inline quoted text. Defaults to right double quotation mark.
public Nullable<WordPageSize> DefaultPageSize { get; set; } #Optional default page size applied when creating new documents.
public Nullable<OfficePageOrientation> DefaultOrientation { get; set; } #Optional default page orientation applied when creating new documents.
public Dictionary<String, WordParagraphStyles> ClassStyles { get; } #Maps HTML class names to paragraph styles. Example: ClassStyles["title"] = WordParagraphStyles.Heading1;
public Boolean IncludeListStyles { get; set; } #When true, attempts to include list styling information during conversion.
public Boolean ContinueNumbering { get; set; } #When true, numbered lists will continue numbering across separate lists.
public Boolean SupportsHeadingNumbering { get; set; } #When true, heading elements are converted into a numbered list using Headings111 so headings receive automatic numbering.
public String BasePath { get; set; } #Base directory used to resolve relative resource paths like images.
public NoteReferenceType NoteReferenceType { get; set; } #Controls whether HTML-generated notes are inserted as footnotes or endnotes.
public Boolean LinkNoteUrls { get; set; } #When true, URLs used as note text are emitted as hyperlinks inside the note.
public HtmlUrlPolicy HyperlinkUrlPolicy { get; set; } #Shared URL policy applied before imported HTML anchors are materialized as Word hyperlinks.
public HtmlUrlPolicy ResourceUrlPolicy { get; set; } #Shared URL policy applied before imported image resources are resolved or materialized.
public ImageProcessingMode ImageProcessing { get; set; } #Controls how images are processed during conversion.
public HttpClient HttpClient { get; set; } #Optional HttpClient used to download remote resources (images, SVG). If not provided, a shared client instance is used.
public Nullable<TimeSpan> ResourceTimeout { get; set; } #Optional timeout applied when downloading remote resources.
public Int32 MaxConcurrentResourceLoads { get; set; } #Maximum number of remote image requests that may be in flight during asynchronous import. Defaults to 8. Imports with a total image byte budget remain sequential so the converter can reject a response before reading its body when the remaining budget is too small.
public HtmlTextBackgroundMode TextBackgroundMode { get; set; } #Controls how CSS text background colors are represented in Word. Exact run shading is used by default so arbitrary CSS colors round-trip without palette loss.
public Nullable<Int64> MaxImageBytes { get; set; } #Optional maximum number of bytes allowed for a single image resource, including SVG images. When exceeded, the image is skipped, alt text is inserted when available, and a diagnostic is emitted.
public Nullable<Int64> MaxTotalImageBytes { get; set; } #Optional maximum number of image bytes allowed across a single HTML import operation, including SVG images. When exceeded, the image that crosses the budget is skipped, alt text is inserted when available, and a diagnostic is emitted.
public Nullable<Int32> MaxRemoteImageCandidateProbes { get; set; } #Optional maximum number of remote image candidates probed while selecting a source for one HTML image element. Defaults to one probe to avoid request fan-out from large srcset or picture candidate lists. Set to null to restore unbounded probing for trusted HTML.
public Nullable<Int32> MaxImageSourceCandidates { get; set; } #Optional maximum number of responsive image candidates considered from picture and srcset inputs per image element. The direct img src fallback is still considered after this limit. Defaults to 32 candidates. Set to null to restore unbounded candidate expansion for trusted HTML.
public Boolean ValidateImageContentTypes { get; set; } #When true, validates declared image content types for remote image resources and data URI images. Images with rejected content types are skipped, alt text is inserted when available, and a diagnostic is emitted.
public HashSet<String> AllowedImageContentTypes { get; } #Declared image media types allowed when ValidateImageContentTypes is enabled. Add image/* to allow any declared image media type.
public HashSet<String> AllowedImageUriSchemes { get; } #Image URI schemes allowed during import. Defaults allow HTTP, HTTPS, and data URI images. Remote image embedding still requires Embed through an explicit option or compatibility profile. Add UriSchemeFile or use CreateTrustedDocumentProfile for trusted local-file images. Remove entries to reject matching image sources before they are loaded or linked.
public HashSet<String> AllowedImageHosts { get; } #Optional host allow-list for absolute non-file image URIs. When empty, all hosts are allowed.
public HashSet<String> AllowedStylesheetUriSchemes { get; } #Stylesheet URI schemes allowed during import. Defaults allow HTTP, HTTPS, and file-based stylesheets. Remove entries to reject matching stylesheet sources before they are loaded.
public HashSet<String> AllowedStylesheetHosts { get; } #Optional host allow-list for absolute non-file stylesheet URIs. When empty, all hosts are allowed.
public Boolean ValidateStylesheetContentTypes { get; set; } #When true, validates declared content types for remote stylesheet resources. Stylesheets with rejected content types are skipped and a diagnostic is emitted.
public HashSet<String> AllowedStylesheetContentTypes { get; } #Declared stylesheet media types allowed when ValidateStylesheetContentTypes is enabled.
public Nullable<Int32> MaxHtmlNodes { get; set; } #Optional maximum number of parsed HTML nodes allowed for a conversion operation. When exceeded, conversion stops with HtmlConversionLimitException and an error diagnostic.
public Nullable<Int32> MaxHtmlDepth { get; set; } #Optional maximum parsed HTML tree depth allowed for a conversion operation. When exceeded, conversion stops with HtmlConversionLimitException and an error diagnostic.
public Nullable<Int64> MaxCssBytes { get; set; } #Optional maximum UTF-8 byte count allowed for each stylesheet before parsing. When exceeded, conversion stops with HtmlConversionLimitException and an error diagnostic.
public Nullable<Int64> MaxTotalCssBytes { get; set; } #Optional maximum UTF-8 byte count allowed across all stylesheets in a single import operation. When exceeded, conversion stops with HtmlConversionLimitException and an error diagnostic.
public HtmlConversionLimits Limits { get; set; } #Shared HTML parsing and CSS limits used by the core engine and Word adapter.
public Nullable<Int64> MaxTableCells { get; set; } #Optional maximum number of Word table cells allowed for a single imported HTML table. Defaults to 50,000 cells. Spans are resolved before the limit is checked. When exceeded, conversion stops with HtmlConversionLimitException and an error diagnostic.
public Action<StyleMissingEventArgs> StyleMissingHandler { get; set; } #Optional conversion-scoped resolver for CSS classes without a built-in Word style mapping. This avoids global event state when conversions run concurrently.
public Boolean EnableAccessibilityDiagnostics { get; set; } #When true, emits advisory accessibility diagnostics for imported HTML patterns that can reduce document usability, such as missing image alternate text, weak link text, skipped heading levels, and data tables without header cells.
public Boolean ImportHtmlComments { get; set; } #When true, raw HTML comment nodes are imported as native Word comments anchored at their DOM position. Empty comments are skipped. Existing exported OfficeIMO comment sections are always imported through their linked comment references.
public Boolean ImportEditableLayoutRegions { get; set; } #When true, bounded positioned and floating HTML regions are retained as editable page-anchored text boxes. Browser-only layouts that do not have one stable native box remain in semantic flow with diagnostics.
public String HtmlCommentAuthor { get; set; } #Author name used for native Word comments created from raw HTML comment nodes.
public String HtmlCommentInitials { get; set; } #Author initials used for native Word comments created from raw HTML comment nodes.
public HtmlUnsupportedCssHandling UnsupportedCssHandling { get; set; } #Controls how unsupported CSS properties and values are handled during import. Defaults to warning diagnostics while preserving best-effort conversion.
public List<String> StylesheetPaths { get; } #File paths pointing to external stylesheets that should be applied during conversion.
public List<String> StylesheetContents { get; } #Raw CSS stylesheet contents that should be applied during conversion.
public Boolean AllowDocumentStylesheetLinks { get; set; } #When true, stylesheet links declared in the imported HTML document are loaded. Keep this disabled for untrusted HTML and prefer StylesheetPaths or StylesheetContents for caller-provided stylesheets.
public Boolean RenderPreAsTable { get; set; } #When true, <pre> elements are rendered inside a single-cell table.
public TableCaptionPosition TableCaptionPosition { get; set; } #Specifies where table captions should be inserted relative to the table.
public SectionTagHandling SectionTagHandling { get; set; } #Controls how the <section> tag is mapped into Word.