Skip to content

C# PDF library

C# PDF Library: HTML to PDF C# and .NET PDF Library Costs Compared

Six real ways to produce a PDF from C#, and the licensing bill attached to each. QuestPDF is excellent and free until your company crosses a revenue line. iText will happily convert your HTML and then ask you to open source your entire application. PDFsharp is MIT forever and cannot read a single tag of HTML. Here is which one fits your document, what each one actually costs a closed source commercial app, and when a rendering API is the cheaper answer. Try it on any URL below.

  • Early access, launching soon
  • No card required
  • Your HTML stays yours

Live demo

Runs in your browser. Nothing is uploaded.

Your PDF is downloading. Want this as one API call, with the page archived too?

Short answer

The right C# PDF library depends on one question: does your document start as HTML, or as data? If it starts as data, QuestPDF is the strongest modern choice. You compose the document in a fluent C# API, output is clean vector PDF, and it is free for individuals and for businesses under 1M USD in annual gross revenue, then 1,999 USD for a Professional license. It deliberately does not accept HTML. If your document starts as HTML, your options narrow sharply. iText 7 with the pdfHTML add-on converts it, but iText is dual licensed AGPL and commercial, and the AGPL requires you to publish the source of your own application. PDFsharp and MigraDoc are MIT with no revenue condition, but they draw documents in code and accept no HTML. IronPDF bundles a Chromium engine and converts HTML properly, from 999 USD per developer perpetual with no free production tier. PuppeteerSharp and Playwright for .NET give you real Chromium for free, and hand you a browser to operate. A hosted rendering API gives you the same Chromium output as one HTTPS call, with no engine to license or host. License facts and prices on this page were read from each vendor own site on 9 August 2026.

Last updated 9 August 2026. Written and fact checked by the Sitepdf team.

Every .NET PDF library, what it renders and what it costs

Most C# PDF comparisons stop at features and skip the licensing, which is the part that decides the project. This table puts both together. The cost column answers one specific question: what does a closed source commercial application have to pay? Every license term and price below was read from the vendor own site or repository on 9 August 2026.

Library or approach Accepts HTML and CSS Runs JavaScript License Cost for a closed source commercial app
QuestPDF No, you compose the document in C# Not applicable Source available, dual licensed Free under 1M USD annual gross revenue, then 1,999 USD Professional or 4,999 USD Enterprise
iText 7 with pdfHTML Yes, through the pdfHTML add-on No AGPL v3 or commercial AGPL requires publishing your own application source; commercial pricing is quote only
PDFsharp and MigraDoc No, you draw the document Not applicable MIT Free, with no revenue condition and no disclosure obligation
IronPDF Yes, bundled Chromium engine Yes Commercial, perpetual 999 USD Lite to 4,799 USD Unlimited, no free production tier
PuppeteerSharp or Playwright for .NET Yes, real Chromium Yes Open source wrapper Free to license, you pay in servers, memory and browser operations
Hosted rendering API
Sitepdf
Yes, managed Chromium Yes Subscription Planned from 29 USD a month, nothing to install, license or host

The honest split: if you are building an invoice or a report out of database rows and your team is comfortable declaring the layout in C#, QuestPDF is a genuinely excellent library and under the revenue threshold it costs nothing. Use it. PDFsharp is the safest license in the table if MIT with no strings matters more to you than a modern API. You only need a browser engine when the document is real HTML and CSS, and at that point the only question left is who runs the browser and who pays for the license.

QuestPDF is the best modern C# PDF library, and it will never accept your HTML

QuestPDF has become the default recommendation in .NET circles for good reason. You describe the document in a fluent C# API, the layout engine handles pagination and measurement for you, and the output is real vector PDF with selectable text. Compared with hand positioning elements in PDFsharp or fighting iText document model, it is a pleasant library to work in, and it is actively developed.

Document.Create(container =>
{
    container.Page(page =>
    {
        page.Size(PageSizes.Letter);
        page.Margin(2, Unit.Centimetre);
        page.Header().Text("Invoice 8842").FontSize(20).SemiBold();
        page.Content().PaddingVertical(1, Unit.Centimetre).Column(col =>
        {
            foreach (var line in invoice.Lines)
                col.Item().Text($"{line.Description}  {line.Amount:C}");
        });
        page.Footer().AlignCenter().Text(t => t.CurrentPageNumber());
    });
}).GeneratePdf("invoice-8842.pdf");

Now the part most comparison articles skip. The QuestPDF README states plainly that the library is "free for individuals, non-profits, open-source projects, and organizations under $1M in annual gross revenue". Above that line you need a paid license: 1,999 USD for Professional, which the pricing page describes as covering "one legal entity shipping PDFs in production, every developer covered at one flat, predictable price", or 4,999 USD for Enterprise where a corporate group needs affiliate wide coverage. Two details are worth knowing before you commit. The Community license is explicitly not an OSI approved open source license, and its own text says the MIT License does not govern use of the software under it. And public sector entities and publicly traded companies are ineligible for the free tier regardless of revenue. If you cross the threshold there is a 90 day transition period, with no back payments for the period when you did qualify.

The hard limit is a design decision, not an oversight. QuestPDF markets itself with the line "Stop fighting with HTML-to-PDF conversion". There is no HTML input, no CSS parser and no plan for one. If you already have a Razor view, an email template or a marketing page that needs to become a PDF, QuestPDF means rebuilding that entire layout by hand in C# and then maintaining two versions of it forever. That is the tradeoff: a beautiful API for documents you author in code, and no path at all for documents you author in markup.

iText, iTextSharp and the AGPL clause that catches closed source apps

iText is the oldest and most capable PDF toolkit in .NET, and with the pdfHTML add-on it does convert HTML and CSS to PDF. It is also the single most common licensing accident in the ecosystem, which is why itextsharp license and itext license are among the most searched terms in the whole .NET PDF space.

The iText for .NET repository states that the library is "dual licensed as AGPL/Commercial software" and that "The AGPL is a copyleft license, which means that any derivative work must also be licensed under the same terms." iText own licensing page is more direct about what that means in practice: "You may not deploy it on a network without disclosing the full source code of your own applications under the AGPL license" and "You must distribute all source code, including your own product and web-based applications." The network clause is the trap. Unlike the GPL, the AGPL is triggered by users interacting with your software over a network, so an internal ASP.NET Core service that generates invoices for customers can fall inside it. There is also a requirement to retain the producer line and copyright notice in the PDF metadata.

Read that against a normal SaaS product and the conclusion is uncomfortable: if you ship a closed source commercial application and it generates PDFs with iText under the AGPL, you are out of compliance unless you publish your own source. The legitimate answer is a commercial license, which iText offers as either an OEM distribution license or a volume based annual subscription. Neither has a published price. The buying page lists both as custom and directs you to request a quote, so you cannot budget for iText without a sales conversation.

A common misconception deserves clearing up. Older iTextSharp releases, up to version 4.1.6, were LGPL or MPL, and a great deal of code and Stack Overflow advice on the internet still assumes those terms. Everything from iText 5 onward is AGPL. Copying a 2011 answer into a 2026 codebase inherits the newer license, not the older one, because the license that applies is the one attached to the package version you install. If your solution has an iTextSharp package reference that predates the change, that does not make new work under it safe. If your solution has an iTextSharp package reference that predates the change, check the installed version rather than assuming the old terms carried forward.

PDFsharp and MigraDoc: the safest license, and no HTML at all

If licensing risk is what keeps you awake, PDFsharp is the cleanest answer in .NET. The project README states it is "Published Open Source under the MIT License". That is MIT with no revenue threshold, no disclosure obligation, no employee count and no transition period. You can ship it inside a closed source commercial product, at any scale, and owe nothing.

What you get for that is a lower level toolkit. PDFsharp draws on the page: you position text, lines, images and shapes yourself, in device independent units. MigraDoc sits above it and adds a document model with paragraphs, tables and styles, which is the layer most people actually want, and it handles pagination for you. Between them you can produce a professional invoice or report, and the output is small and fast.

Neither reads HTML. There is no CSS engine anywhere in the stack, and the documentation does not claim one. Every article you find suggesting PDFsharp for HTML to PDF is describing a third party bridge that parses a narrow subset of HTML and drops most of the CSS on the floor. If your source document is markup, this is the wrong branch of the tree entirely.

The practical way to choose between the two free code first libraries: QuestPDF has the far nicer API and better layout engine, PDFsharp has the simpler license and a longer track record. If you are under the revenue threshold and expect to stay there, take QuestPDF. If you are a large company, or a public sector body, or publicly traded, or you simply do not want a license question resurfacing at your next funding round or audit, PDFsharp costs nothing under any circumstance.

IronPDF, Syncfusion and the bundled Chromium camp

When your document really is HTML, the libraries that work are the ones that ship a browser engine inside the package. IronPDF is the best known. You hand it an HTML string, a file or a URL and it renders through a bundled Chromium, so modern CSS, web fonts and JavaScript all behave the way they do in a browser, and the text stays selectable.

var renderer = new ChromePdfRenderer();
renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
renderer.RenderingOptions.PrintHtmlBackgrounds = true;

var pdf = renderer.RenderHtmlAsPdf(invoiceHtml);
pdf.SaveAs("invoice-8842.pdf");

IronPDF publishes its prices, which is more than iText does. As read on 9 August 2026 the perpetual tiers are Lite at 999 USD for one developer, one location and one project, Plus at 1,499 USD for three of each, Professional at 2,399 USD for ten of each, and Unlimited at 4,799 USD. There is a 30 day free trial with full functionality, but no free tier for production use. Perpetual pricing means no recurring fee, though ongoing support and updates are a separate consideration.

Syncfusion offers a PDF library inside its component suite, and its Community License is genuinely free but the eligibility conditions are the tightest in this comparison. Syncfusion states the free license is for "Companies and individuals with less than $1 million USD in annual gross revenue, 5 or fewer developers, and 10 or fewer total employees", and adds that an organization "may not have ever received more than $3,000,000 USD in capital from an outside source, such as private equity or venture capital". Three separate ceilings plus a funding history test. A ten person startup that raised a 4M USD seed round is ineligible on the funding clause alone even though it passes revenue and headcount.

The shared constraint for this whole camp is architectural rather than commercial: these are server side libraries that need a Chromium engine present on the machine. That is fine on a virtual machine or a container you control. It is a real problem inside a Blazor WebAssembly app, which has no server process at all, and awkward on a constrained serverless platform. The Blazor HTML to PDF page works through that hosting question in detail, because in Blazor your hosting model rules half these options out before you compare a single feature.

Aspose.PDF sits in the same commercial camp and is worth a look if your requirement runs past rendering into editing, form filling and format conversion, though it prices on developers and offices rather than volume, and one remote team can fail the cheapest tier without processing a single extra document. The full ladder, from $1,199 to $59,950, is broken down on our Aspose PDF pricing page.

PuppeteerSharp and Playwright for .NET: real Chromium, on your bill

You can skip the commercial engines and drive a browser directly. PuppeteerSharp is the .NET port of Puppeteer, and Microsoft ships Playwright for .NET as a first class library. Both are open source, both download and control real Chromium, and both produce exactly the output the browser print pipeline produces, because that is literally what they call.

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();

await page.GotoAsync("https://app.example.com/invoices/8842",
    new() { WaitUntil = WaitUntilState.NetworkIdle });

await page.PdfAsync(new()
{
    Path = "invoice-8842.pdf",
    Format = "Letter",
    PrintBackground = true
});

Two options matter more than the rest. PrintBackground = true is off by default, which is the single most common cause of an invoice arriving with white boxes where the branded header should be. And waiting for network idle, or better for a specific selector, is what stops you capturing a page before its data has loaded.

The license is free. The operating cost is not. You are now responsible for a browser: installing its system dependencies in your Docker image, keeping the Chromium version current for security, capping concurrency so a burst of report requests does not exhaust memory, disposing pages and contexts so handles do not leak, and handling the cold start every time a fresh container launches its first browser. On AWS Lambda this collides with hard platform limits. The published quotas are 50 MB for a zipped deployment package and 250 MB unzipped including layers, which a full Chromium does not fit inside, so you end up on container images or a stripped build. None of this is unsolvable. It is simply infrastructure work that a licensing table never shows you, and on a small team it usually costs more per year than the license you avoided.

ASP.NET Core: rendering in the request is the mistake to avoid

Whichever library you land on, the same architectural error shows up in almost every first implementation: generating the PDF inside the HTTP request that asked for it. A Chromium render of a real invoice takes somewhere around one to three seconds. Kestrel handles that fine at low volume, but under load those threads are occupied and your API latency tracks your PDF engine rather than your application.

The pattern that holds up is the same in every stack. Accept the request, queue the job, return a 202 with a location the client can poll or a webhook you will call, and generate the document on a background worker. In .NET that is a hosted service with a channel for small workloads, or Hangfire, or an Azure Storage queue with a worker service for anything serious. This matters more with an in process engine than with an API, because an in process Chromium competes with your web application for the same memory on the same machine, and a memory spike during a large report takes the whole site down rather than just failing the report.

The other thing to decide early is where the finished file lives. Writing PDFs to the local disk of a container works right up until you scale to two instances and half your download links start returning 404 because the file is on the other machine. Object storage from the start, with the document id in your database rather than a file path, saves a painful migration later. The document generation API page covers the queue and template merge pattern in more depth, and bulk HTML to PDF covers what changes when you are rendering thousands of documents in a batch rather than one at a time.

The API path: Chromium fidelity, no license to buy and no browser to run

A hosted rendering API runs managed Chromium on someone else infrastructure. From C# it is an ordinary HttpClient call, so there is no NuGet package with a license attached, no engine in your deployment artifact, no browser pool to tune, no cold start, and no Lambda package limit to work around. It behaves identically from an Azure App Service, a container, a Lambda, a Blazor WebAssembly app or a developer laptop, because from your application it is just an outbound HTTPS request.

var res = await http.PostAsJsonAsync("https://api.sitepdf.com/v1/render", new
{
    url = "https://app.example.com/invoices/8842",
    format = "Letter",
    margin = "normal",
    archive = true
});

var doc = await res.Content.ReadFromJsonAsync<RenderResult>();

Send a url and Chromium loads the page the way a signed in visitor would, JavaScript included, so a Chart.js dashboard renders as a chart rather than an empty container. Send an html string instead when your Razor view is rendered in memory and never served at a public address. The output is true vector text, so it stays selectable, searchable and accessible rather than being a picture of a document.

The archive flag is the part no NuGet package offers. It stores a timestamped snapshot of exactly what Chromium rendered, retrievable later by id, so eighteen months on you can show precisely what a given statement looked like at the moment you produced it. For finance, insurance, healthcare and anything with a records retention requirement, that dated record is usually the reason to render through an API rather than in process. See the PDF generator API page for the full call surface, website archiving for how the record works, and PDF API pricing for what every vendor in this category charges per 1,000 documents. For the other side of that decision, our PDF SDK pricing and licensing comparison records what IronPDF, QuestPDF, Syncfusion, Apryse and five more actually publish.

The honest limit: an API is a network call, so it adds latency an in process library does not have, it needs outbound network access, and it will not work in an air gapped environment. If you generate forty invoices a month from data you already hold, QuestPDF under its free tier will beat this on every axis and you should use it. The case for an API strengthens with HTML source documents, with volume, with serverless hosting, with a licensing department that does not want another perpetual agreement, and with any requirement to prove what you rendered.

Choosing, in one pass

Work down this list and stop at the first line that matches you.

  • Your document is built from data and your company is under 1M USD revenue. Use QuestPDF. Best API in .NET, free at your size, and nothing else on this list is simpler.
  • Your document is built from data and you are large, public sector or publicly traded. Use PDFsharp with MigraDoc. MIT with no conditions beats a license negotiation.
  • Your document is already HTML and you can publish your application source. iText 7 with pdfHTML under the AGPL is a legitimate free option. Almost nobody shipping commercial software can accept this clause, so read it properly before assuming you can.
  • Your document is already HTML, you ship closed source, and you want a package on your own servers. IronPDF from 999 USD, or Syncfusion if you clear all three of its community ceilings including the funding history test.
  • You want Chromium fidelity for free and you have infrastructure people. PuppeteerSharp or Playwright for .NET. Set PrintBackground = true, cap concurrency, and budget for the container work.
  • You want Chromium output without a license, a browser or a deployment problem, or you need a dated record of what you produced. Use a rendering API. Every constraint in the two sections above comes from the engine living inside your own process.

If you are working in a specific framework rather than plain .NET, the Blazor HTML to PDF page covers the Server and WebAssembly split, and the same decision in other stacks is laid out on HTML to PDF in Node.js, Python PDF generation and HTML to PDF in Spring Boot. For the head to head against the specific tools people shortlist alongside these, see the best HTML to PDF API comparison.

From C#: render a URL or a Razor view in managed Chromium with no engine to license, and keep a dated copy of exactly what was produced.
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("SITEPDF_KEY"));

var res = await http.PostAsJsonAsync("https://api.sitepdf.com/v1/render", new
{
    url = "https://app.example.com/invoices/8842",
    format = "Letter",
    margin = "normal",
    archive = true
});

{
  "pdf_url": "https://api.sitepdf.com/v1/documents/doc_7m2vc.pdf",
  "pages": 3,
  "rendered_in_ms": 1780,
  "archive": {
    "id": "arc_q47ne",
    "captured_at": "2026-08-09T09:14:22Z",
    "retrieve_url": "https://api.sitepdf.com/v1/archives/arc_q47ne"
  }
}

The API is in early access; this is the documented call shape it opens with. Full request and response walkthrough.

Questions about this job

What is the best C# PDF library?
There is no single best one, because they solve different problems. QuestPDF is the best library for documents you build from data, with a modern fluent API and a free tier under 1M USD revenue. PDFsharp with MigraDoc is the best MIT licensed option with no conditions. For HTML input you need a browser engine, which means IronPDF, PuppeteerSharp or a rendering API.
How do I convert HTML to PDF in C#?
You need something with a CSS engine, because most .NET PDF libraries have none. The three routes that work are iText 7 with the pdfHTML add-on, a bundled Chromium library like IronPDF, or driving real Chromium through PuppeteerSharp or Playwright for .NET. A hosted rendering API does the same job as one HttpClient call with no engine to install or license.
Is QuestPDF free for commercial use?
Yes, below a revenue threshold. QuestPDF is free for individuals, non-profits, open source projects and organizations under 1M USD in annual gross revenue. Above that you need a Professional license at 1,999 USD or Enterprise at 4,999 USD. Public sector entities and publicly traded companies are ineligible for the free tier regardless of revenue.
Is iTextSharp free for commercial use?
Not for closed source software. iText for .NET is dual licensed AGPL and commercial. iText states you may not deploy it on a network without disclosing the full source code of your own application under the AGPL. Commercial licenses remove that obligation but have no published price, so you have to request a quote. Releases up to iTextSharp 4.1.6 were LGPL or MPL; everything from iText 5 onward is AGPL.
Can QuestPDF convert HTML to PDF?
No, and this is deliberate rather than a missing feature. QuestPDF markets itself on the line "Stop fighting with HTML-to-PDF conversion" and takes no HTML input at all. You compose the document in a fluent C# API instead. If your source is an existing Razor view or email template, using QuestPDF means rebuilding that layout in code and maintaining two versions of it.
How do I create a PDF document in C#?
Pick by where the document starts. If it starts as data, add QuestPDF or PDFsharp and declare the layout in C#, which is a few lines and needs no external engine. If it starts as HTML, you need a renderer with a CSS engine: iText pdfHTML, IronPDF, Playwright for .NET, or an HTTPS call to a rendering API.
What is the best free PDF library for .NET?
PDFsharp with MigraDoc, if free means free with no conditions. It is MIT licensed with no revenue ceiling, headcount limit or disclosure requirement. QuestPDF has the better API and is free under 1M USD revenue, but its Community license is source available rather than OSI approved open source, and it excludes public sector and publicly traded organizations.
Does PDFsharp support HTML to PDF?
No. PDFsharp draws content onto the page directly and MigraDoc adds a document model with paragraphs and tables, but neither contains a CSS engine or an HTML parser. Third party bridges exist that map a narrow subset of HTML onto MigraDoc, and they drop most real world CSS. If your source document is markup, use a browser based renderer instead.

Early access

Get on the early-access list

The API opens to the list first, in order. Early access locks the planned launch rates for 12 months. No card required, launching soon.

Render + archive, one API