Skip to content

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.

License

Notifications You must be signed in to change notification settings

QuestPDF/QuestPDF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


QuestPDF Homepage Dotnet GitHub Repo stars Nuget version Nuget download QuestPDF License


QuestPDF is a modern open-source .NET library for PDF document generation. Offering comprehensive layout engine powered by concise and discoverable C# Fluent API.

Document
  .Create(document =>
  {
    document.Page(page =>
    {
      page.Size(PageSizes.Postcard);
      page.Margin(0.3f, Unit.Inch);

      page.Header()
        .Text("Hello PDF!")
        .FontSize(28)
        .Bold()
        .FontColor(Colors.Blue.Darken2);

      page.Content()
        .PaddingVertical(8)
        .Column(column =>
        {
          column.Spacing(8);

          column.Item()
            .Text(Placeholders.LoremIpsum())
            .Justify();

          column.Item()
            .AspectRatio(16 / 9f)
            .Image(Placeholders.Image);
        });

      page.Footer()
        .AlignCenter()
        .Text(text =>
        {
          text.Span("Page ");
          text.CurrentPageNumber();
        });
    });
  })
  .GeneratePdfAndShow();



Please help by giving a star

GitHub stars guide developers toward great tools. If you find this project valuable, please give it a star – it helps the community and takes just a second! ⭐


QuestPDF Companion App

Accelerate your development with live document preview powered by the hot-reload capability, eliminating the need for code recompilation:

  • Explore document structure and hierarchy
  • Quickly magnify and measure content
  • Debug runtime exceptions with stack traces and code snippets
  • Identify, understand and solve layout errors

Companion App


What you need is here

Comprehensive Layout Engine - A layout engine tailored for document generation, offering advanced paging and precise content control.

Rich Toolkit - Craft documents with intuitive, reusable components and over 50 layout elements for complex designs.

High Performance - Generate thousands of pages per second with minimal CPU and memory usage.

Advanced Language Support - Seamlessly create multilingual documents with support for RTL, text shaping, and bi-directional content.


Code-Focused Paradigm

Using C# to design PDF documents leverages powerful control structures like if-statements, for-loops, and methods, enabling dynamic and highly customizable content generation.

It promotes best practices such as modular design and reusability while seamlessly integrating with source control systems for collaboration and versioning.

.Column(column =>
{
    if (Model.Comments != null)
        column.Item().Text(Model.Comments);

    foreach(var item in Model.Items)
       column.Item().Element(c => CreateItem(c, item);
});
void CreateItem(IContainer container, Item item)
{
    container
-       .Background(Colors.Grey.Lighten2)
+       .Background(item.Color)
        .Padding(10)
        .Text(item.Text);
}

Multiplatform

The library supports all major operating systems, integrates seamlessly with leading IDEs as well as popular cloud platforms and technologies to ensure maximum flexibility.

  • Technologies: modern dotnet, legacy .NET Framework, Docker
  • Operating systems: Windows, Linux, MacOS
  • Cloud providers: Azure, AWS, Google Cloud
  • IDE: Visual Studio, Visual Code, JetBrains Rider, others

Perform common PDF operations

  • Merge documents
  • Attach files
  • Extract pages
  • Encrypt / decrypt
  • Extend metadata
  • Limit access
  • Optimize for Web
  • Overlay / underlay
DocumentOperation
    .LoadFile("input.pdf")
    .TakePages("1-10")
    .MergeFile("appendix.pdf", "1-z") // all pages
    .AddAttachment(new DocumentAttachment
    {
        FilePath = "metadata.xml"
    })
    .Encrypt(new Encryption256Bit
    {
        OwnerPassword = "mypassword",
        AllowPrinting = true,
        AllowContentExtraction = false
    })
    .Save("final-document.pdf");

Getting started tutorial


Let's get started

Follow our detailed tutorial, and see how easy it is to produce a fully functional invoice with fewer than 250 lines of C# code.

Getting started tutorial


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.

Warning

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.

Library license details


QuestPDF on YouTube

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!

Nick Chapsas: The Easiest Way to Create PDFs in .NET

Nick Chapsas The Easiest Way to Create PDFs in .NET

Claudio Bernasconi: QuestPDF - The BEST PDF Generator for .NET?!

Claudio Bernasconi QuestPDF - The BEST PDF Generator for .NET?!

JetBrains: OSS Power-Ups: QuestPDF

JetBrains OSS Power-Ups: QuestPDF

Programming with Felipe Gavilan: Generating PDFs with C# - Very Easy (two examples)

Felipe Gavilan Generating PDFs with C# - Very Easy (two examples)

About

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.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Languages