QuestPDF / QuestPDF

QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API. Easily generate PDF reports, invoices, exports, etc.

Home Page:https://www.questpdf.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Calling FontManager.RegisterFont throws an InitializationException

ebarnard opened this issue · comments

Describe the bug
Calling FontManager.RegisterFont throws a QuestPDF.Drawing.Exceptions.InitializationException with message "QuestPDF cannot instantiate native object."

This worked prior to version 2024.3.0.

To Reproduce
Run the code in this repo https://github.com/ebarnard/QuestPdfRegisterFontBug.

I realise that QuestPDF now bundles Lato as its default font so registering it manually as well could cause issues, but this seems unrelated to the exception type or message.

Expected behavior
Font registration succeeds.

Environment
Windows 10 x64

Thank you for reporting this problem 😄

I have followed your repository. It successfully registers all fonts. However, in the last iteration step, it attempts to register the text file containing the OFL license, which is expected to fail. I have adjusted the exception message to provide more meaningful context ("Cannot decode the provided font file.").

Would you please test the newest 2024.3.2 version? https://github.com/QuestPDF/QuestPDF/releases/tag/2024.3.2

Doh! That is exactly what's happening. Thanks for sorting out the exception message, hopefully that will help others in the future.