iText vs IronPDF: Technical Comparison Guide
This comparison looks at both libraries across relevant technical aspects to assist developers and architects in making informed decisions for their .NET PDF needs.
Overview of iText / iTextSharp
iText is a dual-licensed PDF library that allows for creating PDFs from scratch, modifying existing documents, and performing tasks like adding text, images, and security features. The library uses a programmatic API approach where developers build PDF content using classes such as PdfWriter, PdfDocument, Document, Paragraph, Table, and Cell.
iText 7 utilizes namespaces like iText.Kernel.Pdf, iText.Layout, iText.Layout.Element, and iText.Html2pdf. PDF creation involves creating a PdfWriter, wrapping it in a PdfDocument, and then creating a Document for content layout. Text is added via Paragraph objects, tables via Table and Cell objects, and images via the Image class with ImageDataFactory.
For HTML-to-PDF conversion, iText requires the separate pdfHTML add-on, available via the iText.Html2pdf namespace with the HtmlConverter.ConvertToPdf() method. This add-on is sold separately at an additional cost.
iText is available under the AGPL license, which requires any software incorporating AGPL code in a web application to also be released as open source, or the developer must purchase a commercial license. iText has eliminated perpetual licensing, requiring annual subscription renewals for commercial use.
Overview of IronPDF
IronPDF is a commercial PDF library designed for .NET developers who prefer working with HTML and CSS rather than programmatic PDF construction. The library uses a modern Chromium rendering engine, providing accurate rendering of HTML5, CSS3, JavaScript, and modern layout systems like Flexbox and Grid.
IronPDF uses the ChromePdfRenderer class as its primary PDF generation mechanism with methods like RenderHtmlAsPdf(), RenderUrlAsPdf(), and RenderHtmlFileAsPdf(). The library returns PdfDocument objects that can be saved with SaveAs() or accessed as BinaryData. Configuration uses RenderingOptions properties for paper size, margins, headers, and footers.
IronPDF offers both perpetual and subscription licensing options, with no viral licensing requirements. HTML-to-PDF conversion is built into the base product without requiring separate add-ons.
Licensing and Business Model Comparison
The most significant difference between these libraries involves licensing and business implications.
| Feature | iText 7 / iTextSharp | IronPDF |
|---|---|---|
| License | AGPL (viral) or expensive subscription | Commercial, perpetual option |
| HTML-to-PDF | Separate pdfHTML add-on (additional cost) | Built-in Chromium renderer |
| Open Source Risk | Must open-source web apps under AGPL | No viral requirements |
| Pricing Model | Subscription only | Perpetual or subscription |
| Perpetual Option | Eliminated | Available |
The AGPL license trap is particularly problematic for commercial web applications. If you use iText in a web application without purchasing a commercial license, the AGPL requires you to open-source your entire application—not just the PDF code, but your entire codebase.
API Paradigm Comparison
The fundamental API design philosophy differs significantly between the libraries.
| Aspect | iText | IronPDF |
|---|---|---|
| API Paradigm | Programmatic (Paragraph, Table, Cell) | HTML-first with CSS |
| CSS Support | Basic CSS (via pdfHTML add-on) | Full CSS3, Flexbox, Grid |
| JavaScript | None | Full execution |
| Learning Curve | Steep (PDF coordinate system) | Web developer friendly |
| Content Construction | Manual low-level objects | HTML templates |
iText builds PDFs programmatically with explicit object construction. IronPDF uses HTML/CSS, allowing web developers to apply existing skills directly.
Code Comparison: Common PDF Operations
HTML to PDF Conversion
The most fundamental operation demonstrates the different approaches and add-on requirements.
iText (requires pdfHTML add-on):
// NuGet: Install-Package itext7
using iText.Html2pdf;
using System.IO;
class Program
{
static void Main()
{
string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
string outputPath = "output.pdf";
using (FileStream fs = new FileStream(outputPath, FileMode.Create))
{
HtmlConverter.ConvertToPdf(html, fs);
}
}
}// NuGet: Install-Package itext7
using iText.Html2pdf;
using System.IO;
class Program
{
static void Main()
{
string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
string outputPath = "output.pdf";
using (FileStream fs = new FileStream(outputPath, FileMode.Create))
{
HtmlConverter.ConvertToPdf(html, fs);
}
}
}IronPDF:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello World</h1><p>This is a PDF from HTML.</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}iText requires the separate iText.Html2pdf namespace (from the pdfHTML add-on), creates a FileStream manually, and calls HtmlConverter.ConvertToPdf() to write directly to the stream.
IronPDF creates a ChromePdfRenderer, calls RenderHtmlAsPdf() with the HTML string, and saves with SaveAs(). The Chromium engine provides full CSS3 and JavaScript support without additional add-ons.
For advanced HTML rendering options, explore the HTML to PDF conversion guide.
Creating PDFs with Text and Images
Programmatic PDF construction shows the paradigm difference most clearly.
iText:
// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.IO.Image;
class Program
{
static void Main()
{
string outputPath = "document.pdf";
using (PdfWriter writer = new PdfWriter(outputPath))
using (PdfDocument pdf = new PdfDocument(writer))
using (Document document = new Document(pdf))
{
document.Add(new Paragraph("Sample PDF Document"));
document.Add(new Paragraph("This document contains text and an image."));
Image img = new Image(ImageDataFactory.Create("image.jpg"));
img.SetWidth(200);
document.Add(img);
}
}
}// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.IO.Image;
class Program
{
static void Main()
{
string outputPath = "document.pdf";
using (PdfWriter writer = new PdfWriter(outputPath))
using (PdfDocument pdf = new PdfDocument(writer))
using (Document document = new Document(pdf))
{
document.Add(new Paragraph("Sample PDF Document"));
document.Add(new Paragraph("This document contains text and an image."));
Image img = new Image(ImageDataFactory.Create("image.jpg"));
img.SetWidth(200);
document.Add(img);
}
}
}IronPDF:
// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Sample PDF Document</h1>
<p>This document contains text and an image.</p>
<img src='image.jpg' width='200' />";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("document.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
class Program
{
static void Main()
{
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Sample PDF Document</h1>
<p>This document contains text and an image.</p>
<img src='image.jpg' width='200' />";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("document.pdf");
}
}iText requires creating a PdfWriter, wrapping it in a PdfDocument, creating a Document for layout, then adding Paragraph objects and Image objects created via ImageDataFactory. Each element requires explicit construction and configuration.
IronPDF uses standard HTML—headings, paragraphs, and <img> tags—all styled with familiar HTML attributes or CSS. The Chromium engine handles rendering, producing the same result with significantly less code.
Merging Multiple PDFs
Document merging demonstrates the API complexity differences.
iText:
// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Kernel.Utils;
using System.IO;
class Program
{
static void Main()
{
string outputPath = "merged.pdf";
string[] inputFiles = { "document1.pdf", "document2.pdf", "document3.pdf" };
using (PdfWriter writer = new PdfWriter(outputPath))
using (PdfDocument pdfDoc = new PdfDocument(writer))
{
PdfMerger merger = new PdfMerger(pdfDoc);
foreach (string file in inputFiles)
{
using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
{
merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
}
}
}
}
}// NuGet: Install-Package itext7
using iText.Kernel.Pdf;
using iText.Kernel.Utils;
using System.IO;
class Program
{
static void Main()
{
string outputPath = "merged.pdf";
string[] inputFiles = { "document1.pdf", "document2.pdf", "document3.pdf" };
using (PdfWriter writer = new PdfWriter(outputPath))
using (PdfDocument pdfDoc = new PdfDocument(writer))
{
PdfMerger merger = new PdfMerger(pdfDoc);
foreach (string file in inputFiles)
{
using (PdfDocument sourcePdf = new PdfDocument(new PdfReader(file)))
{
merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages());
}
}
}
}
}IronPDF:
// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;
class Program
{
static void Main()
{
var pdfDocuments = new List<PdfDocument>
{
PdfDocument.FromFile("document1.pdf"),
PdfDocument.FromFile("document2.pdf"),
PdfDocument.FromFile("document3.pdf")
};
var merged = PdfDocument.Merge(pdfDocuments);
merged.SaveAs("merged.pdf");
}
}// NuGet: Install-Package IronPdf
using IronPdf;
using System.Collections.Generic;
class Program
{
static void Main()
{
var pdfDocuments = new List<PdfDocument>
{
PdfDocument.FromFile("document1.pdf"),
PdfDocument.FromFile("document2.pdf"),
PdfDocument.FromFile("document3.pdf")
};
var merged = PdfDocument.Merge(pdfDocuments);
merged.SaveAs("merged.pdf");
}
}iText requires creating a PdfWriter for the output, creating a destination PdfDocument, creating a PdfMerger, then iterating through source files to create PdfReader and PdfDocument instances, calling merger.Merge() with page ranges, and managing disposal of all objects.
IronPDF loads documents with PdfDocument.FromFile(), creates a list, and calls the static PdfDocument.Merge() method. The operation is significantly more concise.
Learn more about PDF manipulation in the IronPDF tutorials.
API Mapping Reference
For developers evaluating iText migration or comparing capabilities, this mapping shows equivalent operations:
Class Mapping
| iText 7 Class | iTextSharp Class | IronPDF Equivalent |
|---|---|---|
PdfWriter | PdfWriter | ChromePdfRenderer |
PdfDocument | Document | PdfDocument |
Document | Document | ChromePdfRenderer.RenderHtmlAsPdf() |
Paragraph | Paragraph | HTML <p>, <h1>, etc. |
Table | PdfPTable | HTML <table> |
Cell | PdfPCell | HTML <td>, <th> |
Image | Image | HTML <img> |
List | List | HTML <ul>, <ol> |
ListItem | ListItem | HTML <li> |
PdfReader | PdfReader | PdfDocument.FromFile() |
PdfMerger | N/A | PdfDocument.Merge() |
PdfTextExtractor | PdfTextExtractor | pdf.ExtractAllText() |
Method Mapping
| Task | iText 7 | IronPDF |
|---|---|---|
| Create PDF from HTML | HtmlConverter.ConvertToPdf() | renderer.RenderHtmlAsPdf() |
| Create PDF from URL | Download HTML + convert | renderer.RenderUrlAsPdf() |
| Create PDF from file | HtmlConverter.ConvertToPdf(File.ReadAllText()) | renderer.RenderHtmlFileAsPdf() |
| Save to file | document.Close() (via stream) | pdf.SaveAs() |
| Save to bytes | memoryStream.ToArray() | pdf.BinaryData |
| Open existing PDF | new PdfDocument(new PdfReader(path)) | PdfDocument.FromFile() |
| Merge PDFs | PdfMerger.Merge() | PdfDocument.Merge() |
| Extract text | PdfTextExtractor.GetTextFromPage() | pdf.ExtractAllText() |
Styling Mapping
| iText 7 Method | IronPDF Equivalent |
|---|---|
SetTextAlignment(TextAlignment.CENTER) | CSS text-align: center |
SetFontSize(12) | CSS font-size: 12px |
SetBold() | CSS font-weight: bold |
SetBackgroundColor() | CSS background-color |
SetBorder() | CSS border |
Feature Comparison Summary
| Feature | iText | IronPDF |
|---|---|---|
| Programmatic PDF Construction | ✅ (Primary approach) | ⚠️ (Via HTML) |
| HTML-to-PDF | ⚠️ (Requires pdfHTML add-on) | ✅ (Built-in) |
| CSS3 Support | ⚠️ (Basic via pdfHTML) | ✅ (Full) |
| Flexbox/Grid | ❌ | ✅ |
| JavaScript Execution | ❌ | ✅ |
| PDF Merging | ✅ (PdfMerger) | ✅ (PdfDocument.Merge()) |
| Text Extraction | ✅ (PdfTextExtractor) | ✅ (ExtractAllText()) |
| Perpetual License | ❌ (Eliminated) | ✅ |
| No AGPL Risk | ❌ (AGPL or subscription) | ✅ |
| Community Support | ✅ (Extensive) | ✅ |
When Teams Consider Moving from iText to IronPDF
Development teams evaluate transitioning from iText to IronPDF for several reasons:
AGPL License Trap: The AGPL license is highly restrictive for commercial web applications. If you use iText in a web application without purchasing a commercial license, the AGPL requires you to open-source your entire application—not just the PDF code, but your entire codebase. Teams developing proprietary software often cannot accept this viral licensing requirement.
Subscription-Only Commercial Licensing: iText has eliminated perpetual licensing, requiring annual subscription renewals for commercial use. Teams preferring one-time purchases find IronPDF's perpetual licensing option more suitable for budgeting.
pdfHTML Add-On Cost: To convert HTML to PDF with iText, developers must invest in the separate pdfHTML add-on, which increases costs and complexity. IronPDF includes HTML-to-PDF conversion in the base product with a modern Chromium rendering engine.
Programmatic API Complexity: iText requires manual low-level PDF construction with Paragraph, Table, Cell, and other objects. Teams with web development experience find IronPDF's HTML/CSS approach more intuitive and productive.
Modern Web Standards: Even with pdfHTML, iText has limited support for complex CSS and JavaScript. IronPDF's Chromium engine provides full CSS3, Flexbox, Grid, and JavaScript execution for modern web content.
Simplified Codebase: Converting from iText's programmatic approach to IronPDF's HTML-first paradigm often results in significantly less code. Report tables that require dozens of lines with Table, Cell, and Paragraph objects become simple HTML tables with CSS styling.
Strengths and Considerations
iText Strengths
- Comprehensive Feature Set: Extensive PDF manipulation capabilities
- Wide Adoption: Large community and extensive documentation
- Cross-Platform: Works across various .NET platforms
- Fine-Grained Control: Direct PDF object manipulation for specialized needs
iText Considerations
- AGPL License: Viral license requires open-sourcing web applications or commercial subscription
- Subscription Only: Perpetual licensing eliminated
- pdfHTML Add-On: HTML-to-PDF requires separate purchase
- Programmatic Complexity: Steep learning curve with PDF coordinate system
- Limited Modern CSS: Basic CSS support even with pdfHTML
- No JavaScript: Cannot execute JavaScript in HTML content
IronPDF Strengths
- Perpetual Licensing: Option for one-time purchase
- No AGPL Risk: Keep proprietary code closed-source
- Built-in HTML-to-PDF: No separate add-on required
- Chromium Engine: Full CSS3, Flexbox, Grid, JavaScript support
- Web Developer Friendly: Uses familiar HTML/CSS skills
- Simpler API: Concise methods for common operations
- Comprehensive Resources: Extensive tutorials and documentation
IronPDF Considerations
- Commercial License: Required for production use
- HTML-First Paradigm: Different approach from programmatic construction
Conclusion
iText and IronPDF represent fundamentally different approaches to PDF generation in .NET applications. iText provides comprehensive programmatic PDF construction using classes like Paragraph, Table, and Cell, but carries significant licensing concerns—the AGPL requires open-sourcing web applications, perpetual licensing has been eliminated, and HTML-to-PDF requires a separate pdfHTML add-on purchase.
IronPDF provides a modern alternative with built-in HTML-to-PDF conversion using a Chromium engine, perpetual licensing options, and no viral licensing requirements. The HTML-first approach allows web developers to apply existing skills directly, often resulting in simpler, more maintainable code.
As organizations plan for .NET 10, C# 14, and application development through 2026, the choice between AGPL-licensed programmatic PDF construction and commercially-licensed HTML-based rendering significantly impacts both legal compliance and development productivity. Teams seeking to eliminate AGPL risk, reduce licensing complexity, or leverage web development skills for PDF generation will find IronPDF addresses these requirements effectively.
Start evaluating IronPDF with a free trial and explore the comprehensive documentation to assess fit for your specific requirements.