Search Results for

    Show / Hide Table of Contents

    Class SourceFont

    Inheritance
    System.Object
    SourceFont
    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[]
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    IronPDF_for_dotnet_log2o
    Blue key in circleGet started for FREE
    No credit card required
    Test in a live environment

    Test in production without watermarks.
    Works wherever you need it to.

    Fully-functional product

    Get 30 days of fully functional product.
    Have it up and running in minutes.

    24/5 technical support

    Full access to our support engineering team during your product trial

    Grey key in circleGet started for FREE
    The trial form was submitted successfully.
    Calendar in circleBook Free Live Demo
    No contact, no card details, no commitments Book a 30-minute, personal demo.
    Here's what to expect:

    A live demo of our product and its key features

    Get project specific feature recommendations

    All your questions are answered to make sure you have all the information you need. (No commitment whatsoever.)

    Grey key in circleBook Free Live Demo
    Your booking has been completed Check your e-mail for confirmation
    Support Team Member 6 related to The C# PDF Library Support Team Member 14 related to The C# PDF Library Support Team Member 4 related to The C# PDF Library Support Team Member 2 related to The C# PDF Library
    Online 24/5
    Need help? Our sales team would be glad to help you.
    Try the Enterprise Trial
    ironpdf_for_dotnet_log2o
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    bullet_checkedNo credit card or account creation required
    Key in blue circle
    Get your free 30-day Trial Key instantly.
    Blue key in circleNo credit card or account creation required
    Green Check in orange circle
    The trial form was submitted successfully.
    badge_greencheck_in_yellowcircle
    Thank you for starting a trial

    Please check your email for the trial license key.

    If you don’t receive an email, please start a live chat or email support@ironsoftware.com

    Install with NuGet
    View Licensing
    • Logo Aetna
    • Logo NASA
    • Logo GE
    • Logo Porsche
    • Logo USDA
    • Logo Qatar
    Join Millions of Engineers who’ve tried IronPDF