PdfFonts Class
Provides enumeration support for PdfFontFamily and PdfFontFace objects.
- Inheritance:
- PdfFonts
Remarks
Custom font location is usually used in medium trust environments to bypass file system operations restrictions imposed for file locations that are not under the application's jurisdiction.
Properties
StandardFontFaces
Gets the collection of PdfFontFace objects that represent the PDF standard Type 1 fonts.
public static ICollection<PdfFontFace> StandardFontFaces { get; }
Public Shared ReadOnly Property StandardFontFaces As ICollection(Of PdfFontFace)
Property Value
An ICollection<T> of PdfFontFace objects that represent the PDF standard Type 1 fonts.
See Also
StandardFontFamilies
Gets the collection of PdfFontFamily objects that represent the PDF standard Type 1 fonts.
public static ICollection<PdfFontFamily> StandardFontFamilies { get; }
Public Shared ReadOnly Property StandardFontFamilies As ICollection(Of PdfFontFamily)
Property Value
An ICollection<T> of PdfFontFamily objects that represent the PDF standard Type 1 fonts.
See Also
SystemFontFaces
Gets the collection of PdfFontFace objects from the default system font location.
public static ICollection<PdfFontFace> SystemFontFaces { get; }
Public Shared ReadOnly Property SystemFontFaces As ICollection(Of PdfFontFace)
Property Value
An ICollection<T> of PdfFontFace objects that represent the fonts in the system fonts collection.
SystemFontFamilies
Gets the collection of PdfFontFamily objects from the default system font location.
public static ICollection<PdfFontFamily> SystemFontFamilies { get; }
Public Shared ReadOnly Property SystemFontFamilies As ICollection(Of PdfFontFamily)
Property Value
An ICollection<T> of PdfFontFamily objects that represent the fonts in the system fonts collection.
Methods
GetFontFaces(String)
Returns the collection of PdfFontFace objects from a string value that represents the location of the fonts.
public static ICollection<PdfFontFace> GetFontFaces(string location)
Public Shared Function GetFontFaces(location As String) As ICollection(Of PdfFontFace)
Parameters
location
- String
The location that contains the fonts.
Returns
An ICollection<T> of PdfFontFace objects that represent the fonts in location
.
Remarks
If location
is null or Empty, GetCurrentDirectory() is used.
If location
is relative, it is converted to absolute with GetFullPath(String) method.
If you are developing ASP.NET application, then use Server.MapPath(System.String) as the value of the location
parameter.
GetFontFaces(String, String)
Returns the collection of PdfFontFace objects embedded as resources in the specified assembly at the specified location.
Read the Remarks for details about the arguments of the GetFontFaces(String, String) method for desktop and web applications.
public static ICollection<PdfFontFace> GetFontFaces(string assemblyName, string location)
Public Shared Function GetFontFaces(assemblyName As String, location As String) As ICollection(Of PdfFontFace)
Parameters
assemblyName
- String
The name of the assembly that contains the fonts.
location
- String
The location of the fonts in the assembly.
Returns
An ICollection<T> of PdfFontFace objects embedded as resources in the specified assembly at the specified location.
Remarks
important
When you add fonts as resources to your application, make sure you are setting the <Resource> element when targeting .NET Framework or when targeting .NET Core with enabled WPF.
Otherwise, use <EmbeddedResource> element for the build action.
Also, make sure System.Windows.Application.ResourceAssembly is correctly initialized, if you want to format text that uses embedded fonts with WPF or WPFDisplay text formatting mode.
The following image shows an example of a Windows Console project structure with font files added as resources.

The Following table illustrates the various assemblyName
and location
values that you can specify to retrieve fonts from the above Windows Console project structure.
Retrieved font | assemblyName | location | Notes |
---|---|---|---|
Font1.ttf | null, Empty or "MyConsoleApplication" | null or Empty | Font resource files are in the root of the entry assembly. |
Font2.ttf | null, Empty or "MyConsoleApplication" | "MyFonts" | Font resource files are in the subfolder of the entry assembly. |
Font3.ttf | "MyClassLibrary" | null or Empty | Font resource files are in the root of the referenced assembly. |
Font4.ttf | "MyClassLibrary" | "MyFonts" | Font resource files are in the subfolder of the referenced assembly. |
The following image shows an example of a Web ASP.NET project structure with font files added as resources.

The following table illustrates the various assemblyName
and location
values that you can specify to retrieve fonts from the above Web ASP.NET project structure.
Since ASP.NET assembly is actually a class library referenced from ASP.NET web server, assemblyName
must always be specified.
Retrieved font | assemblyName | location | Notes |
---|---|---|---|
Font1.ttf | "MyWebApplication" | null or Empty | Font resource files are in the root of the main assembly. |
Font2.ttf | "MyWebApplication" | "MyFonts" | Font resource files are in the subfolder of the main assembly. |
Font3.ttf | "MyClassLibrary" | null or Empty | Font resource files are in the root of the referenced assembly. |
Font4.ttf | "MyClassLibrary" | "MyFonts" | Font resource files are in the subfolder of the referenced assembly. |
GetFontFamilies(String)
Returns the collection of PdfFontFamily objects from a string value that represents the location of the fonts.
public static ICollection<PdfFontFamily> GetFontFamilies(string location)
Public Shared Function GetFontFamilies(location As String) As ICollection(Of PdfFontFamily)
Parameters
location
- String
The location that contains the fonts.
Returns
An ICollection<T> of PdfFontFamily objects that represent the fonts in location
.
Remarks
If location
is null or Empty, GetCurrentDirectory() is used.
If location
is relative, it is converted to absolute with GetFullPath(String) method.
If you are developing ASP.NET application, then use Server.MapPath(System.String) as the value of the location
parameter.
GetFontFamilies(String, String)
Returns the collection of PdfFontFamily objects embedded as resources in the specified assembly at the specified location.
Read the Remarks for details about the arguments of the GetFontFamilies(String, String) method for desktop and web applications.
public static ICollection<PdfFontFamily> GetFontFamilies(string assemblyName, string location)
Public Shared Function GetFontFamilies(assemblyName As String, location As String) As ICollection(Of PdfFontFamily)
Parameters
assemblyName
- String
The name of the assembly that contains the fonts.
location
- String
The location of the fonts in the assembly.
Returns
An ICollection<T> of PdfFontFamily objects embedded as resources in the specified assembly at the specified location.
Remarks
important
When you add fonts as resources to your application, make sure you are setting the <Resource> element when targeting .NET Framework or when targeting .NET Core with enabled WPF.
Otherwise, use <EmbeddedResource> element for the build action.
Also, make sure System.Windows.Application.ResourceAssembly is correctly initialized, if you want to format text that uses embedded fonts with WPF or WPFDisplay text formatting mode.
The following image shows an example of a Windows Console project structure with font files added as resources.

The Following table illustrates the various assemblyName
and location
values that you can specify to retrieve fonts from the above Windows Console project structure.
Retrieved font | assemblyName | location | Notes |
---|---|---|---|
Font1.ttf | null, Empty or "MyConsoleApplication" | null or Empty | Font resource files are in the root of the entry assembly. |
Font2.ttf | null, Empty or "MyConsoleApplication" | "MyFonts" | Font resource files are in the subfolder of the entry assembly. |
Font3.ttf | "MyClassLibrary" | null or Empty | Font resource files are in the root of the referenced assembly. |
Font4.ttf | "MyClassLibrary" | "MyFonts" | Font resource files are in the subfolder of the referenced assembly. |
The following image shows an example of a Web ASP.NET project structure with font files added as resources.

The following table illustrates the various assemblyName
and location
values that you can specify to retrieve fonts from the above Web ASP.NET project structure.
Since ASP.NET assembly is actually a class library referenced from ASP.NET web server, assemblyName
must always be specified.
Retrieved font | assemblyName | location | Notes |
---|---|---|---|
Font1.ttf | "MyWebApplication" | null or Empty | Font resource files are in the root of the main assembly. |
Font2.ttf | "MyWebApplication" | "MyFonts" | Font resource files are in the subfolder of the main assembly. |
Font3.ttf | "MyClassLibrary" | null or Empty | Font resource files are in the root of the referenced assembly. |
Font4.ttf | "MyClassLibrary" | "MyFonts" | Font resource files are in the subfolder of the referenced assembly. |