
A Comparison of Creating PDF in C# Between ITextSharp and IronPDF
A Comparative Guide to Creating PDFs in C# with iText and IronPDF
Generating PDF documents programmatically in C# typically involves choosing between a library that constructs documents element-by-element or one that renders HTML directly to PDF. That architectural split determines how much boilerplate your team writes and which compliance paths are available.
This comparison covers iText and IronPDF on PDF creation model, HTML conversion, digital signatures, compliance standards, and licensing - with code examples for each. The PDF file format is created by Adobe; background on the format is available at Adobe Create PDF.
The table below highlights the key differences covered in this comparison:
| Feature | iText / iText | IronPDF | |---|---|---| | PDF Creation Model | Programmatic element construction | HTML-to-PDF via embedded Chromium engine | | HTML to PDF Conversion | Requires separate pdfHTML add-on | Built-in, single NuGet package | | PDF/A and PDF/UA Compliance | Supported | Supported | | Digital Signatures | Supported | Supported | | Interactive Forms | Supported | Supported | | Watermarks and Annotations | Supported | Supported | | Cross-Platform (.NET Core) | Supported (iText+) | Supported | | Licensing | AGPL or commercial license | Commercial with free 30-day trial |
To test IronPDF's HTML-to-PDF workflow against iText's programmatic model in your own project, a free 30-day trial covers every feature in this comparison.
What Is iText?
iText, launched in December 2009, established itself as a widely-adopted .NET PDF library, superseding its predecessor, iText 2. As the .NET version of iText, it paved the way for advanced programmable PDF functionalities. iText, the .NET version of iText, has long been a reliable source for creating a programmable PDF document object.
Summary of Creating PDFs with iText
- Create a new C# Project in Visual Studio.
- Install the iText library from NuGet Package Manager.
- Create an instance of PdfDocument class.
- Instantiate it with PdfWriter object.
- Create a Document object and pass the PdfDocument object to it.
- Add text to Document object using Paragraph class.
- Close the Document object.
Key Features of iText
Here are some important key features of iText DLL:
Dynamic PDF Generation
iText empowers developers to dynamically generate or manipulate PDF documents. This feature is invaluable for creating documents and reports based on data from XML files or databases.
Interactive Forms
The library facilitates the creation and filling out of interactive forms, enhancing user engagement and interactivity.
Advanced PDF Features
iText allows developers to exploit numerous interactive features, such as adding bookmarks, page numbers, watermarks, and more to existing PDF files. This flexibility is essential for tailoring PDFs to specific requirements.
Map and Book Creation
Developers can use iText to create maps and books, expanding the application of the library beyond basic document generation.
PDF Standards Compliance
iText supports various PDF standards, including PDF/A for archiving, PDF/UA for accessibility, ZUGFeRD for electronic invoicing, and PDF 2.0 (though not all functionalities are covered).
The Release of iText Core Version 8
While iText has been a robust choice for PDF manipulation, iText/iText has been superseded by iText Core version 8, which brings forth numerous improvements. Developers are encouraged to consider transitioning existing projects to iText 8 to benefit from the latest releases.
Key Features of iText Core version 8
Here are some key features of iText version 8:
Enhanced Functionality
iText introduces enhancements in functionality, performance, and extensibility compared to its predecessor.
Improved APIs
The latest version provides improved APIs for more intuitive and efficient development.
Documentation and Support
iText comes with updated documentation and support, ensuring a smoother development experience.
Optimized Invoicing
With the iText version 8 Suite, developers can optimize invoicing, ensuring long-term archiving and addressing compliance issues through its powerful PDF SDK.
Creating PDFs with iText in Depth
Step 1: Install iText Library
To create a PDF document with iText, follow these steps to install the library using the NuGet Package Manager:
-
Open Visual Studio and create a new project.
-
Right-click on the project in the Solution Explorer and select "Manage NuGet Packages."

-
In the "NuGet Package Manager" window, select the "Browse" tab.
-
Type "iText" in the search bar and press Enter.

-
Select "iText" from the search results and click "Install."
-
Review and accept the dependencies, then click "OK" to proceed.
-
Wait for the installation to complete, and iText can now be added to your project.
Step 2: Code to Create a PDF Document with iText
Now, let's explore a basic example of creating a PDF using iText:
using System;
using System.IO;
using iText.Kernel.Pdf;
using iText.Layout;
using iText.Layout.Element;
class Program
{
static void Main(string[] args)
{
// Create a new PDF document with a FileStream and PdfWriter
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileStream("/myfiles/hello.pdf", FileMode.Create, FileAccess.Write))))
{
// Create a document object
using (Document doc = new Document(pdfDocument))
{
// Add a paragraph to the document
string line = "Hello! Welcome to iTextSharp. Created with latest iText core version 8.";
doc.Add(new Paragraph(line));
}
}
// Print a message to the console
Console.WriteLine("PDF created successfully!");
}
}Imports System
Imports System.IO
Imports iText.Kernel.Pdf
Imports iText.Layout
Imports iText.Layout.Element
Module Program
Sub Main(args As String())
' Create a new PDF document with a FileStream and PdfWriter
Using pdfDocument As New PdfDocument(New PdfWriter(New FileStream("/myfiles/hello.pdf", FileMode.Create, FileAccess.Write)))
' Create a document object
Using doc As New Document(pdfDocument)
' Add a paragraph to the document
Dim line As String = "Hello! Welcome to iTextSharp. Created with latest iText core version 8."
doc.Add(New Paragraph(line))
End Using
End Using
' Print a message to the console
Console.WriteLine("PDF created successfully!")
End Sub
End ModuleIn this source code, we created a new PDF document by passing a PdfWriter class object. The FileStream object specifies the PDF file name and file mode to create the PDF document. We then pass this PdfDocument object to the Document class for PDF creation.
Finally, we added a string text as a new paragraph with the text "Hello! Welcome to iText. Created with latest iText core version 8." and closed the document to save memory. The created PDF document is saved as "hello.pdf" in the specified location within the 'myfiles' folder.

What Does IronPDF Offer?
IronPDF is a comprehensive C# library that empowers developers to interact with PDFs in a versatile and efficient manner. Whether you're creating PDFs from scratch, converting HTML and CSS to PDF, or adding advanced features like digital signatures and watermarks, IronPDF provides a rich set of tools for all your PDF-related needs.
Key Features of IronPDF
HTML to PDF Conversion
IronPDF excels in converting HTML and CSS to high-quality PDF documents. This feature is particularly valuable for developers dealing with web content or dynamic HTML-based reports.
PDF Creation and Manipulation
Developers can create PDFs from scratch, add content dynamically, and manipulate existing PDFs with ease. This flexibility allows for the generation of customized documents tailored to specific requirements.
Text, Images, and Forms
IronPDF supports the inclusion of text, images, tables, and forms in your PDF document. This makes it a versatile tool for creating diverse types of content within PDFs.
Digital Signatures
Security is paramount, and IronPDF enables the addition of digital signatures to PDF documents. This feature is crucial for applications dealing with sensitive information or legal documents.
Watermarks and Annotations
Enhance your PDFs with watermarks, annotations, and additional metadata. IronPDF provides the means to add visual elements and notes to your documents, improving communication and document clarity.
PDF/A and PDF/UA Compliance
IronPDF supports compliance with PDF/A standards for archiving and PDF/UA standards for accessibility. This ensures that your documents meet industry standards for long-term archiving and accessibility requirements.
Cross-Platform Support
IronPDF is designed to work seamlessly across different platforms, providing a consistent experience for developers working in various environments.
User-Friendly Interface
The library comes with a user-friendly API that simplifies complex PDF operations. This allows developers to focus on application logic rather than solving complex PDF functionalities.
Creating PDFs with IronPDF
Step 1: Install IronPDF Library
To get started with IronPDF, follow these steps to install the library using the NuGet Package Manager:
-
Open Visual Studio and create a new project.
-
Right-click on the project in the Solution Explorer and select "Manage NuGet Packages."
-
In the "NuGet Package Manager" window, select the "Browse" tab.

-
Type "IronPDF" in the search bar and press Enter.
-
Select "IronPDF" from the search results and click "Install."
-
Review and accept the dependencies, then click "OK" to proceed.
-
Wait for the installation to complete, and IronPDF can now be added to your project.
Step 2: Code to Create a PDF Document with IronPDF
Now, let's look at the following code for creating a PDF from an HTML string using IronPDF:
using IronPdf;
class Program
{
static void Main(string[] args)
{
// Instantiate renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from an HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Print a message to the console
Console.WriteLine("PDF created successfully using IronPDF!");
}
}Imports IronPdf
Module Program
Sub Main(args As String())
' Instantiate renderer
Dim renderer As New ChromePdfRenderer()
' Create a PDF from an HTML string using VB.NET
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
' Export to a file or Stream
pdf.SaveAs("output.pdf")
' Print a message to the console
Console.WriteLine("PDF created successfully using IronPDF!")
End Sub
End ModuleIn the above source code, we created a new ChromePdfRenderer, rendered the HTML string content (in this case, a heading) as a PDF, and saved the generated PDF document as "output.pdf." IronPDF converts HTML to a pixel-perfect PDF document.
To generate PDFs with more control, such as by setting page size, adding image files, meta information, and other elements, please visit this documentation for more information.

Which Library Should You Choose?
Both IronPDF and iText, now formally known as iText, are capable libraries for creating PDFs in C#, each with distinct strengths.
iText is renowned for its robust feature set and fine-grained control over PDF internals - particularly valuable in environments where advanced PDF manipulation and standards compliance are primary requirements. IronPDF, meanwhile, provides an HTML-first approach with an accessible API and extensive documentation, which reduces ramp-up time for developers who are already comfortable with HTML and CSS.
Both iText and IronPDF are solid solutions for PDF generation and manipulation. IronPDF uses an embedded Chromium rendering engine that handles HTML-to-PDF conversion - including CSS3, Flexbox, and Grid layouts - in a single pass, whereas iText's document-building model operates at a lower abstraction level, requiring developers to construct page elements programmatically. For teams whose workflow is predicated on converting web content to PDF, this architectural difference translates to fewer lines of code and less layout debugging.
IronPDF ships as a single NuGet package that bundles rendering, manipulation, and security features together. iText offers a modular ecosystem with separate add-on packages for capabilities like HTML conversion (pdfHTML) and digital signatures, which provides flexibility but creates additional integration steps for teams needing multiple features out of the box.
Beyond license cost, total project cost includes the developer hours spent assembling separate add-on packages, constructing page layouts programmatically, and - for teams using iText's open-source tier - maintaining AGPL compliance across the codebase. For teams evaluating cost over a multi-year project lifecycle, these integration and maintenance costs frequently eclipse the difference between open-source and commercial licensing.
For a full comparison between IronPDF and iText, please visit this detailed comparison between IronPDF and iText.
IronPDF provides a free trial license for more information. Download the library from the IronPDF download page.

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.
Related Articles


