Class FontResolver
Inheritance
System.Object
FontResolver
Assembly: IronPdf.dll
Syntax
public abstract class FontResolver : Object
Font handling during PDF-to-SVG conversion is governed by a FontResolver, the policy object that decides how each typeface embedded in a source PDF is represented in the output SVG. Choosing the right resolver controls file size, offline rendering fidelity, and cross-platform text accuracy without touching any other part of the conversion pipeline.
Four built-in resolvers cover the most common scenarios. FontResolver.Default applies a balanced strategy suited to general-purpose conversion. FontResolver.EmbedOpenType encodes each font as a base64 OpenType data URI inside the SVG, making the file self-contained and portable at the cost of a larger payload. FontResolver.EmbedWoff does the same with WOFF encoding, which compresses better and is the preferred choice when the SVG will be displayed in a browser. FontResolver.LocalFonts emits CSS local() references instead of embedding data, keeping the SVG compact but requiring that the same fonts are installed on every machine that renders the file.
Pass a resolver to the conversion options when converting a PDF with IronPDF. The resolver is consulted once per distinct SourceFont encountered in the document. ResolveFont returns a synchronous Font decision, while ResolveFontAsync is the awaitable overload for pipelines that must stay non-blocking, both accepting a CancellationToken for cooperative cancellation.
Custom font strategies are possible by subclassing FontResolver (the constructor is protected) and overriding ResolveFont or ResolveFontAsync. A custom resolver can, for example, substitute a licensed typeface, strip a font entirely, or fetch a font from a remote asset store.
using PdfToSvg;
// Embed fonts as WOFF for browser-friendly, self-contained SVG output
var options = new ConversionOptions
{
FontResolver = FontResolver.EmbedWoff
};
using var pdf = PdfDocument.FromFile("report.pdf");
string svg = pdf.Pages[0].ToSvgString(options);
File.WriteAllText("report.svg", svg);
The IronPDF get-started guide covers initial setup, the PDF-to-SVG how-to explains the full conversion workflow, and the font handling example demonstrates each resolver side by side.
Constructors
FontResolver()
Declaration
Properties
Default
Declaration
public static FontResolver Default { get; }
Property Value
EmbedOpenType
Declaration
public static FontResolver EmbedOpenType { get; }
Property Value
EmbedWoff
Declaration
public static FontResolver EmbedWoff { get; }
Property Value
LocalFonts
Declaration
public static FontResolver LocalFonts { get; }
Property Value
Methods
ResolveFont(SourceFont, CancellationToken)
Declaration
public virtual Font ResolveFont(SourceFont sourceFont, CancellationToken cancellationToken)
Parameters
| Type |
Name |
Description |
| SourceFont |
sourceFont |
|
| System.Threading.CancellationToken |
cancellationToken |
|
Returns
ResolveFontAsync(SourceFont, CancellationToken)
Declaration
public virtual Task<Font> ResolveFontAsync(SourceFont sourceFont, CancellationToken cancellationToken)
Parameters
| Type |
Name |
Description |
| SourceFont |
sourceFont |
|
| System.Threading.CancellationToken |
cancellationToken |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<Font> |
|