Skip to main content
SEMastery
.NET Corebeginner

The 3 C# PDF Libraries Every Developer Must Know

A friendly guide to QuestPDF, PDFsharp, and iText for C#. Learn what each does, their licensing, code examples, and how to pick the right one.

12 min readUpdated October 24, 2025

A pizza box, a recipe card, and a master chef

Think about three ways you can get a meal on the table.

The first way is to order a pizza. The box arrives, you open it, and it already looks neat. You did not have to know how the oven works. You just said what you wanted, and the kitchen handled the hard parts. This is QuestPDF. You describe the document in simple words, and it lays everything out for you.

The second way is a plain recipe card. It tells you the basic steps, but you do the cooking yourself. You decide where each ingredient goes. You have full control, but you also do more work. This is PDFsharp. It gives you the basic tools and lets you place things exactly where you want.

The third way is hiring a master chef who can cook anything, even the rarest dishes. The chef is powerful and can handle special requests like signatures, stamps, and strict formats. But a master chef is expensive, and you must agree to their terms. This is iText. It is the most capable, but it comes with rules and cost.

In this guide we will meet all three. We will keep the language simple, look at real code, and learn how to pick the right one for your project. By the end you will know exactly which library to reach for.

Why generating PDFs is a common need

PDF files are everywhere in real software. When you book a train ticket on IRCTC, you get a PDF. When you pay a bill online, you get a PDF receipt. When a school sends a report card or a shop sends a GST invoice, it is almost always a PDF.

A PDF looks the same on every phone, laptop, and printer. That is its big magic. A web page can shift around on different screens, but a PDF stays fixed. So when a business needs an exact, printable document, PDF is the answer.

As a C# developer, you will be asked to create these files. You do not want to build a PDF by hand, because the PDF format is complicated inside. Instead, you use a library that does the heavy lifting. Let us see how the three best ones compare.

The three libraries sit between your C# code and the final PDF file

Meet the three libraries

Here is a quick map before we go deep. Read it once, then we will explain each one slowly.

LibraryStyleBest forLicence in short
QuestPDFHigh level, fluentInvoices, reports, modern appsMIT, free under 1M USD revenue
PDFsharpLow level, drawingSimple PDFs, full freedomMIT, free for everyone
iTextVery low level, powerfulSignatures, PDF/A, formsAGPL or paid commercial

The words "high level" and "low level" matter a lot here. High level means the library makes many decisions for you, so you write less code. Low level means you make the decisions yourself, so you have more control but write more code.

From need to library

Need a PDF
How fancy?
Pick library

Steps

1

Need a PDF

Invoice, report, receipt

2

How fancy?

Simple or advanced

3

Pick library

Quest, PDFsharp, iText

A simple thinking path to pick a library

Library 1: QuestPDF, the friendly one

QuestPDF is the newest of the three and the easiest to learn. It uses a fluent API. That is a fancy way of saying you chain small commands together, and the code reads almost like a sentence. It has a smart layout engine, so it figures out where text wraps, when a new page begins, and how columns line up. You do not deal with raw coordinates.

First, install it from NuGet:

// In the terminal, inside your project folder:
// dotnet add package QuestPDF

Now here is a small, complete example that makes a one-page PDF with a header, some body text, and a footer.

using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
 
// Tell QuestPDF you are using the free Community licence.
QuestPDF.Settings.License = LicenseType.Community;
 
Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSizes.A4);
        page.Margin(2, Unit.Centimetre);
        page.DefaultTextStyle(x => x.FontSize(14));
 
        page.Header()
            .Text("Sunrise School Report")
            .SemiBold().FontSize(22).FontColor(Colors.Blue.Darken2);
 
        page.Content()
            .PaddingVertical(1, Unit.Centimetre)
            .Text("Student: Aarav Sharma. Result: Passed with distinction.");
 
        page.Footer()
            .AlignCenter()
            .Text(text =>
            {
                text.Span("Page ");
                text.CurrentPageNumber();
            });
    });
})
.GeneratePdf("report.pdf");

Read that code again. Even without knowing PDFs, you can guess what it does. page.Header() is the top. page.Content() is the middle. page.Footer() is the bottom. QuestPDF handles the spacing and page breaks for you. That is why beginners love it.

QuestPDF is great for invoices and reports because it can repeat table rows, break long content across many pages, and keep a footer on every page. The official invoice tutorial builds a full invoice in under two hundred lines.

How QuestPDF builds a page from top to bottom

A word on the QuestPDF licence

QuestPDF is free under the MIT licence for many people. You can use it for free if you are an individual, a student, a charity, an open-source project, or a company earning under one million US dollars per year in gross revenue. If your company earns more than that, you need a paid commercial licence, which costs about 1,999 US dollars per year. There is no licence key to paste. You simply set QuestPDF.Settings.License to Community, Professional, or Enterprise in your code.

For students and most small teams in India, QuestPDF is completely free. That makes it a safe and friendly first choice.

Library 2: PDFsharp, the freedom one

PDFsharp is older and works at a lower level. Instead of "header, content, footer", you draw things on the page using coordinates and a graphics object. Think of the page as a blank sheet, and you place each item by saying where it goes.

This means a bit more work, but it also means total freedom. And the biggest win is the licence. PDFsharp uses the plain MIT licence with no revenue limit. Any company, big or small, can use it for free. There are no conditions to worry about.

Install it:

// dotnet add package PdfSharpCore
// or the official package: dotnet add package PdfSharp

Here is a small example that draws a title onto a new PDF page.

using PdfSharp.Drawing;
using PdfSharp.Pdf;
 
// Create a new, empty document and add one page.
var document = new PdfDocument();
var page = document.AddPage();
 
// Get a drawing surface for that page.
using var gfx = XGraphics.FromPdfPage(page);
 
// Pick a font and a pen colour.
var titleFont = new XFont("Verdana", 20, XFontStyleEx.Bold);
var bodyFont = new XFont("Verdana", 12, XFontStyleEx.Regular);
 
// Draw text at a chosen position on the page.
gfx.DrawString("Water Bill Receipt", titleFont, XBrushes.DarkBlue,
    new XRect(0, 40, page.Width, 30), XStringFormats.TopCenter);
 
gfx.DrawString("Amount paid: 350 rupees", bodyFont, XBrushes.Black,
    new XRect(40, 100, page.Width, 20), XStringFormats.TopLeft);
 
document.Save("receipt.pdf");

Notice the numbers like 40, 100, and page.Width. Those are positions on the page, measured from the top-left corner. You are the one deciding where each piece of text sits. That is the trade-off: more control, more typing.

PDFsharp is perfect when you want a simple PDF and you never want to think about licensing again. It is also good for editing existing PDFs and merging pages. One honest note: PDFsharp has not added many big new features in recent years, so it is best for steady, simple needs rather than fancy modern layouts.

Drawing with PDFsharp

New document
Add page
Draw items
Save

Steps

1

New document

Empty PDF

2

Add page

Blank sheet

3

Draw items

Text by X and Y

4

Save

Write file

You place each element by coordinates

Library 3: iText, the powerful one

iText is the heavyweight. It can do almost anything a PDF can do. It supports digital signatures, strict archive formats like PDF/A, accessible formats like PDF/UA, fillable forms, and very fine control over every byte of the file. Banks, insurance firms, and government systems often use iText because they need these strong features.

But power comes with cost and rules. iText Core for .NET uses the AGPL licence. AGPL is strict. It says that if you build a product using iText, you must also share your whole product's source code under the same open licence. Most companies do not want to give away their code, so they buy a commercial licence instead. That commercial licence can cost from a few thousand to many tens of thousands of US dollars per year, depending on how you use it.

Here is a tiny iText example that writes one line into a PDF:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
 
// Open a writer that points to the output file.
using var writer = new PdfWriter("statement.pdf");
using var pdf = new PdfDocument(writer);
 
// A Document is the high-level layout wrapper around the PDF.
using var document = new Document(pdf);
 
document.Add(new Paragraph("Bank Statement for June 2026"));
document.Add(new Paragraph("Closing balance: 12,450 rupees"));
 
// document is disposed here, which writes and closes the file.

The code is not hard for a simple case. The real strength of iText shows up in advanced tasks like adding a legally valid digital signature, which the other two libraries cannot do well. So you choose iText when those advanced needs are real, and you are ready to handle the licence.

iText can do simple and advanced jobs, but the advanced ones are its real value

Comparing the three side by side

Now that you have met all three, here is a fuller comparison. Keep this table handy when you start a project.

FeatureQuestPDFPDFsharpiText
Ease for beginnersVery easyMediumHarder
Layout engineAutomaticManual, by coordinatesManual and advanced
Digital signaturesNoNoYes
PDF/A and PDF/UALimitedNoYes
Edit existing PDFsNoYesYes
LicenceMIT, paid above 1M USDMIT, fully freeAGPL or paid
New features latelyActiveSlowActive

A short way to remember it: QuestPDF for clean new documents, PDFsharp for free and simple work, iText for serious enterprise needs.

How to choose the right one

Choosing is easier than it looks. Ask yourself three small questions in order.

First, do you need digital signatures, PDF/A archiving, or fillable forms? If yes, you likely need iText, and you should plan for the licence. If no, move on.

Second, does your company earn over one million US dollars per year, and do you want zero licence worries? If yes, PDFsharp's plain MIT licence is the safest. If you are a student, a small team, or a hobby project, QuestPDF is free for you too.

Third, do you want the cleanest, most modern code with the least effort? If yes, QuestPDF wins for most everyday documents like invoices and reports.

Choosing your PDF library

Advanced features?
Big company or worry-free?
Want easy modern code?

Steps

1

Advanced features?

Yes leads to iText

2

Big company or worry-free?

Yes leads to PDFsharp

3

Want easy modern code?

Yes leads to QuestPDF

Three questions lead you to the right tool

Here is the same idea as a simple decision flow you can follow in your head.

A decision path for picking a PDF library

A few practical tips

When you generate PDFs on a server, do it in a background task if the file is large, so your web request stays fast. A report with a thousand rows can take a moment, and you do not want users staring at a frozen screen.

Always test your PDF on a real device and a real printer. Fonts can look different, and margins that seem fine on screen may get cut off on paper. If you embed images, use a sensible size so the file does not become huge.

Keep your library version pinned. If you use many projects in one solution, Central Package Management helps you keep the same QuestPDF or PDFsharp version everywhere, which avoids surprise bugs. Finally, read the licence once at the start of a project. It is far easier to choose correctly now than to swap libraries after launch.

Quick recap

  • A PDF is a fixed document that looks the same on every screen and printer, which is why apps generate them for invoices, receipts, and reports.
  • QuestPDF is the friendly high-level choice. Its fluent C# API reads like plain English, and it is free under MIT for individuals, students, charities, open-source work, and companies under one million US dollars of yearly revenue.
  • PDFsharp is the freedom choice. It works at a lower level using coordinates, but its MIT licence has no revenue limit, so any company can use it for free.
  • iText is the powerful choice. It supports signatures, PDF/A, and forms, but it uses the AGPL licence, so most companies must buy a commercial licence that can be costly.
  • To choose: pick iText for advanced features, PDFsharp for total licence freedom, and QuestPDF for the easiest modern code on everyday documents.
  • Always check the licence early, test on real devices, and pin your library versions across projects.

References and further reading

Related Posts