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
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
CachePolicy
Per-document and process-level cache policy.
public CachePolicy CachePolicy { get; init; }
Property Value
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
Creator
Document /Creator metadata — the authoring application. When set, emitted verbatim.
public string? Creator { get; init; }
Property Value
Diagnostics
Receives diagnostics live during conversion. Aggregated diagnostics are also available via ConvertDetailed(string, HtmlPdfOptions?).
public IDiagnosticsSink? Diagnostics { get; init; }
Property Value
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
EmittedPdfVersion
The PDF version emitted in the file header. Defaults to 1.7 for compatibility.
public PdfVersion EmittedPdfVersion { get; init; }
Property Value
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
Features
Opt-in feature flags.
public FeatureFlags Features { get; init; }
Property Value
FontResolver
Resolves font queries to font face data. When unset, system fonts are enumerated.
public IFontResolver? FontResolver { get; init; }
Property Value
Keywords
Document /Keywords metadata. When set, overrides <meta name="keywords">.
public string? Keywords { get; init; }
Property Value
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
Margins
The default page margins when CSS does not specify them.
public PageMargins Margins { get; init; }
Property Value
MediaType
Which stylesheet block applies. Default is Print because PDF is paged output.
public CssMediaType MediaType { get; init; }
Property Value
ModDate
Document modification timestamp emitted as /ModDate. null (the
default) omits it. Same determinism rule as CreationDate.
public DateTimeOffset? ModDate { get; init; }
Property Value
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
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
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
PageSize
The default page size when CSS does not specify one via @page { size: ... }.
public PageSize PageSize { get; init; }
Property Value
PreferCssPageSize
When true, an @page { size: ... } declaration in CSS overrides
PageSize. When false, PageSize always wins.
public bool PreferCssPageSize { get; init; }
Property Value
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
ResourceLoader
Resolves images / fonts / stylesheets referenced via URL.
public IResourceLoader? ResourceLoader { get; init; }
Property Value
SecurityPolicy
Per-URI fetch policy. Defaults to data-URI-only.
public SecurityPolicy SecurityPolicy { get; init; }
Property Value
Subject
Document /Subject metadata. When set, overrides <meta name="description">.
public string? Subject { get; init; }
Property Value
Timeout
Hard cap on conversion time. null = no cap.
public TimeSpan? Timeout { get; init; }
Property Value
Title
Document /Title metadata. When set, overrides the HTML <title>.
public string? Title { get; init; }