From version 6.5.0, PDFsharp and MigraDoc are dual-licensed: AGPL-3.0, or a commercial license that empira, the publisher, sells for €750. Version 6.2.4 and earlier were published under the MIT license and are still on NuGet. Version 6.5.0 also changes code: your program has to load one of the two licenses, or PDFsharp throws PdfSharpLicenseException. If your product isn’t AGPL and you don’t want to buy the license, you can pin 6.2.4 or move to a permissively licensed library. This page sets out what changed, quoting empira’s own pages, then shows the fix for the exception and how PDFsharp code moves to OnePDF (MIT OR Apache-2.0).
The facts below come from empira’s license page, license FAQ, pricing page and the NuGet listings, all read on 26 October 2026. empira’s FAQ says of itself, “This is not a legal consultation”, and the same goes for this page.
Which PDFsharp versions are MIT and which are AGPL
| Package and version | Published on NuGet | License on NuGet |
|---|---|---|
| PDFsharp 6.2.4 | 6 January 2026 | MIT |
| PDFsharp 7.0.0 Preview 1 | 24 March 2026 | MIT |
| PDFsharp 6.5.0 and PDFsharp-MigraDoc 6.5.0 | 14 October 2026 | AGPL-3.0-only |
| PDFsharp 7.0.0 Preview 2 | 14 October 2026 | AGPL-3.0-only |
empira’s license page covers “Version 6.5.0 and later • Version 7.0.0 Preview 2 and later” and says “PDFsharp and MigraDoc are published under a Dual License consisting of AGPL and a commercial license”. Its AGPL notice uses the wording “either version 3 of the License, or (at your option) any later version”, while the NuGet listings give the expression AGPL-3.0-only. The PDFsharp samples stay under MIT. The page also says “PDFsharp has been open source from the very beginning and will remain open source.”
PdfSharpCore is a different package: a partial port of PDFsharp by other authors, whose package ships an MIT license file. Its latest release, 1.3.67, came out in April 2025 and targets up to .NET 8.
What the AGPL and the commercial license mean, per empira
The pricing page compares the two:
- AGPL (“Community, remaining free”): “Free use in open‑source projects”, “Use in closed‑source projects prohibited”, “Requires your project to be licensed with AGPL, too”. The full libraries, perpetual.
- Commercial, €750: “Free use in proprietary, closed‑source, internal, hosted, SaaS, and commercial applications and services”, “Unlimited developers, projects, servers, and deployments”, perpetual, “No subscription model”, and “Includes all updates for the 6.5.x and 7.0.x release line”. Prices exclude VAT and “are addressed exclusively to business customers (B2B)”.
In empira’s words: “For using PDFsharp and MigraDoc in closed‑source or differently licensed products, you have to purchase a commercial license.” The license FAQ adds that commercial use is allowed under the AGPL, but “AGPL requires publication of the source code of your projects under AGPL”, that you don’t pay royalties, and that you don’t have to mention PDFsharp in your product.
PdfSharpLicenseException after upgrading to 6.5.0
“Beginning with version 6.5.0, your code must select the type of license to be used” (readme for 6.5). Code written for 6.2.4, like this, compiles against 6.5.0 and fails at run time:
using PdfSharp.Drawing; using PdfSharp.Pdf; // PDFsharp 6.5.0 without a license call var document = new PdfDocument(); var page = document.AddPage(); var gfx = XGraphics.FromPdfPage(page); gfx.DrawLine(XPens.Red, 0, 0, page.Width.Point, page.Height.Point); document.Save("lines.pdf");
Unhandled exception. PdfSharp.License.PdfSharpLicenseException: The loaded license is not valid. at PdfSharp.License.PdfSharpLicenseImpl.CheckLicense() at PdfSharp.PdfSharpLicense.CheckLicense() at PdfSharp.Pdf.PdfDocument..ctor()
The fix, from empira’s license loading page, is one call at the start of the program, before any other PDFsharp code:
using PdfSharp; using PdfSharp.Drawing; using PdfSharp.Pdf; PdfSharpLicense.SetAgplLicense(); // or PdfSharpLicense.LoadLicense(yourLicenseKey) var document = new PdfDocument(); var page = document.AddPage(); var gfx = XGraphics.FromPdfPage(page); gfx.DrawLine(XPens.Red, 0, 0, page.Width.Point, page.Height.Point); document.Save("lines.pdf");
With the AGPL license loaded, the file’s document properties read “Creator: PDFsharp 6.5.0 (www.pdfsharp.com) (AGPL license)” and “Producer: PDFsharp 6.5.0 (AGPL license)”. empira also warns that “after an Update of PDFsharp, your license could get invalid - depending on the supported versions of your license.”
Your options
- Stay on 6.2.4. It was published under MIT and is still on NuGet. Pin the exact version so an update doesn’t move you to 6.5.0:
<PackageReference Include="PDFsharp" Version="[6.2.4]" />. - Use the AGPL. Call
SetAgplLicense()and license your own project under the AGPL. - Buy the commercial license. €750, perpetual, for business customers, covering the 6.5.x and 7.0.x lines.
- Move to a permissively licensed library. The rest of this page covers that.
PDFsharp alternatives with a permissive license
PDFsharp is used for two kinds of work: page-level work with PDFsharp itself (opening files, importing pages, drawing on them) and document layout with MigraDoc. OnePDF covers both under MIT OR Apache-2.0: the core RecursiveAI.OnePdf package for pages and drawing, and RecursiveAI.OnePdf.Layout for documents.
From PDFsharp: pages, imports and drawing
A typical PDFsharp job opens a file, appends another file’s pages and stamps a footer on every page. In OnePDF:
using OnePdf; // Open, append another file's pages, stamp a footer on every page, save. using PdfDocument doc = PdfDocument.Open("chapter-1.pdf", new PdfOpenOptions { AllowEditing = true }); using (PdfDocument w9 = PdfDocument.Open("fw9.pdf")) doc.ImportPages(w9); PdfCreatedFont font = doc.AddStandardFont("Helvetica"); for (int i = 0; i < doc.PageCount; i++) { using PdfPageContentBuilder footer = doc.Pages[i].BeginContent(); footer.SetFont(font, 9); footer.DrawText($"Page {i + 1} of {doc.PageCount}", 72, 24); footer.Commit(); } doc.Save("numbered.pdf"); Console.WriteLine($"{doc.PageCount} pages, {doc.Form?.TerminalFields.Count() ?? 0} form fields");
8 pages, 23 form fieldsThe input is a two-page document plus the six-page IRS Form W-9. Its 23 form fields come along with its pages, and each page ends with “Page 1 of 8” to “Page 8 of 8”. The calls map like this:
| PDFsharp | OnePDF |
|---|---|
PdfReader.Open(path, PdfDocumentOpenMode.Import) | PdfDocument.Open(path) |
PdfReader.Open(path, PdfDocumentOpenMode.Modify) | PdfDocument.Open(path, new PdfOpenOptions { AllowEditing = true }) |
new PdfDocument() | PdfDocument.CreateEmpty() |
document.AddPage(importedPage) | doc.ImportPages(source, [index]) |
document.Pages.RemoveAt(index) | doc.RemovePage(index) |
page.Rotate = 90 | doc.SetPageRotation(index, 90) |
XGraphics.FromPdfPage(page) | doc.Pages[i].BeginContent(), then Commit() |
The full map, including encryption and metadata, is in migrating from PDFsharp. OnePDF also covers things PDFsharp’s FAQ (marked version 6.2.0) describes as missing or limited: text extraction (“There are no high-level functions that return words, paragraphs, or whole pages”), PDF/A (the FAQ says “Not yet with PDFsharp 6.1”; the 6.2.0 archiving page calls support “under construction” and “in a very early state”), AcroForms (“limited support”), and object streams (“PDFsharp does not yet write object streams”). OnePDF reads and writes object streams, extracts text in reading order, fills and flattens forms, and saves PDF/A and PDF/UA.
From MigraDoc: documents with OnePdf.Layout
MigraDoc’s job, describing paragraphs, tables, headers and footers and letting the library paginate, is what OnePdf.Layout does, with a fluent C# API. Create a PDF in C# builds a multi-page invoice with it. The project’s published layout benchmark compares it with MigraDoc 6.2.4: a 50-page report with tables, images and page X of Y took 37.1 ms against 175 ms, and a 10,000-row table took 362 ms against 1,191 ms (BenchmarkDotNet means, AMD Ryzen 9 7950X3D, Linux, .NET 10.0.13). The benchmark notes that MigraDoc draws Arabic and Devanagari unshaped, while OnePdf.Layout shapes them.
What to check before you switch
- Target framework: OnePDF targets
net10.0only. PDFsharp 6.5.0 also targets .NET Standard 2.0, .NET 8 and .NET 9. - Windows drawing: PDFsharp’s GDI+ and WPF builds draw to windows and printers as well as PDF (features). OnePDF writes PDF only and has no viewer or printing.
- HTML: neither library converts HTML to PDF.
Other options: PdfPig (Apache-2.0) if you only read text, and QuestPDF, free under its community license for eligible users. They are compared in choosing a C# PDF library. iText, the other library that moved developers to the AGPL, is covered in iText license cost.
Common questions
Is PDFsharp free?
Under the AGPL, yes: empira calls that column “Community, remaining free”. In closed-source or differently licensed products, version 6.5.0 and later need the €750 commercial license. Versions up to 6.2.4 were published under MIT.
Is PDFsharp still open source?
Yes. The AGPL is an open-source license, and empira says PDFsharp “will remain open source”. What changed is that the AGPL is a copyleft license, where MIT was permissive.
Does MigraDoc have the same license?
Yes. PDFsharp-MigraDoc 6.5.0 is AGPL-3.0-only on NuGet, and the commercial license covers both PDFsharp and MigraDoc.
Can I keep using PDFsharp 6.2.4?
6.2.4 is on NuGet with the MIT license. The releases published since, 6.5.0 and 7.0.0 Preview 2, are AGPL or commercial. To move to a permissively licensed library instead, run dotnet add package RecursiveAI.OnePdf and start with getting started.