Skip to content

Quick start

What is QuestPDF?

Modern approach for PDF generation

QuestPDF is a modern C# library that takes a fresh approach to PDF document generation. Instead of relying on HTML conversion like many other solutions, it provides a dedicated layout engine optimized specifically for creating PDF documents.

Component-Based Architecture

At its core, QuestPDF works by composing simple elements (like text, images, tables, and grids) into more complex layouts. Think of it as building with LEGO blocks – each piece has a clear purpose, and you can combine them confidently to create sophisticated documents.

Code-focused Paradigm

Since the library uses pure C# language, you can leverage familiar programming concepts like loops and conditionals to create dynamic documents. It promotes best practices such as modular design and reusability while seamlessly integrating with source control systems for collaboration and versioning.

Installation

QuestPDF is available as a NuGet package. You can install it through your IDE by searching for QuestPDF:

Or use one of the following methods:

c#
// Package Manager
Install-Package QuestPDF

// .NET CLI
dotnet add package QuestPDF

// Package reference in .csproj file
<PackageReference Include="QuestPDF" Version="2025.4.0" />

Check the package details on the NuGet website:

quest pdf logo

Implementation

QuestPDF's minimal API makes it incredibly easy to create and prototype PDF documents. Here's a simple example that demonstrates its intuitive syntax:

c#
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;

// code in your main method
Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Margin(2, Unit.Centimetre);
        page.PageColor(Colors.White);
        page.DefaultTextStyle(x => x.FontSize(20));
        
        page.Header()
            .Text("Hello PDF!")
            .SemiBold().FontSize(36).FontColor(Colors.Blue.Medium);
        
        page.Content()
            .PaddingVertical(1, Unit.Centimetre)
            .Column(x =>
            {
                x.Spacing(20);
                
                x.Item().Text(Placeholders.LoremIpsum());
                x.Item().Image(Placeholders.Image(200, 100));
            });
        
        page.Footer()
            .AlignCenter()
            .Text(x =>
            {
                x.Span("Page ");
                x.CurrentPageNumber();
            });
    });
})
.GeneratePdf("hello.pdf");

This code generates a PDF document with the following layout:

example

SUSTAINABLE AND FAIR LICENSE

By offering free access to most users and premium licenses for larger organizations, the project maintains its commitment to excellence while ensuring sustainable, long-term development for all.

The library is free to use for any individual or business with less than 1 million USD annual gross revenue, or operates as a non-profit organization, or is a FOSS project.

TIP

For learning and evaluation, you can use the free QuestPDF Community license.

More details can be found on the QuestPDF License and Pricing page.

Are you ready for more?

QuestPDF's Fluent API scales seamlessly with your document complexity. Whether you're creating simple reports or sophisticated documents, the intuitive syntax remains consistent and maintainable. To explore its full potential, check out the Getting started tutorial, where you'll learn to create a professional invoice in less than 200 lines of code. You can also examine and experiment with the code hosted on the GitHub repository.

invoice

Learn from the Community

We are incredibly grateful to the YouTube Community for their positive reviews and recommendations of the QuestPDF library. Your support and feedback are invaluable and motivate us to keep improving and expanding this project. Thank you for helping us grow and reach more developers!




Released under the MIT License