IRONSOFTWAREHOME
PRODUCT COMPARISONS

A Comparison Between iTextSharp and IronPDF For Editing PDFs

Curtis Chau
Curtis Chau
Updated: July 20, 2026

PDF (Portable Document Format) is a widely-used document format that is popular due to its ability to preserve document formatting, security, and portability.

PDF files have become one of the most widely used document formats in the world, and there are several libraries available for creating and manipulating PDFs in the C# language.

Discover how to edit PDF files using C# with IronPDF and iText, making the task straightforward by leveraging these powerful libraries.

In this article, we will compare two popular libraries for PDF manipulation in C#: iText and IronPDF. We will discuss how to edit PDF files using both libraries, and then we will explore how IronPDF is a superior option compared to iText, especially in terms of output print, performance, and pricing.

Introduction to iText DLL and IronPDF Libraries

iText and IronPDF features and trial information are available to help developers efficiently work with PDF files in C#. Both libraries provide a wide range of features and functionalities to create, edit, and manipulate PDF documents.

iText DLL is a C# port of the Java-based iText library. It provides a simple and easy-to-use API for creating and manipulating PDF documents. iText is an open-source library that is available under the AGPL license.

IronPDF is a .NET library that is designed to create, edit, and manipulate PDF files using C#. It provides a modern and intuitive API for working with PDF documents. IronPDF is a commercial library that comes with a free trial version and subscription options for more extensive usage.

Comparing iText and IronPDF Libraries

Both iText and IronPDF libraries provide a wide range of features and functionalities to create, edit, and manipulate PDF documents. However, IronPDF has several advantages over iText, which make it a preferred choice for working with PDF documents in C#.

Editing PDF Files Using iText and IronPDF

Now that we have discussed the differences between iText and IronPDF, let's take a look at how to edit PDF files using both libraries. We will go through examples of adding text, form fields, and filling out forms in an existing PDF document using iText and IronPDF.

Editing PDF Files Using iText

Prerequisites

Before we start, you will need the following:

  1. Visual Studio installed on your machine.
  2. Basic knowledge of the C# programming language.
  3. iText library installed in your project.

A Comparison between iText and IronPDF For Editing PDF: Figure 1 - Create PDF Using iText in C#.

To install the iText library in your project, you can use the NuGet package manager. Open your Visual Studio project and right-click on the project name in the Solution Explorer. Select "Manage NuGet Packages" from the context menu. In the NuGet Package Manager, search for "iText" and install the latest version of the package.

A Comparison between iText and IronPDF For Editing PDF: Figure 2 - Explore How to Use iText in ASP.NET C#

Creating a New PDF File

To create a new PDF file using iText, we need to create a new instance of the "Document" class and pass a new FileStream object to its constructor. Here's an example:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using System.IO;

// Create a new PDF document
using (var writer = new PdfWriter(new FileStream("newfile.pdf", FileMode.Create)))
{
    using (var pdf = new PdfDocument(writer))
    {
        var document = new Document(pdf);

        // Create a header paragraph
        Paragraph header = new Paragraph("HEADER")
            .SetTextAlignment(TextAlignment.CENTER)
            .SetFontSize(16);

        // Add the header to the document
        document.Add(header);

        // Loop through pages and align header text
        for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
        {
            Rectangle pageSize = pdf.GetPage(i).GetPageSize();
            float x = pageSize.GetWidth() / 2;
            float y = pageSize.GetTop() - 20;

            // Add the header text to each page
            document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
        }

        // Set the margins
        document.SetTopMargin(50);
        document.SetBottomMargin(50);
    }
}

In the code above, we created a new PDF file called "newfile.pdf" and added a paragraph header to it.

A Comparison between iText and IronPDF For Editing PDF: Figure 3 - iText Tutorial for PDF Creation in C#

Editing an Existing PDF File

To edit an existing PDF file using iText, you need a PdfReader object to read the existing PDF document and a PdfStamper object to modify it. Here's an example:

using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using iText.Html2pdf;
using System.IO;

/**
 * iText URL to PDF
 * anchor-itext-url-to-pdf
 **/
private void ExistingWebURL()
{
    // Initialize PDF writer
    PdfWriter writer = new PdfWriter("wikipedia.pdf");

    // Initialize PDF document
    using PdfDocument pdf = new PdfDocument(writer);
    
    ConverterProperties properties = new ConverterProperties();
    properties.SetBaseUri("https://en.wikipedia.org/wiki/Portable_Document_Format");

    // Convert HTML to PDF
    Document document = HtmlConverter.ConvertToDocument(
        new FileStream("Test_iText7_1.pdf", FileMode.Open), pdf, properties);

    // Create and add a header paragraph
    Paragraph header = new Paragraph("HEADER")
        .SetTextAlignment(TextAlignment.CENTER)
        .SetFontSize(16);
    
    document.Add(header);

    // Align header text for each page
    for (int i = 1; i <= pdf.GetNumberOfPages(); i++)
    {
        Rectangle pageSize = pdf.GetPage(i).GetPageSize();
        float x = pageSize.GetWidth() / 2;
        float y = pageSize.GetTop() - 20;

        // Add header text aligned at the top
        document.ShowTextAligned(header, x, y, i, TextAlignment.LEFT, VerticalAlignment.BOTTOM, 0);
    }

    // Set the top and bottom margins
    document.SetTopMargin(50);
    document.SetBottomMargin(50);
    document.Close();
}

In this code, an existing PDF opens, and we add headers to its pages with proper text alignment.

Editing a PDF Document Using IronPDF

IronPDF is a powerful PDF library for C# that facilitates editing PDF documents. This tutorial will walk through the steps to edit an existing PDF file using IronPDF, including creating new PDF documents, adding pages, merging PDFs, and more.

A Comparison between iText and IronPDF For Editing PDF: Figure 4 - IronPDF Features Overview

Prerequisites

Ensure you have:

  • Visual Studio IDE
  • IronPDF library

Step 1: Create a New Project

Create a new C# project in Visual Studio. Choose the "Console Application" project type.

Step 2: Install IronPDF

A Comparison between iText and IronPDF For Editing PDF: Figure 5 - Installing IronPDF NuGet Package

Use the NuGet Package Manager to install the IronPDF library into your project.

// Execute this command in the Package Manager Console
Install-Package IronPdf
SHELL

Step 3: Load an Existing PDF Document

Load an existing PDF document using the PdfDocument class:

using IronPdf;

// Path to an existing PDF file
var existingPdf = @"C:\path\to\existing\pdf\document.pdf";

// Load the PDF document
var pdfDoc = PdfDocument.FromFile(existingPdf);

A Comparison between iText and IronPDF For Editing PDF: Figure 6 - Create PDF using IronPDF

Step 4: Add a New Page to an Existing PDF Document

To add a new page:

// Add a new page with default size
var newPage = pdfDoc.AddPage();
newPage.Size = PageSize.Letter;

Step 5: Creating PDF From Website

Generate a PDF directly from a webpage URL. Here's an example:

using IronPdf;

/**
 * IronPDF URL to PDF
 * anchor-ironpdf-website-to-pdf
 **/
private void ExistingWebURL()
{
    // Create PDF from a webpage
    var Renderer = new IronPdf.ChromePdfRenderer();

    // Set rendering options
    Renderer.RenderingOptions.MarginTop = 50; // millimeters
    Renderer.RenderingOptions.MarginBottom = 50;
    Renderer.RenderingOptions.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print;
    Renderer.RenderingOptions.TextHeader = new TextHeaderFooter()
    {
        CenterText = "{pdf-title}",
        DrawDividerLine = true,
        FontSize = 16
    };
    Renderer.RenderingOptions.TextFooter = new TextHeaderFooter()
    {
        LeftText = "{date} {time}",
        RightText = "Page {page} of {total-pages}",
        DrawDividerLine = true,
        FontSize = 14
    };
    Renderer.RenderingOptions.EnableJavaScript = true;
    Renderer.RenderingOptions.RenderDelay = 500; // milliseconds

    // Render URL as PDF
    using var PDF = Renderer.RenderUrlAsPdf("https://en.wikipedia.org/wiki/Portable_Document_Format");
    PDF.SaveAs("wikipedia.pdf");
}

Differences Between iText and IronPDF

A Comparison between iText and IronPDF For Editing PDF: Figure 7 - Choosing Between iText and IronPDF

iText is a popular open-source library for creating, manipulating, and extracting data from PDF documents in C#. It is well-documented and widely used. IronPDF, on the other hand, is more modern, with additional features and benefits that make it a better choice for developers.

Generate PDF From HTML Input String

Here's how you can use IronPDF to create a PDF from HTML:

using IronPdf;

/**
 * IronPDF HTML to PDF
 * anchor-ironpdf-document-from-html
 **/
private void HTMLString()
{
    // Render HTML to PDF
    var Renderer = new IronPdf.ChromePdfRenderer();
    using var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello IronPdf</h1>");
    Renderer.RenderingOptions.TextFooter = new HtmlHeaderFooter() 
    { 
        HtmlFragment = "<div style='text-align:right'><em style='color:pink'>page {page} of {total-pages}</em></div>"
    };
    var OutputPath = "ChromeHtmlToPdf.pdf";
    PDF.SaveAs(OutputPath);
}

iText HTML to PDF

Convert HTML text to a PDF using iText:

using iText.Html2pdf;
using System.IO;

/**
 * iText HTML to PDF
 * anchor-itext-html-to-pdf
 **/
private void HTMLString()
{
    HtmlConverter.ConvertToPdf("<h1>Hello iText7</h1>", new FileStream("iText7HtmlToPdf.pdf", FileMode.Create));
}

Performance

IronPDF is designed to be faster and more efficient than iText, allowing quicker generation of PDFs using fewer resources. This efficiency is crucial for large or complex documents.

Pricing

iText requires a commercial license for certain use cases, which can be expensive. IronPDF, however, offers a more affordable pricing model with various options tailored to different needs and budgets.

Licenses and Pricing

One of the key differences between iText and IronPDF is their licensing and pricing models.

  • iText: Licensed under AGPL, it requires a commercial license for non-open-source projects. Commercial licenses vary in cost.
  • IronPDF: Offers a free trial with flexible licensing, including developer and server licenses, making it suitable for commercial use.

A Comparison between iText and IronPDF For Editing PDF: Figure 9 - Key Features of IronPDF

Conclusion

In conclusion, while both iText and IronPDF can handle PDF manipulation in C#, IronPDF stands out as a more versatile and efficient choice. It offers advanced features, an intuitive API, and better performance. Its flexible pricing makes it suitable for commercial projects and larger organizations.

With IronPDF's superior HTML to PDF conversion, developers can easily generate reports or documents with rich media or interactive content. Coupled with cost-effective pricing, IronPDF is an excellent choice for developers needing a powerful and efficient PDF library for C# projects.

Please note: iText is a registered trademark of its respective owner. This site is not affiliated with, endorsed by, or sponsored by iText. 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