A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hello,
Welcome to the Microsoft Q&A and thank you for posting your question here.
I understand that you are still getting errors after adding Type for the QuestPDF license configuration in your .NET MAUI project.
From the screenshot, the main issue is that the code is placed directly inside the class body, but it needs to be inside the CreateMauiApp() method. Also, the QuestPDF license setting should be QuestPDF.Settings.License, not QuestPDF.Settings.LicenseType.
Please update your MauiProgram.cs like this:
using CommunityToolkit.Maui;
using QuestPDF.Infrastructure;
namespace Handle_PDF_MauiApp1;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
QuestPDF.Settings.License = LicenseType.Community;
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
.UseMauiCommunityToolkit();
return builder.Build();
}
}
Also, please make sure the .NET MAUI Community Toolkit NuGet package is installed in your project. Otherwise, UseMauiCommunityToolkit() will still show an error.
So the key changes are:
Put the code inside public static MauiApp CreateMauiApp()
Use QuestPDF.Settings.License = LicenseType.Community;
Make sure using QuestPDF.Infrastructure; is added
Make sure using CommunityToolkit.Maui; is added
Confirm that the CommunityToolkit.Maui NuGet package is installed
You can also refer to the official QuestPDF license configuration documentation here: https://www.questpdf.com/license/configuration.html
And the .NET MAUI Community Toolkit setup documentation here: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/get-started
I hope this is helpful. Please let me know if you have any other questions, steps or clarifications.
Please don’t forget to close the thread by upvoting and accepting it as an answer if it is helpful.