Table of Contents

Class HtmlPdfOptions

Namespace
NetPdf
Assembly
NetPdf.dll

All options that control conversion. The default-constructed instance produces sensible behavior for a US Letter / A4 print document with print media stylesheets, backgrounds on, and exact colors honored.

public sealed class HtmlPdfOptions
Inheritance
HtmlPdfOptions
Inherited Members

Properties

Author

Document /Author metadata. When set, overrides <meta name="author">.

public string? Author { get; init; }

Property Value

string

BaseUri

Base URI used to resolve relative URLs in the input HTML — <img src="logo.png">, @font-face src: url("font.woff"), etc. When unset, only absolute URIs and data: URIs are resolvable.

public Uri? BaseUri { get; init; }

Property Value

Uri

CachePolicy

Per-document and process-level cache policy.

public CachePolicy CachePolicy { get; init; }

Property Value

CachePolicy

CreationDate

Document creation timestamp emitted as /CreationDate (and in XMP). null (the default) omits it entirely — the deterministic default, since no wall-clock time is ever read. Set an explicit value when a real (or fixed) timestamp is wanted.

public DateTimeOffset? CreationDate { get; init; }

Property Value

DateTimeOffset?

Creator

Document /Creator metadata — the authoring application. When set, emitted verbatim.

public string? Creator { get; init; }

Property Value

string

Diagnostics

Receives diagnostics live during conversion. Aggregated diagnostics are also available via ConvertDetailed(string, HtmlPdfOptions?).

public IDiagnosticsSink? Diagnostics { get; init; }

Property Value

IDiagnosticsSink

DocumentProperties

Custom document-information entries emitted as extra keys in the PDF /Info dictionary (beyond the standard Title/Author/Subject/Keywords/Creator). Keys must be non-empty and are matched case-sensitively; the standard keys and Producer cannot be overridden here. null or empty = none.

public IReadOnlyDictionary<string, string>? DocumentProperties { get; init; }

Property Value

IReadOnlyDictionary<string, string>

EmittedPdfVersion

The PDF version emitted in the file header. Defaults to 1.7 for compatibility.

public PdfVersion EmittedPdfVersion { get; init; }

Property Value

PdfVersion

ExactColors

When true, colors are reproduced exactly without a "color-adjust" override. Equivalent to print-color-adjust: exact on the root.

public bool ExactColors { get; init; }

Property Value

bool

Features

Opt-in feature flags.

public FeatureFlags Features { get; init; }

Property Value

FeatureFlags

FontResolver

Resolves font queries to font face data. When unset, system fonts are enumerated.

public IFontResolver? FontResolver { get; init; }

Property Value

IFontResolver

Keywords

Document /Keywords metadata. When set, overrides <meta name="keywords">.

public string? Keywords { get; init; }

Property Value

string

Language

Document language tag (BCP-47), used for the catalog /Lang and XMP metadata. The HTML root <html lang> attribute takes precedence when present; this is the fallback. null (the default) means "not declared" — no /Lang is manufactured, so a document that declares no language is not presumed to be English.

public string? Language { get; init; }

Property Value

string

Margins

The default page margins when CSS does not specify them.

public PageMargins Margins { get; init; }

Property Value

PageMargins

MediaType

Which stylesheet block applies. Default is Print because PDF is paged output.

public CssMediaType MediaType { get; init; }

Property Value

CssMediaType

ModDate

Document modification timestamp emitted as /ModDate. null (the default) omits it. Same determinism rule as CreationDate.

public DateTimeOffset? ModDate { get; init; }

Property Value

DateTimeOffset?

NativeSvgRendering

Phase 4 native vector SVG (opt-in, first cut). When true, an <img> whose source is SVG is drawn as native PDF vector operators (crisp at any zoom) IF the whole document is within the supported subset (basic shapes + <path>, <g>, element transforms, solid fill/stroke, fill-rule, root viewBox/preserveAspectRatio); otherwise it falls back to the raster path. Default false → SVG always rasterizes, so output is byte-identical to before. The native path uses the SVG's own preserveAspectRatio (meet), so it doesn't apply object-fit: fill stretching.

public bool NativeSvgRendering { get; init; }

Property Value

bool

PageLayout

The page layout a reader uses when it first opens the document (catalog /PageLayout). null (the default) omits the entry, leaving the reader's own default.

public PdfPageLayout? PageLayout { get; init; }

Property Value

PdfPageLayout?

PageMode

How a reader presents its navigation UI when the document opens (catalog /PageMode) — e.g. UseOutlines opens the bookmarks panel. null (the default) omits the entry, leaving the reader's own default.

public PdfPageMode? PageMode { get; init; }

Property Value

PdfPageMode?

PageSize

The default page size when CSS does not specify one via @page { size: ... }.

public PageSize PageSize { get; init; }

Property Value

PageSize

PreferCssPageSize

When true, an @page { size: ... } declaration in CSS overrides PageSize. When false, PageSize always wins.

public bool PreferCssPageSize { get; init; }

Property Value

bool

PrintBackgrounds

When true, element backgrounds are painted into the PDF — the equivalent of the browser print dialog's "Background graphics" checkbox.

public bool PrintBackgrounds { get; init; }

Property Value

bool

ResourceLoader

Resolves images / fonts / stylesheets referenced via URL.

public IResourceLoader? ResourceLoader { get; init; }

Property Value

IResourceLoader

SecurityPolicy

Per-URI fetch policy. Defaults to data-URI-only.

public SecurityPolicy SecurityPolicy { get; init; }

Property Value

SecurityPolicy

Subject

Document /Subject metadata. When set, overrides <meta name="description">.

public string? Subject { get; init; }

Property Value

string

Timeout

Hard cap on conversion time. null = no cap.

public TimeSpan? Timeout { get; init; }

Property Value

TimeSpan?

Title

Document /Title metadata. When set, overrides the HTML <title>.

public string? Title { get; init; }

Property Value

string