Skip to content

HtmlConverterOptions class

View as Markdown

Namespace: PdfNetStack.Html
Assembly: PdfNetStack.Html.dll
Package: PdfNetStack.Html

Settings for HtmlConverter.

public sealed class HtmlConverterOptions

Inheritance

object ← HtmlConverterOptions

The address relative URLs resolve against: a file path’s URI such as new Uri(@“C:\reports”), or a web address when ResourceLoader fetches from the network. Null when the HTML only uses absolute URLs or data: URIs.

public Uri? BaseUri { get; init; }

Uri?

Headings become bookmarks (the bookmark-level property). Default true.

public bool Bookmarks { get; init; }

bool

Fonts to use before installed ones, matched by family name, width, style and weight.

public PdfFontCollection? Fonts { get; init; }

PdfFontCollection?

Finds the hyphenator for a language tag, or null when there is none, for text with hyphens: auto; its language is the nearest lang attribute, and text without one is not hyphenated, as CSS Text 3 says. Called once per tag in a conversion. PdfHyphenationPatterns.ForLanguage from the PdfNetStack.Hyphenation package fits here. Null, the default, treats hyphens: auto like manual: words break only at soft hyphens.

public Func<string, PdfHyphenator?>? Hyphenators { get; init; }

Func<string, PdfHyphenator?>?

The most pages a conversion may produce. Default 10000. A document that needs more, such as one whose sizes run to kilometres, ends with HtmlConversionException instead of using memory without bound.

public int MaxPages { get; init; }

int

ArgumentOutOfRangeException

The value is less than 1.

The page size and margins before the document’s @page rules, as CSS. Default size: A4; margin: 2cm.

public string PageStyle { get; init; }

string

Fetches style sheets, images and fonts by absolute URL; return null for anything that should not load. Without a loader only data: URIs and files under BaseUri load, and nothing comes from the network: keep it that way for untrusted HTML, or check each address before fetching it.

public Func<Uri, byte[]?>? ResourceLoader { get; init; }

Func<Uri, byte[]?>?

How ConvertToPdf saves the document, such as a PDF/A conformance level. Null, the default, saves as Default does but without the optimizer’s equivalence proof (VerifyOptimization false): the converter draws all the content itself, and the bytes are the same whenever the proof would pass. Set Default to keep the proof.

public PdfSaveOptions? SaveOptions { get; init; }

PdfSaveOptions?

A style sheet applied before the document’s own, for house styles.

public string? StyleSheet { get; init; }

string?

Writes a tagged PDF (ISO 32000-1, 14.8): headings, paragraphs, lists, tables, figures with their alt text and links in a structure tree, in reading order, with backgrounds, borders, repeated headers and page margins marked as artifacts, so screen readers and reflow work. Default true.

public bool Tagged { get; init; }

bool

Whether installed fonts are used, for families the HTML names and as fallbacks for characters such as Arabic. Default true. With false, output depends only on the HTML, the supplied fonts and the standard 14 fonts, and is the same on every machine.

public bool UseSystemFonts { get; init; }

bool