Available for: UI for Blazor | UI for Xamarin | UI for WinUI | UI for ASP.NET Core | UI for .NET MAUI

New to Telerik Document Processing? Download free 30-day trial


Unlike the .NET Framework one, RadPdfProcessing’s .NET Standard version does not offer a default mechanism to read fonts. The FixedExtensibilityManager class is exposed to help implement this functionality. The code snippets below show how to create a custom implementation of the FixedExtensibilityManager and properly set it.

Setting and Exporting Fonts

PdfProcessing needs to have access to the font data so that it can read it and add it to the PDF file. That is why, to allow the library to create and use fonts, you will need to provide an implementation of the FontsProviderBase abstract class and set this implementation to the FontsProvider property of the FixedExtensibilityManager.

The code snippets below show how to create a custom FontsProvider implementation and how to set it.

If the FontsProvider property is not set, a default font will be used when exporting the document.

Example 1: Creating custom implementation by inheriting the FontsProviderBase abstract class

    public class FontsProvider : Telerik.Windows.Documents.Extensibility.FontsProviderBase 
        public override byte[] GetFontData(FontProperties fontProperties) 
            string fontFileName = fontProperties.FontFamilyName + ".ttf"; 
            string fontFolder = Environment.GetFolderPath(Environment.SpecialFolder.Fonts); 
            string targetPath = Path.Combine(fontFolder, fontFileName); 
            DirectoryInfo directory = new DirectoryInfo(fontFolder); 
            FileInfo[] fontFiles = directory.GetFiles("*.ttf"); 
            if (fontFiles.Any(s => s.Name.Equals(fontFileName, StringComparison.InvariantCultureIgnoreCase))) 
                using (FileStream fileStream = File.OpenRead(targetPath)) 
                    using (MemoryStream memoryStream = new MemoryStream()) 
                        return memoryStream.ToArray(); 
            return null; 

Example 2: Set the custom implementation inheriting the FontsProviderBase abstract class

    Telerik.Windows.Documents.Extensibility.FontsProviderBase fontsProvider = new FontsProvider(); 
    Telerik.Windows.Documents.Extensibility.FixedExtensibilityManager.FontsProvider = fontsProvider; 
In this article