IRONSOFTWAREHOME
MIGRATION GUIDES

How to Migrate from iText to IronPDF in C#

Curtis Chau
Curtis Chau
Updated: August 1, 2026

Migrating from iText to IronPDF moves your .NET PDF workflow from a programmatic API - building Paragraph, Table, and Cell objects in code - to an HTML-first approach with CSS3 and JavaScript support. This guide provides a step-by-step migration path that removes AGPL exposure and the need for a separate pdfHTML add-on.

Why Migrate from iText to IronPDF

The AGPL License Consideration

iText (owned by iText Group / Apryse Group NV) carries licensing characteristics commercial teams should weigh up front:

  1. AGPL Viral License: If you use iText under its open-source license in a web application, the AGPL is typically interpreted as requiring you to release your application's source to anyone who interacts with it over a network. For closed-source commercial software this usually means buying a commercial license instead.
  2. Subscription-Only Commercial Licensing: iText's commercial license is sold as an annual subscription based on PDF processing volume; a perpetual option is not advertised on the public pricing page (custom OEM terms are quote-only).
  3. pdfHTML Add-On Cost: HTML-to-PDF requires the itext.pdfhtml add-on (currently 6.3.2), sold separately on top of the core itext package (currently 9.6.0).
  4. Complex Licensing Audits: Enterprise deployments face licensing complexity and audit risk.
  5. Programmatic-First API: Core iText builds PDFs by composing Paragraph, Table, and Cell objects in code; pdfHTML lets you start from HTML.
  6. Defined CSS Subset, No JS at Render Time: pdfHTML supports a defined subset of CSS and does not execute JavaScript while converting HTML to PDF (PDF-level JS form actions are a separate, supported feature).

iText vs IronPDF Comparison

FeatureiText 9 / iTextSharp 5.xIronPDF
LicenseAGPL (viral) or commercial annual subscriptionCommercial, perpetual option
HTML-to-PDFSeparate itext.pdfhtml add-on (6.3.2)Built-in Chromium renderer
CSS SupportDefined CSS subset in pdfHTMLFull CSS3, Flexbox, Grid
JavaScript at renderpdfHTML does not run JS during HTML→PDFFull JS execution at render time
API ParadigmProgrammatic (Paragraph, Table, Cell)HTML-first with CSS
Learning CurveSteep (PDF coordinate system)Web developer friendly
Open Source RiskMust open-source web apps under AGPLNo viral requirements
Pricing ModelAnnual subscription (volume-based) or custom OEMPerpetual or subscription

For teams standardising on modern .NET, IronPDF's HTML-first approach leans on web development skills the team already has.


Migration Complexity Assessment

Estimated Effort by Feature

FeatureMigration Complexity
HTML to PDFVery Low
Merge PDFsLow
Text and ImagesLow
TablesMedium
Headers/FootersMedium
Security/EncryptionLow

Paradigm Shift

The fundamental shift in this iText migration is from programmatic PDF construction to HTML-first rendering:

iText:    PdfWriter → PdfDocument → Document → Add(Paragraph) → Add(Table)
IronPDF:  ChromePdfRenderer → RenderHtmlAsPdf(htmlString) → SaveAs()
Text

This paradigm shift is liberating: instead of learning iText's object model, you use HTML and CSS skills that web developers already possess.


Before You Start

Prerequisites

  1. .NET Environment: .NET Framework 4.6.2+ or .NET Core 3.1+ / .NET 5/6/7/8/9+
  2. NuGet Access: Ability to install NuGet packages
  3. IronPDF License: Obtain your license key from ironpdf.com

NuGet Package Changes

# Remove iText packages (current naming is 'itext'; 'itext7' is the deprecated alias)
dotnet remove package itext
dotnet remove package itext.pdfhtml
dotnet remove package itext7
dotnet remove package itext7.pdfhtml
dotnet remove package itextsharp

# Install IronPDF
dotnet add package IronPdf
SHELL

License Configuration

// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";

Identify iText Usage

# Find all iText references
grep -r "using iText\|using iTextSharp" --include="*.cs" .
grep -r "PdfWriter\|PdfDocument\|Document\|Paragraph\|Table\|Cell" --include="*.cs" .
grep -r "HtmlConverter\|ConverterProperties" --include="*.cs" .
SHELL

Complete API Reference

Class Mappings

iText 7+ ClassiTextSharp 5.x ClassIronPDF Equivalent
PdfWriterPdfWriterChromePdfRenderer
PdfDocumentDocumentPdfDocument
DocumentDocumentChromePdfRenderer.RenderHtmlAsPdf()
ParagraphParagraphHTML <p>, <h1>, etc.
TablePdfPTableHTML <table>
CellPdfPCellHTML <td>, <th>
ImageImageHTML <img>
PdfReaderPdfReaderPdfDocument.FromFile()
PdfMergerN/APdfDocument.Merge()

Namespace Mappings

iText NamespaceIronPDF Equivalent
iText.Kernel.PdfIronPdf
iText.LayoutIronPdf
iText.Layout.ElementUse HTML elements
iText.Html2pdfIronPdf (built-in)
iText.IO.ImageUse HTML <img>
iText.Kernel.UtilsIronPdf

Code Migration Examples

Example 1: HTML to PDF Conversion

Before (iText):

// 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);
        }
    }
}

After (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");
    }
}

The iText approach requires the separate itext.pdfhtml package (pdfHTML add-on, currently 6.3.2, sold separately on top of itext 9.6.0), creating a FileStream, and wrapping everything in using statements for proper disposal. The HtmlConverter.ConvertToPdf() method writes directly to the stream.

IronPDF's approach is cleaner: create a ChromePdfRenderer, call RenderHtmlAsPdf() with your HTML string, and call SaveAs() on the resulting PdfDocument. No separate packages, no stream management, and the Chromium rendering engine provides superior CSS3 and JavaScript support. See the HTML to PDF documentation for additional rendering options.

Example 2: Merge Multiple PDFs

Before (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());
                }
            }
        }
    }
}

After (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");
    }
}

The iText merge operation requires significant boilerplate: creating a PdfWriter for output, wrapping it in a PdfDocument, creating a PdfMerger, then iterating through source files with nested using statements for each PdfDocument and PdfReader. You must also specify page ranges with merger.Merge(sourcePdf, 1, sourcePdf.GetNumberOfPages()).

IronPDF reduces this to three steps: load documents with PdfDocument.FromFile(), call the static PdfDocument.Merge() method with the list, and save. The entire merge operation becomes readable and maintainable. Learn more about merging and splitting PDFs.

Example 3: Create PDF with Text and Images

Before (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);
        }
    }
}

After (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");
    }
}

This example illustrates the paradigm shift most clearly. iText requires:

  • Triple-nested using statements (PdfWriter, PdfDocument, Document)
  • Creating Paragraph objects for each text element with new Paragraph()
  • Using ImageDataFactory.Create() to load images
  • Creating an Image object and calling SetWidth() separately
  • Calling document.Add() for each element

IronPDF uses standard HTML: <h1> for headings, <p> for paragraphs, and <img> for images with a width attribute. Web developers can leverage their existing skills immediately, and designers can style documents using CSS they already know.


Critical Migration Notes

Paradigm Shift: Programmatic to HTML-First

The most significant change in this iText migration is conceptual. iText builds PDFs programmatically:

// iText approach
document.Add(new Paragraph("Title")
    .SetTextAlignment(TextAlignment.CENTER)
    .SetFontSize(24)
    .SetBold());

var table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth();
table.AddHeaderCell(new Cell().Add(new Paragraph("ID")));
table.AddHeaderCell(new Cell().Add(new Paragraph("Name")));
// ... many more lines

IronPDF uses HTML and CSS:

// IronPDF approach
string html = @"
    <style>
        h1 { text-align: center; font-size: 24px; font-weight: bold; }
        table { width: 100%; border-collapse: collapse; }
        th { background-color: #4CAF50; color: white; padding: 8px; }
    </style>
    <h1>Title</h1>
    <table>
        <tr><th>ID</th><th>Name</th></tr>
    </table>";

var pdf = renderer.RenderHtmlAsPdf(html);

AGPL Exposure Removed

Under iText's AGPL terms, a web application that uses iText is typically expected to release its source to anyone who interacts with it over a network; the commercial license is the alternative path. IronPDF's commercial license allows deployment in proprietary software without viral licensing requirements.

No pdfHTML Add-On Required

iText requires the separate itext.pdfhtml add-on (currently 6.3.2) for HTML-to-PDF conversion, sold on top of the core itext package. IronPDF includes Chromium-based HTML rendering in the base package.

Method Replacement Patterns

iText PatternIronPDF Replacement
SetTextAlignment(TextAlignment.CENTER)CSS text-align: center
SetFontSize(24)CSS font-size: 24px
SetBold()CSS font-weight: bold
new Table(3)HTML <table>
AddHeaderCell(new Cell().Add(new Paragraph()))HTML <th>
AddCell(new Cell().Add(new Paragraph()))HTML <td>

Troubleshooting

Issue 1: PdfWriter/Document Pattern

Problem: Code uses the PdfWriterPdfDocumentDocument nesting pattern.

Solution: Replace with ChromePdfRenderer:

// Delete this iText pattern:
// using (var writer = new PdfWriter(outputPath))
// using (var pdfDoc = new PdfDocument(writer))
// using (var document = new Document(pdfDoc))

// Replace with:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);

Issue 2: HtmlConverter Not Found

Problem: Code uses iText.Html2pdf.HtmlConverter, which lives in the separately-purchased itext.pdfhtml add-on.

Solution: Use IronPDF's built-in HTML rendering:

// iText (requires pdfHTML add-on)
HtmlConverter.ConvertToPdf(html, fileStream);

// IronPDF (built-in)
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs(outputPath);

Issue 3: PdfMerger Complexity

Problem: iText's PdfMerger requires nested readers and page range specification.

Solution: Use IronPDF's static merge method:

// iText merger pattern (delete this)
// 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 (simple)
var merged = PdfDocument.Merge(pdfDocuments);
merged.SaveAs("merged.pdf");

Migration Checklist

Pre-Migration

  • Inventory all iText API calls in codebase
  • Identify programmatic PDF construction patterns (Paragraph, Table, Cell)
  • Document HtmlConverter usage (pdfHTML add-on)
  • Assess AGPL compliance risk
  • Obtain IronPDF license key

Code Migration

  • Remove iText NuGet packages: dotnet remove package itext (and the deprecated itext7 alias, plus itext.pdfhtml / iTextSharp if present)
  • Install IronPDF NuGet package: dotnet add package IronPdf
  • Update namespace imports (using iText.*using IronPdf)
  • Replace PdfWriter/Document pattern with ChromePdfRenderer
  • Convert Paragraph/Table/Cell to HTML elements
  • Replace HtmlConverter.ConvertToPdf() with RenderHtmlAsPdf()
  • Update merge operations to PdfDocument.Merge()
  • Add license key initialization at startup

Testing

  • Test all PDF generation paths
  • Verify visual output matches expectations
  • Test with complex HTML/CSS content
  • Benchmark performance

Post-Migration

  • Remove iText license files and references
  • Update documentation
  • Cancel iText subscription (if applicable)
  • Archive legacy iText code

Please note: iText is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by iText Group. All product names, logos, and brands are property of their respective owners. Comparisons are for informational purposes only and reflect publicly available information at the time of writing.
Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Related Articles

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required