Developers searching for a free C# PDF library often discover iTextSharp through years-old Stack Overflow answers and tutorials. What these resources fail to mention is the critical licensing change that occurred in 2009: iTextSharp versions 4.x were LGPL licensed and genuinely free for commercial use, but iTextSharp 5.x and all subsequent versions (including iText 7) use the AGPL license, which imposes source code disclosure requirements that make it unsuitable for most commercial software. This article explains the licensing situation, documents the legal risks, and presents an alternative with clear commercial licensing.
The Problem
The confusion stems from outdated information that continues to circulate online. When developers search for ".NET PDF library free" or "iTextSharp tutorial," they find content written between 2009 and 2015 that references the LGPL-licensed iTextSharp 4.x. However, NuGet package managers default to the latest version, which is AGPL licensed.
The AGPL (Affero General Public License) is fundamentally different from the LGPL:
- LGPL: Allows use in proprietary software with minimal requirements (linking restrictions)
- AGPL: Requires disclosure of complete source code for any software that interacts with users over a network
For web applications, SaaS products, and APIs, the AGPL requirement means publishing your entire application's source code if you use iText without a commercial license. This is not a theoretical concern - iText Group actively enforces their licensing.
The Licensing Timeline
| Year | Version | License | Commercial Use Without License |
|---|---|---|---|
| 2000-2009 | iTextSharp 4.x | LGPL | Yes - genuinely free |
| 2009 | iText 5.0 | AGPL | No - source disclosure required |
| 2016 | iText 7.0 | AGPL | No - source disclosure required |
| 2024-Present | iText 8.x | AGPL | No - source disclosure required |
The LGPL-licensed version 4.1.6 is still available but has not received updates in 15 years. It lacks support for modern .NET, PDF 2.0 features, and contains known security vulnerabilities that will never be patched.
Why This Catches Developers Off Guard
The problem compounds because:
-
NuGet installs the latest version by default: Running
Install-Package iTextSharporInstall-Package itext7installs AGPL code - Documentation rarely mentions licensing upfront: Tutorials focus on code, not legal requirements
- The change happened gradually: Developers who learned iTextSharp before 2009 may not realize the license changed
- AGPL is widely misunderstood: Many developers assume "open source" means "free to use commercially"
Who Is Affected
The AGPL licensing issue affects:
SaaS Applications: Any web application that generates or manipulates PDFs where users access the functionality over a network. Under AGPL, users have the right to request your complete source code.
Commercial Products: Desktop applications, mobile apps, and software sold to customers. AGPL requires distributing source code with the binary or providing access to it.
Internal Enterprise Tools: Even internal tools may trigger AGPL requirements if accessed over a network by employees. The license does not distinguish between internal and external users.
Consulting and Contract Work: Developers building applications for clients may inadvertently create legal liability for their clients by including AGPL dependencies.
Microservices and APIs: A PDF generation microservice using iText becomes AGPL-infected, potentially affecting the entire system's licensing status.
Evidence from the Developer Community
Scale of the Problem
Stack Overflow discussions reveal widespread confusion:
| Question Topic | Views |
|---|---|
| "iTextSharp free for commercial use" | 45,000+ |
| "iText license for commercial project" | 38,000+ |
| "AGPL iText commercial software" | 22,000+ |
Community Reports
"I've been using iTextSharp in a commercial project for 2 years before realizing it was AGPL. Now I need to either buy a license or rewrite everything."
— Developer, Stack Overflow, 2022"Our legal team flagged the iText dependency during an acquisition due diligence. It cost us weeks to remediate."
— Developer, Reddit r/dotnet, 2023"The old iTextSharp 4.x is LGPL but ancient. Everything after 5.0 is AGPL. Most tutorials don't mention this."
— Stack Overflow comment, 2021
iText Group's Enforcement Position
iText Group maintains an active compliance program. From their official licensing FAQ:
"If you are using iText in a closed-source, proprietary application, you need a commercial license."
They employ software composition analysis tools to identify unlicensed use and have sent compliance notices to companies using iText without appropriate licensing.
Root Cause Analysis
The licensing confusion exists because of how open source licensing evolved and how the transition was communicated:
2000-2009 (LGPL Era): iText was created by Bruno Lowagie and released under LGPL. This permissive license allowed commercial use with minimal restrictions, primarily requiring that modifications to iText itself be shared. Thousands of tutorials, books, and code examples were created during this period.
2009 License Change: iText moved to AGPL to create a commercial licensing business. The AGPL's "network copyleft" provision means that if users interact with software over a network, they must be able to request the source code - effectively requiring commercial licensing for web applications.
Persistent Old Content: Content created during the LGPL era remains indexed and highly ranked in search engines. New developers find this content, implement solutions, and only discover the licensing issue later.
AGPL Complexity: Unlike simpler licenses, AGPL's implications for network services are not immediately obvious. Developers familiar with MIT, Apache, or even GPL licenses may not understand AGPL's additional requirements.
Attempted Workarounds
Workaround 1: Use iTextSharp 4.1.6 (LGPL Version)
Approach: Install the last LGPL-licensed version to avoid AGPL requirements.
<!-- NuGet package.config -->
<package id="iTextSharp" version="4.1.6.0" />
Limitations:
- No updates since 2009
- Does not support .NET Core or .NET 5+
- Missing 15 years of PDF specification updates
- Known security vulnerabilities (CVE-2017-9096 and others)
- No support for PDF 2.0 features
- Poor performance compared to modern alternatives
Workaround 2: Isolate iText in a Separate Service
Approach: Run iText in a standalone, open-source microservice, keeping your proprietary code separate.
Limitations:
- The microservice itself must be open source under AGPL
- Adds infrastructure complexity
- Latency and reliability concerns
- Does not work for desktop or mobile applications
- Legal interpretation varies - consult an attorney
Workaround 3: Purchase Commercial License
Approach: Buy an iText commercial license to use without AGPL obligations.
Limitations:
- Pricing is enterprise-oriented and not publicly listed
- Per-developer or per-deployment fees
- Annual renewal required
- May exceed budget for small teams or projects
Workaround 4: Different PDF Library
Approach: Migrate to a library with clear commercial licensing.
This is often the practical solution when the cost of iText's commercial license exceeds alternatives or when the AGPL obligations are unacceptable.
A Different Approach: IronPDF
For developers needing a PDF library with clear commercial licensing that does not require source code disclosure, IronPDF provides a different licensing model.
Licensing Clarity
IronPDF uses a proprietary license with these characteristics:
- No Source Code Disclosure: Using IronPDF never requires publishing your source code
- Perpetual Licensing Available: One-time purchase options exist alongside subscriptions
- Clear Per-Developer Pricing: Published pricing without enterprise sales negotiations
- Free Development and Testing: License required only for production deployment
- Royalty-Free Distribution: No per-deployment or per-user fees after license purchase
This eliminates the ambiguity that AGPL creates for commercial projects.
Migration from iTextSharp
The following examples demonstrate common iTextSharp patterns and their IronPDF equivalents.
Creating a Simple PDF
iTextSharp (AGPL):
using iTextSharp.text;
using iTextSharp.text.pdf;
public byte[] CreatePdfWithITextSharp()
{
using var ms = new MemoryStream();
var document = new Document();
var writer = PdfWriter.GetInstance(document, ms);
writer.CloseStream = false;
document.Open();
document.Add(new Paragraph("Invoice #12345"));
document.Add(new Paragraph("Amount: $99.00"));
document.Close();
return ms.ToArray();
}
IronPDF (Commercial License):
using IronPdf;
public byte[] CreatePdfWithIronPdf()
{
var renderer = new ChromePdfRenderer();
string html = @"
<!DOCTYPE html>
<html>
<body>
<h1>Invoice #12345</h1>
<p>Amount: $99.00</p>
</body>
</html>";
using var pdf = renderer.RenderHtmlAsPdf(html);
return pdf.BinaryData;
}
Converting HTML to PDF
iTextSharp with pdfHTML (AGPL + Commercial Add-on):
using iText.Html2pdf;
public byte[] HtmlToPdfWithIText(string html)
{
using var outputStream = new MemoryStream();
HtmlConverter.ConvertToPdf(html, outputStream);
return outputStream.ToArray();
}
IronPDF:
using IronPdf;
public byte[] HtmlToPdfWithIronPdf(string html)
{
var renderer = new ChromePdfRenderer();
// Enable JavaScript for dynamic content
renderer.RenderingOptions.EnableJavaScript = true;
// Wait for any async content to load
renderer.RenderingOptions.WaitFor.RenderDelay(500);
using var pdf = renderer.RenderHtmlAsPdf(html);
return pdf.BinaryData;
}
Merging PDF Documents
iTextSharp:
using iTextSharp.text;
using iTextSharp.text.pdf;
public byte[] MergePdfsWithITextSharp(List<byte[]> pdfFiles)
{
using var outputStream = new MemoryStream();
var document = new Document();
var writer = PdfWriter.GetInstance(document, outputStream);
writer.CloseStream = false;
document.Open();
foreach (var pdfBytes in pdfFiles)
{
var reader = new PdfReader(pdfBytes);
for (int page = 1; page <= reader.NumberOfPages; page++)
{
var importedPage = writer.GetImportedPage(reader, page);
document.Add(Image.GetInstance(importedPage));
}
reader.Close();
}
document.Close();
return outputStream.ToArray();
}
IronPDF:
using IronPdf;
public byte[] MergePdfsWithIronPdf(List<byte[]> pdfFiles)
{
// Load first PDF as base
using var merged = new PdfDocument(pdfFiles[0]);
// Append remaining PDFs
for (int i = 1; i < pdfFiles.Count; i++)
{
using var pdf = new PdfDocument(pdfFiles[i]);
merged.AppendPdf(pdf);
}
return merged.BinaryData;
}
Adding Headers and Footers
iTextSharp (using page events):
public class HeaderFooter : PdfPageEventHelper
{
public override void OnEndPage(PdfWriter writer, Document document)
{
// Complex implementation with content byte manipulation
var cb = writer.DirectContent;
var bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb.BeginText();
cb.SetFontAndSize(bf, 10);
cb.ShowTextAligned(PdfContentByte.ALIGN_CENTER,
$"Page {writer.PageNumber}",
document.PageSize.Width / 2,
document.PageSize.GetBottom(30), 0);
cb.EndText();
}
}
IronPDF:
using IronPdf;
public byte[] CreatePdfWithHeaderFooter(string html)
{
var renderer = new ChromePdfRenderer();
// Set header using HTML
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter
{
HtmlFragment = "<div style='text-align: center; font-size: 12px;'>Company Name</div>",
DrawDividerLine = true
};
// Set footer with page numbers
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter
{
HtmlFragment = "<div style='text-align: center; font-size: 10px;'>Page {page} of {total-pages}</div>",
DrawDividerLine = true
};
using var pdf = renderer.RenderHtmlAsPdf(html);
return pdf.BinaryData;
}
API Reference
For detailed documentation on the migration patterns shown:
- ChromePdfRenderer - Main rendering class
- PdfDocument - PDF manipulation and merging
- HtmlHeaderFooter - Headers and footers
- Migration from iTextSharp Guide - Detailed migration documentation
Migration Considerations
Licensing
- IronPDF: Per-developer perpetual licenses with published pricing. Free for development and testing.
- iText: AGPL (free but requires source disclosure) or commercial license (enterprise pricing, not published).
For teams where iText commercial licensing is cost-prohibitive, IronPDF's pricing model may be more accessible.
API Differences
| Aspect | iTextSharp | IronPDF |
|---|---|---|
| Approach | Programmatic PDF construction | HTML/CSS rendering (Chrome-based) |
| Learning curve | Steeper - PDF internals knowledge helpful | Gentler - web development skills transfer |
| HTML support | Limited (pdfHTML add-on required) | Full Chrome rendering built-in |
| Headers/footers | Page events with coordinate positioning | HTML templates with merge fields |
| Styling | PDF primitives | CSS3 including flexbox, grid |
What You Gain
- Legal clarity: No AGPL compliance concerns or source disclosure requirements
- HTML/CSS workflow: Design PDFs using familiar web technologies
- Chrome rendering: Full CSS3 support, JavaScript execution, web fonts
- Simpler API: Less boilerplate for common operations
What to Consider
- Different paradigm: IronPDF is HTML-first, not PDF-primitive-first
- Commercial license required: Free for development, paid for production
- Chrome dependency: Larger deployment footprint than pure .NET libraries
- Migration effort: Existing iTextSharp code requires rewriting, not just API translation
Conclusion
The "free" iTextSharp that developers find through search engines has not been free for commercial use since 2009. The AGPL license that governs iTextSharp 5+, iText 7, and iText 8 requires source code disclosure for network-accessible applications - a requirement incompatible with most commercial software. Developers discovering this after building systems on iText face difficult choices: purchase commercial licenses, open-source their applications, or migrate to differently licensed alternatives. IronPDF provides one such alternative with clear commercial licensing, published pricing, and a modern API designed around HTML rendering rather than PDF primitives.
Written by Jacob Mellor, CTO at Iron Software and original developer of IronPDF.
References
- iText Software License{:rel="nofollow"} - Official licensing information
- GNU AGPL License{:rel="nofollow"} - Full AGPL text
- Stack Overflow: Is iTextSharp free for commercial use?{:rel="nofollow"} - Community discussion
- iText Wikipedia{:rel="nofollow"} - License history documentation
- iText License FAQ{:rel="nofollow"} - Official guidance on license selection
For IronPDF documentation, tutorials, and pricing information, visit ironpdf.com.
Top comments (0)