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.IDocumentFontObject
    IronSoftware.IDocumentObject
    Namespace: IronPdf.Fonts
    Assembly: IronPdf.dll
    Syntax
    public class PdfFont : Object, IDocumentFontObject, IDocumentObject

    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.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.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.IDocumentFontObject
    IronSoftware.IDocumentObject
    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronPDF to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronPDF free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.