Completed
Last Updated: 10 Oct 2025 06:11 by ADMIN
Release 2025.3.1007 (2025 Q3)
Diego
Created on: 15 Aug 2025 09:04
Category: PdfProcessing
Type: Bug Report
1
PdfProcessing: Registered fonts are lost when the code is executed on multiple threads

When you register a font in an ASP.Core project and in a static constructor, the generated PDF document will have this font only the first time you load the web page. Refreshing the page will generate the PDF document but the fonts will be lost.

Note: This worked in the previous version  2025.2.701.

 

5 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 19 Aug 2025 06:04

Hello, Diego,

The documentation will be reviewed and updated according to the behavior offered by the released functionality.

Stay tuned.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Diego
Posted on: 18 Aug 2025 15:06
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 18 Aug 2025 14:32

Hi, Diego,

The provided information is appreciated. We will consider your feedback when addressing this item.

Indeed, in version 2025.3.806, font registration via FontsRepository.RegisterFont is no longer global for the application; instead, it is now thread-specific. This means that fonts registered in one thread are not automatically available in others.
This change is intentional and related to internal optimizations, especially for cross-platform scenarios and .NET Standard compatibility, where font access and management are handled differently.

The recommended workaround is to ensure fonts are registered in each thread before generating PDF documents. You can use [ThreadStatic] or other mechanisms to track initialization per thread.

If you have additional questions or need more specific guidance, let me know how your application handles PDF generation and font registration.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Diego
Posted on: 18 Aug 2025 08:28

With the new version of the library 2025.3.806, a breaking change has been introduced (not sure if intentional) in the handling of the RegisterFonts call. Specifically, this call is no longer static for the entire application but instead per thread.

This change causes major confusion: on the one hand, we have a static method, but on the other hand, we are required to use it within the thread instance. There are evident thread-safety issues, and my tests fail in a flaky manner.

To resolve this and update the libraries, I had to change my font registration logic (fortunately, my test suite covered this part of PDF generation, which is central to my application).

 

[MethodImpl(MethodImplOptions.Synchronized)]

private void RegisterFonts(CancellationToken cancellationToken = default)
{
    // Embedding fonts            
    var fontDataNormalItalic = File.ReadAllBytes(Path.Join(AppContext.BaseDirectory, "Resources", "Arial_Italic.ttf"));
    FontsRepository.RegisterFont(_arialFontFamily, FontStyles.Italic, FontWeights.Normal, fontDataNormalItalic);
// bla bla bla
}

 

From my point of view, the Telerik developers need to make a decision: either the method remains static but the issue is fixed to make it thread-safe, or the method is deprecated and font management is moved directly into the PdfFormatProvider instance.

Thanks.

ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 15 Aug 2025 09:26

Hi, Diego,

Currently, the possible solution I can suggest is to register the fonts per thread:

        [ThreadStatic]
        private static bool fontsInitialized;
        static WebinarCertificateDocumentService()
        {
           
        }

        private static void RegisterFonts()
        {
            if (!fontsInitialized)
            {
                // Embedding fonts            

                var nickainleyFontData = File.ReadAllBytes(Path.Join(AppContext.BaseDirectory, "Resources", "Nickainley_Normal.ttf"));
FontsRepository.RegisterFont(nickainleyFontFamily, TDocuments.Core.Fonts.FontStyles.Normal, TDocuments.Core.Fonts.FontWeights.Normal, nickainleyFontData);

                fontsInitialized = true;
            }
        }

Then, call the RegisterFonts() method before the logic for generating the PDF document.

Please excuse us for the inconvenience caused. We will threat this item with highest priority and we will do our best to provide a proper fix accordingly.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.