Class SourceFont
Inheritance
Namespace: PdfToSvg
Assembly: IronPdf.dll
Syntax
public abstract class SourceFont : Object
A font resource extracted from a PDF during SVG conversion is represented as a SourceFont object. When IronPDF renders a PDF page to SVG, every typeface encountered in that page is surfaced through a SourceFont so that downstream code can decide how to handle it: embed the raw bytes, inline the data as a web font, or skip fonts that belong to the PDF standard set.
SourceFont is an abstract base class in the PdfToSvg namespace. Concrete subtypes are produced internally by the conversion pipeline; you do not construct them directly (the constructor is protected). Instead, you receive instances through the SVG conversion API and interrogate them through the properties and methods declared here.
Three boolean properties describe what a given font supports. CanBeExtracted reports whether the underlying font data can be retrieved at all; some fonts in a PDF are partially embedded or restricted, making extraction impossible. CanBeInlined indicates whether the font can be encoded directly into the SVG output as a data URI, which is useful for fully self-contained SVG files. IsStandardFont identifies the 14 PDF standard fonts (Times, Helvetica, Courier, and their variants) that do not carry embedded data because PDF viewers are expected to supply them natively.
The Name property returns the PostScript name of the font as it appears in the PDF. Two conversion methods cover the most common web-font formats: ToOpenType() returns the font bytes as an OpenType (.otf) binary, and ToWoff() returns the same data repackaged as a WOFF file ready for a CSS @font-face rule. Both methods return a byte[], so you can write the result to disk, embed it in a stream, or encode it to Base64 for inlining.
A typical workflow checks CanBeExtracted before calling either conversion method, then branches on IsStandardFont to decide whether embedding is necessary at all.
using PdfToSvg;
using System.IO;
// svgConversion supplies SourceFont instances during PDF-to-SVG rendering
void HandleFont(SourceFont font, string outputDir)
{
if (font.IsStandardFont || !font.CanBeExtracted)
return;
string path = Path.Combine(outputDir, font.Name + ".woff");
File.WriteAllBytes(path, font.ToWoff());
}For background on PDF-to-SVG conversion in IronPDF, see the PDF to SVG how-to, the IronPDF get-started guide, and the font handling examples.
Constructors
SourceFont()
Declaration
protected SourceFont()
Properties
CanBeExtracted
Declaration
public virtual bool CanBeExtracted { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
CanBeInlined
Declaration
public virtual bool CanBeInlined { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsStandardFont
Declaration
public virtual bool IsStandardFont { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Name
Declaration
public abstract string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
ToOpenType()
Declaration
public abstract byte[] ToOpenType()
Returns
| Type | Description |
|---|---|
| System.Byte[] |
ToWoff()
Declaration
public abstract byte[] ToWoff()
Returns
| Type | Description |
|---|---|
| System.Byte[] |