Class SvgLoadOptions
How SvgDocument reads a file: what it may fetch, how strict it is, and which limits and diagnostics apply.
public sealed record SvgLoadOptions : IEquatable<SvgLoadOptions>
- Inheritance
-
SvgLoadOptions
- Implements
- Inherited Members
Examples
// Images, style sheets and fonts the file refers to open only through a resolver; data: URIs always work.
var options = new SvgLoadOptions
{
Resolver = SvgResolvers.SameDirectory(folder),
Dpi = 96,
Context = EgamiContext.Default with { Limits = SafetyLimits.Default with { MaxTotalBytes = 64L << 20 } },
};
SvgDocument document = SvgDocument.Parse(Icon, options);
Properties
BaseUri
Gets the URI relative references are resolved against, or null to use the file's own location when it was loaded from a path.
public Uri? BaseUri { get; init; }
Property Value
Context
Gets the context whose limits bound the load (file size, element count and nesting, entity expansion) and whose diagnostics receive what a lenient load skipped, or null for Default.
public EgamiContext? Context { get; init; }
Property Value
Default
Gets the defaults: nothing outside the file, lenient, 96 pixels per inch, the default context.
public static SvgLoadOptions Default { get; }
Property Value
Dpi
Gets the resolution that turns physical units (in, cm, mm, pt, pc) into pixels; 96 by default, as CSS defines.
public float Dpi { get; init; }
Property Value
Fonts
Gets where text finds its fonts; Default uses the installed fonts.
public SvgFontOptions Fonts { get; init; }
Property Value
Resolver
Gets the resolver that opens files the document refers to (images, style sheets, fonts, other SVG files), or
null, the default, to open nothing outside the file. data: URIs always work. It gets an absolute
URI (relative ones are resolved against BaseUri) and returns a stream it may own, or null
to refuse. Egami never opens a network connection itself; SvgResolvers has a ready resolver for files in
one folder.
public Func<Uri, Stream?>? Resolver { get; init; }
Property Value
Strict
Gets a value indicating whether anything a lenient load would skip (an attribute it cannot read, an element in error, a missing reference) throws an SvgException with its line and column instead. false by default, as browsers and resvg read SVG.
public bool Strict { get; init; }