PRODUCT COMPARISONS

Extract Text From PDF in C# Using iTextSharp VS IronPDF

Introduction

Extracting text from PDF documents is a common requirement in modern software projects—from processing invoices to mining content for search engines. Developers need reliable libraries that offer not only accurate results but also an efficient integration experience in C# .NET applications. Some developers use OCR (optical character recognition) tools to extract data from scanned documents and images, but sometimes the job calls for a robust text extraction tool.

But with several PDF libraries on the market, choosing the right tool can be overwhelming. Two libraries that often come up in the conversation are iTextSharp and IronPDF. Both can extract text from PDFs, but they differ significantly in usability, support, performance, and pricing. This article compares the two libraries, looking at different code samples to demonstrate how they handle text extraction, to help you decide which best fits your project.

An Overview of IronPDF and the iTextSharp Library

iTextSharp has long been a popular open-source PDF library for .NET, offering powerful tools for generating, manipulating, and extracting content. As a C# port of the Java-based iText, it provides deep control over PDF structures—ideal for advanced users. However, this flexibility comes with a steep learning curve and licensing constraints; commercial use often requires a paid license to avoid AGPL obligations.

Enter IronPDF—a modern, developer-friendly PDF library built for .NET. It streamlines common tasks like text extraction with an intuitive API, clear documentation, and responsive support. With this tool, developers can extract images and text from PDF documents with ease, create new PDF files, implement PDF security, and more.

Unlike iTextSharp, IronPDF avoids complex low-level structures, letting you work faster and more efficiently. Whether you're processing a single page or hundreds of PDFs, it keeps things simple.

It’s also actively maintained, with regular updates and a straightforward licensing model, including a free trial and affordable plans for teams and solo developers alike.

Installing and Using IronPDF

NuGet Install with NuGet

PM >  Install-Package IronPdf

Check out IronPDF on NuGet for quick installation. With over 10 million downloads, it’s transforming PDF development with C#. You can also download the DLL or Windows installer.

IronPDF can be installed via NuGet as well, by running the following command in the NuGet Package Manager Console:

Install-Package IronPdf

Installing IronPDF via the Package Manager Console

Alternatively, you can install it via the NuGet package manager for Solution screen. To do this, navigate to "Tools > NuGet Package Manager > Manage NuGet Packages for Solution".

Tools dropdown menu in Visual Studio

Then, search for IronPDF, and click "Install".

IronPDF NuGet package manager screen

Extract Text from PDF Files with IronPDF

Once installed, extracting text is straightforward:

using IronPdf;

var pdf = PdfDocument.FromFile("invoice.pdf");
string extractedText = pdf.ExtractAllText();
Console.WriteLine(extractedText);
using IronPdf;

var pdf = PdfDocument.FromFile("invoice.pdf");
string extractedText = pdf.ExtractAllText();
Console.WriteLine(extractedText);
Imports IronPdf

Private pdf = PdfDocument.FromFile("invoice.pdf")
Private extractedText As String = pdf.ExtractAllText()
Console.WriteLine(extractedText)
$vbLabelText   $csharpLabel

📝 Note: This method reads the entire PDF file and returns the text in reading order, saving hours of parsing time compared to traditional libraries.

No need to handle encodings, content streams, or manual parsing. IronPDF handles all of that internally, providing clean and accurate output with minimal setup. You could then easily save the extracted text to a new text file for further manipulation or use.

Installing the iTextSharp PDF library

To download iTextSharp's core package for PDF generation:

Install-Package iTextSharp
Install-Package iTextSharp
SHELL

Installing iTextSharp via the NuGet console

You can also iTextSharp via the Package Manager for Solution screen. To do this, you first need to go to the Tools drop down menu, then find "NuGet Package Manager > Manage NuGet Packages for Solution".

Visual Studio's tool drop down menu

Then, simply search for iTextSharp, and click "Install".

Extract Text From Pdf Csharp Itextsharp 6 related to Installing the iTextSharp PDF library

Extract Text from PDF documents with iTextSharp

Here’s a sample to extract text from a single PDF page:

using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas.Parser;
using iText.Kernel.Pdf.Canvas.Parser.Listener;

string path = "sample.pdf";
using (PdfReader reader = new PdfReader(path))
using (PdfDocument pdf = new PdfDocument(reader))
{
    var strategy = new SimpleTextExtractionStrategy();
    string pageText = PdfTextExtractor.GetTextFromPage(pdf.GetPage(1), strategy);
    Console.WriteLine(pageText);
}
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Canvas.Parser;
using iText.Kernel.Pdf.Canvas.Parser.Listener;

string path = "sample.pdf";
using (PdfReader reader = new PdfReader(path))
using (PdfDocument pdf = new PdfDocument(reader))
{
    var strategy = new SimpleTextExtractionStrategy();
    string pageText = PdfTextExtractor.GetTextFromPage(pdf.GetPage(1), strategy);
    Console.WriteLine(pageText);
}
Imports iText.Kernel.Pdf
Imports iText.Kernel.Pdf.Canvas.Parser
Imports iText.Kernel.Pdf.Canvas.Parser.Listener

Private path As String = "sample.pdf"
Using reader As New PdfReader(path)
Using pdf As New PdfDocument(reader)
	Dim strategy = New SimpleTextExtractionStrategy()
	Dim pageText As String = PdfTextExtractor.GetTextFromPage(pdf.GetPage(1), strategy)
	Console.WriteLine(pageText)
End Using
End Using
$vbLabelText   $csharpLabel

This example demonstrates iTextSharp’s capability, but notice the verbosity and additional objects required to perform a simple task.

Detailed Comparison

Now that we've covered installation and basic usage, let's take a look at more in-depth comparison of how these two libraries handle text extraction by having them extract text from a multi-paged PDF document.

Advanced Example: Extracting Text from a Page Range with IronPDF

IronPDF supports granular control over page selection and layout-aware text extraction.

using IronPdf;

// Load PDF document
var pdf = PdfDocument.FromFile("longPdf.pdf");

int[] pages = new[] { 2, 3, 4 };

var text = pdf.ExtractTextFromPages(pages);

Console.WriteLine("Extracted text from pages 2, 3, and 4:" + text);
using IronPdf;

// Load PDF document
var pdf = PdfDocument.FromFile("longPdf.pdf");

int[] pages = new[] { 2, 3, 4 };

var text = pdf.ExtractTextFromPages(pages);

Console.WriteLine("Extracted text from pages 2, 3, and 4:" + text);
Imports IronPdf

' Load PDF document
Private pdf = PdfDocument.FromFile("longPdf.pdf")

Private pages() As Integer = { 2, 3, 4 }

Private text = pdf.ExtractTextFromPages(pages)

Console.WriteLine("Extracted text from pages 2, 3, and 4:" & text)
$vbLabelText   $csharpLabel

Output

IronPDF text extraction output

Advanced Example: Extracting Text from a Page Range using iTextSharp

In iTextSharp, you’ll need to manually specify the page range and extract text using PdfTextExtractor:

using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.IO;
using System.Text;

// Load PDF document
PdfReader reader = new PdfReader("longPdf.pdf");
StringBuilder textBuilder = new StringBuilder();

// Extract text from pages 2–4
for (int i = 2; i <= 4; i++)
{
    string pageText = PdfTextExtractor.GetTextFromPage(reader, i, new LocationTextExtractionStrategy());
    textBuilder.AppendLine(pageText);
}

// Output the extracted text
Console.WriteLine(textBuilder.ToString());
reader.Close();
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.IO;
using System.Text;

// Load PDF document
PdfReader reader = new PdfReader("longPdf.pdf");
StringBuilder textBuilder = new StringBuilder();

// Extract text from pages 2–4
for (int i = 2; i <= 4; i++)
{
    string pageText = PdfTextExtractor.GetTextFromPage(reader, i, new LocationTextExtractionStrategy());
    textBuilder.AppendLine(pageText);
}

// Output the extracted text
Console.WriteLine(textBuilder.ToString());
reader.Close();
Imports iTextSharp.text.pdf
Imports iTextSharp.text.pdf.parser
Imports System.IO
Imports System.Text

' Load PDF document
Private reader As New PdfReader("longPdf.pdf")
Private textBuilder As New StringBuilder()

' Extract text from pages 2–4
For i As Integer = 2 To 4
	Dim pageText As String = PdfTextExtractor.GetTextFromPage(reader, i, New LocationTextExtractionStrategy())
	textBuilder.AppendLine(pageText)
Next i

' Output the extracted text
Console.WriteLine(textBuilder.ToString())
reader.Close()
$vbLabelText   $csharpLabel

Output

iTextSharp extracted text output

Code Comparison Summary

iTextSharp vs IronPDF Summary

Both IronPDF and iTextSharp are capable of advanced PDF text extraction, but their approaches differ significantly in complexity and clarity:

  • IronPDF keeps things clean and accessible. Its high-level methods like PdfDocument.ExtractAllText() allow you to extract structured content with minimal setup. The code is straightforward, making it easy to implement even for developers new to PDF processing.

  • iTextSharp, on the other hand, requires deeper understanding of the PDF structure. Extracting text involves setting up custom render listeners, managing pages manually, and interpreting layout data line by line. While powerful, it’s more verbose and less intuitive, making IronPDF a faster and more maintainable option for most .NET projects.

But our comparison doesn't end here, next, let's look at how these two libraries compare in other areas.

Detailed Comparison: IronPDF vs iTextSharp

When evaluating PDF text extraction libraries for .NET, developers often weigh the balance between simplicity, performance, and long-term support. Let’s break down how IronPDF and iTextSharp compare in real-world usage, especially for extracting text from PDFs in C#.

1. Ease of Use

✅ IronPDF: Clean and Modern API

IronPDF emphasizes developer experience. Installation is easy via NuGet, and the syntax is intuitive:

using IronPdf;

// Load the PDF
var pdf = PdfDocument.FromFile("sample.pdf");

// Extract all text from every page
string extractedText = pdf.ExtractAllText();

// Output
Console.WriteLine(extractedText);
using IronPdf;

// Load the PDF
var pdf = PdfDocument.FromFile("sample.pdf");

// Extract all text from every page
string extractedText = pdf.ExtractAllText();

// Output
Console.WriteLine(extractedText);
Imports IronPdf

' Load the PDF
Private pdf = PdfDocument.FromFile("sample.pdf")

' Extract all text from every page
Private extractedText As String = pdf.ExtractAllText()

' Output
Console.WriteLine(extractedText)
$vbLabelText   $csharpLabel

IronPDF abstracts the complexity behind simple method calls like ExtractAllText(), requiring no boilerplate or parsing logic.

iTextSharp: More Verbose and Lower-Level

iTextSharp requires manual parsing of each page and more effort to extract plain text.

using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.IO;

// Load the PDF
var reader = new PdfReader("sample.pdf");
StringBuilder text = new StringBuilder();

for (int i = 1; i <= reader.NumberOfPages; i++)
{
    text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}

// Output
Console.WriteLine(text.ToString());
using iTextSharp.text.pdf;
using iTextSharp.text.pdf.parser;
using System.IO;

// Load the PDF
var reader = new PdfReader("sample.pdf");
StringBuilder text = new StringBuilder();

for (int i = 1; i <= reader.NumberOfPages; i++)
{
    text.Append(PdfTextExtractor.GetTextFromPage(reader, i));
}

// Output
Console.WriteLine(text.ToString());
Imports iTextSharp.text.pdf
Imports iTextSharp.text.pdf.parser
Imports System.IO

' Load the PDF
Private reader = New PdfReader("sample.pdf")
Private text As New StringBuilder()

For i As Integer = 1 To reader.NumberOfPages
	text.Append(PdfTextExtractor.GetTextFromPage(reader, i))
Next i

' Output
Console.WriteLine(text.ToString())
$vbLabelText   $csharpLabel

Developers need to manually loop through pages, which introduces more code and potential for bugs if edge cases arise.

2. Performance and Reliability

  • IronPDF is built on a modern rendering engine (Chromium), making it well-suited for modern PDFs, even those with embedded fonts, rotated text, and multiple layouts. Text extraction is layout-aware and preserves spacing more naturally.

  • iTextSharp, although powerful, may struggle with complex formatting. PDF files with mixed orientation or non-standard encodings may yield garbled or improperly ordered text.

3. Cost and Licensing

FeatureIronPDFiTextSharp
License TypeCommercial (Free Trial Available)AGPL (Free) / Commercial (Paid)
Pricing TransparencyPublic pricing & perpetual licensingComplex tiers and redistribution rules
SupportDedicated Support TeamCommunity support (unless licensed)
Use in Closed Source App✅ Yes (with license)❌ Not with AGPL

📌 Note: If you're building commercial or proprietary software, iTextSharp AGPL will force you to open-source your code, or pay for a commercial license. IronPDF offers a more flexible licensing model for closed-source projects.

4. Developer Support and Documentation

  • IronPDF: Comes with modern documentation, video tutorials, and fast ticket-based support.

  • iTextSharp: Good documentation, but limited free support unless you're a paid customer.

5. Cross-Library Summary

CriteriaIronPDFiTextSharp
Simplicity✅ High – One-liner text extraction⚠️ Medium – Manual page iteration
Performance✅ Fast and modern parsing⚠️ Slower on complex or scanned PDFs
Commercial Friendly✅ Yes, no AGPL restrictions❌ AGPL limits use in closed-source apps
Support & Docs✅ Dedicated, responsive⚠️ Community-dependent
.NET Core Support✅ Full✅ Full

Conclusion

When it comes to extracting text from PDFs in C#, both IronPDF and iTextSharp are capable tools—but they serve different types of developers. If you're looking for a modern, easy-to-integrate solution with excellent support, actively maintained features, and seamless layout preservation, IronPDF clearly stands out. It reduces development time, offers intuitive APIs, and works well across a wide range of applications within the .NET framework, from web apps to enterprise systems.

On the other hand, iTextSharp remains a strong option for developers already embedded in its ecosystem or those who require granular control over text extraction strategies. However, its steeper learning curve and lack of commercial support can slow down projects that need to scale quickly or maintain clean codebases.

For .NET developers who value speed, clarity, and reliable results, IronPDF provides a future-ready path. Whether you're building document automation tools, search engines, or internal dashboards, IronPDF’s robust features and performance will help you deliver faster and smarter.

👉 Try IronPDF today by downloading the free trial and experience the difference for yourself. With a free trial and a developer-friendly API, you can get started in minutes.

Get stated with IronPDF now.
green arrow pointer

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.
< PREVIOUS
iTextSharp Documentation Reviewed VS IronPDF
NEXT >
IronPDF and Puppeteer C#: A Comparison