Share via

QuestPDF issue

Jonathan 270 Reputation points
2026-06-17T05:27:33.4066667+00:00

Hi,

Can you help for the issues below? I did the change to add "Type" but still the same problem.

User's image

Developer technologies | .NET | .NET Multi-platform App UI
0 comments No comments

Answer accepted by question author

Sumesh Ramasamy 80 Reputation points
2026-06-17T05:55:43.99+00:00

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.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nancy Vo (WICLOUD CORPORATION) 6,510 Reputation points Microsoft External Staff Moderator
    2026-06-17T08:30:38.1066667+00:00

    Hello @Jonathan ,

    Thanks for your question.

    I apologize for not being able to assist you previously. After conducting a more thorough investigation, I have identified the issue.

    Please put code inside a method, you can refer to my code example:

    MauiProgram.cs:

    using Microsoft.Extensions.Logging;
    using QuestPDF.Infrastructure;
    
    namespace TestPDF
    {
        public static class MauiProgram
        {
            public static MauiApp CreateMauiApp()
            {
                var builder = MauiApp.CreateBuilder();
                builder
                    .UseMauiApp<App>()
                    .ConfigureFonts(fonts =>
                    {
                        fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                        fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
                    });
    
    #if DEBUG
                builder.Logging.AddDebug();
    #endif
                QuestPDF.Settings.License = LicenseType.Community;
                return builder.Build();
            }
        }
    }
    

    Please check whether, when using QuestPDF, the import statement is grayed out. I mean to confirm whether it is being used or not. If it is not used, I recommend checking the .csproj file and sharing it with me.

    I tested this on my end and it works.

    User's image

    I hope this addresses your question. If this response was helpful, please consider following the guidance to provide feedback.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.