Search Results for

    Show / Hide Table of Contents

    Class PdfFont

    Font info which describes the data structure of font referenced inside a PDF document.

    Inheritance
    System.Object
    PdfFont
    Implements
    IronSoftware.Abstractions.Pdf.IDocumentFontObject
    IronSoftware.Abstractions.IFont
    IronSoftware.Abstractions.IDocumentObject
    IronSoftware.Abstractions.Pdf.IPdfDocumentObject
    Namespace: IronPdf.Fonts
    Assembly: IronPdf.dll
    Syntax
    public class PdfFont : Object, IDocumentFontObject, IFont, IDocumentObject, IPdfDocumentObject

    Constructors

    PdfFont(StandardFont)

    Create a font object from standard font enumeration.

    Declaration
    public PdfFont(StandardFont font)
    Parameters
    Type Name Description
    StandardFont font

    StandardFont enumeration. If the standard font resolution fails, then System.ArgumentException is thrown.

    PdfFont(FontTypes)

    Create a font object from IronSoftware.Drawing.FontTypes.

    Declaration
    public PdfFont(FontTypes font)
    Parameters
    Type Name Description
    IronSoftware.Drawing.FontTypes font

    IronSoftware.Drawing.FontTypes represents one of standard fonts of PDF document

    PdfFont(IPdfClient, IDocumentId, UInt32, Boolean, Boolean, String, FontType, UInt32)

    Construct a FontInfo from all the specified arguments.

    Declaration
    public PdfFont(IPdfClient client, IDocumentId id, uint obj_num, bool is_embedded, bool is_subsetted, string name, FontType type, uint descendantFontObjNum = 0U)
    Parameters
    Type Name Description
    IronSoftware.Pdfium.IPdfClient client

    Pdf client

    IronSoftware.Abstractions.Pdf.IDocumentId id

    Document identifier

    System.UInt32 obj_num

    Object number representing the font object for use within PDF document

    System.Boolean is_embedded

    True if this font is embedded, otherwise false.

    System.Boolean is_subsetted
    System.String name

    Name of the font

    FontType type

    Type of the font. See FontType.

    System.UInt32 descendantFontObjNum

    (Optional) Descendant object number. Default is 0.

    PdfFont(String)

    Create a font object from a standard font string.

    Declaration
    public PdfFont(string StandardFont)
    Parameters
    Type Name Description
    System.String StandardFont

    One of 14 standard fonts which are guaranteed to be available and known within PDF document. If specified font cannot be resolved as one of the standard fonts, then System.ArgumentException is thrown.

    Properties

    DescendantFontObjNum

    Object number which represents a descendant font; a direct child font object from a composite font.

    If its value is greater than 0, then the parent font is a composite font, and the value itself represent an actual descedant font (CIDFont) thus it can be either CIDFontType0, or CIDFontType2. Otherwise, value is 0 which means it is a simple font.

    Declaration
    public uint DescendantFontObjNum { get; }
    Property Value
    Type Description
    System.UInt32

    DocumentId

    Declaration
    public IDocumentId DocumentId { get; set; }
    Property Value
    Type Description
    IronSoftware.Abstractions.Pdf.IDocumentId

    FontData

    Declaration
    public byte[] FontData { get; set; }
    Property Value
    Type Description
    System.Byte[]

    FontSize

    Declaration
    public float FontSize { get; set; }
    Property Value
    Type Description
    System.Single

    IsEmbedded

    Declaration
    public bool IsEmbedded { get; }
    Property Value
    Type Description
    System.Boolean

    IsSubsetted

    Declaration
    public bool IsSubsetted { get; }
    Property Value
    Type Description
    System.Boolean

    Name

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    ObjNum

    Declaration
    public uint ObjNum { get; set; }
    Property Value
    Type Description
    System.UInt32

    PageIndex

    Declaration
    public uint PageIndex { get; set; }
    Property Value
    Type Description
    System.UInt32

    Type

    Font type

    Declaration
    public FontType Type { get; }
    Property Value
    Type Description
    FontType
    See Also
    FontType

    Methods

    Embed(Byte[])

    Embed all font file data for this font into the current document

    Declaration
    public void Embed(byte[] Data = null)
    Parameters
    Type Name Description
    System.Byte[] Data
    Exceptions
    Type Condition
    System.Exception

    Font is not currently part of a document

    IsValidStandardFont(String)

    Determines whether the specified font name is a valid standard font.

    Declaration
    public static bool IsValidStandardFont(string fontName)
    Parameters
    Type Name Description
    System.String fontName

    The name of the font to validate.

    Returns
    Type Description
    System.Boolean

    true if the font name corresponds to a valid standard font; otherwise, false.

    ReplaceWith(Byte[])

    Replace instances of this font with the specified custom font file

    Declaration
    public PdfFont ReplaceWith(byte[] FontData)
    Parameters
    Type Name Description
    System.Byte[] FontData

    Custom font file data

    Returns
    Type Description
    PdfFont

    ReplaceWith(String)

    Replace instances of this font with the specified standard font name

    Declaration
    public PdfFont ReplaceWith(string FontName)
    Parameters
    Type Name Description
    System.String FontName

    Standard font name

    Returns
    Type Description
    PdfFont

    ToString()

    Return a string representation of this object.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    String representation of the object

    Unembed()

    Unembed all font file data for this font from the current document

    Declaration
    public void Unembed()
    Remarks

    WARNING: Unembedding a font may cause text objects in the PDF that use this font to display incorrectly or not render at all. Ensure that unembedding is appropriate for the use case before proceeding.

    Exceptions
    Type Condition
    System.Exception

    Font is not currently part of a document

    Operators

    Implicit(PdfFont to FontTypes)

    Implicitly convert from PdfFont to IronSoftware.Drawing.FontTypes.

    If internally it has invalid state prior to conversion, it will throw an exception System.InvalidOperationException.

    Declaration
    public static implicit operator FontTypes(PdfFont src)
    Parameters
    Type Name Description
    PdfFont src
    Returns
    Type Description
    IronSoftware.Drawing.FontTypes

    Implicit(FontTypes to PdfFont)

    Implicitly convert from IronSoftware.Drawing.FontTypes to PdfFont.

    Declaration
    public static implicit operator PdfFont(FontTypes src)
    Parameters
    Type Name Description
    IronSoftware.Drawing.FontTypes src
    Returns
    Type Description
    PdfFont

    Implements

    IronSoftware.Abstractions.Pdf.IDocumentFontObject
    IronSoftware.Abstractions.IFont
    IronSoftware.Abstractions.IDocumentObject
    IronSoftware.Abstractions.Pdf.IPdfDocumentObject
    ☀
    ☾
    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