Published September 1, 2022
A Comparison between IronPDF & iText7
Convert your webpages into PDF documents quickly and easily using the IronPDF library for C# and Java. IronPDF supports all forms of HTML content and renders them with pixel-perfect precision. No fuss. No stress. This library just simply works.
Continue reading to learn about how IronPDF for C# stacks up against the iText7 PDF Library for .NET. For the comparison between the Java version of both libraries, refer to this blog post.
The need to generate PDFs in C#, either for users or to save locally, is something that arises on a fairly regular basis. I was recently underwhelmed by the options available to actually achieve this when I tried to do it. There is nothing in C# or .NET Core that can generate PDFs for you natively. Plus, there was a slew of issues when it came to actually looking at the feature sets of third-party libraries (for example, if I wish to use HTML as a template option).
As a result, rather than showing you code to make a PDF using a specific PDF library, I'll compare two of these libraries: IronPDF and iText 7.
IronPDF and iText 7 are two libraries that can be used in your Microsoft .NET application to create, read, and edit PDF documents, whether they are online or on a desktop with better internal PDF structures. Let's examine the two libraries to see which one is the most appropriate for our purposes. We'll first compare the features of the two libraries, then see how well they convert and edit a PDF using a better document engine. Microsoft's .NET frameworks support both libraries.
Before we begin, here is what we should expect when looking for suitable software to generate and manipulate PDFs in .NET core, and one that can also be used to debug PDFs.
How to Use iText7 in C# (Example tutorial)
- Install iText7 library to edit PDF file in C#
- Convert HTML to PDF utilizing
HtmlConverter
class - Use
PDFReader
class to read and extract PDF content - Sign document in iText7 with
SignDetached
method - Export the finished PDF file to desire location
What to expect from a .NET PDF files library
Price
Free software is obviously the most desirable, and even better if it's open-source — that way I can debug it myself. However, if I am required to pay for a "premium" library, I will. I'm seeking a one-time price that isn't based on some nonsense like "per user/seat/machine/server." If I'm a corporation looking at this library, I don't want future architecture or decisions to be predicated on the library's pricing.
If there were a freemium model in play, I would also want to make sure that the restrictions were reasonable (e.g. single pages only, set number of images allowed per PDF, etc.). It's fine to employ a freemium model as long as the free version is truly usable.
Templating in HTML
I'd previously determined that HTML would be my templating language of choice. I was open to utilizing any other sensible alternative (e.g. HTML with some XSLT engine), but in the end, I just want to input an HTML file into the library and have my PDF generated. I don't want to have to manually position each element on the PDF, as we used to have to do when printing a document from a WinForms program.
All-in-One/Ease Of Use
This is certainly a personal preference, but when you start looking for libraries in obscure places on the internet or in a Stack Overflow answer from three years ago, you frequently end up with a half-baked library that doesn't work. I'm likely to see it all, whether it's a C++ library ported to C#, a library that requires X number of other libraries to function, or things that just don't operate as they should. Above all, I want to be up and operating in minutes rather than hours.
What is IronPDF?
IronPDF is a highly efficient PDF tool and capable PDF converter that can do practically anything a browser can. It's a PDF library for programmers that makes creating, reading, and manipulating PDF files a breeze using low-level programming capabilities. IronPDF converts HTML to PDF using the Chrome engine. IronPDF supports Windows forms, HTML, ASPX, Razor HTML, .NET Core, ASP.NET, Windows Forms, WPF, Xamarin, Blazor, Unity, and HoloLense apps, among other web components. Microsoft.NET and .NET Core apps are supported by IronPDF (both ASP.NET Web applications and traditional Windows applications) to make your own applications. IronPDF can also be used to create visually appealing PDFs.
IronPDF can convert HTML5, JavaScript, CSS, and pictures into PDF documents, and build custom PDF scenarios. A header and footer can also be included in the files. It can also make it easier for us to view PDF files. IronPDF comes with a robust HTML-to-PDF converter that works with PDF files. It also has a powerful PDF conversion engine. Furthermore, it has no external dependencies. IronPDF shows more benefits PDF can bring.
IronPDF Features
- Sources that can be used to create a PDF document include HTML, HTML5, ASPX, and Razor/MVC View using IronPDF as a better document engine. Not only can we convert HTML files to PDF, but we can also convert image files.
- The ability to create edit interactive PDF documents, fill out and submit interactive forms, combine and divide PDF documents, extract text and images from PDF documents, replace text in PDF documents, rasterize PDF pages to images, convert PDF documents, and much more.
- As a starting point, create a document using the link. It also supports custom network login credentials, user-agents, proxies, cookies, HTTP headers, and form variables for login behind HTML login forms.
- By specifying user names and passwords, IronPDF allows us to open protected documents.
- IronPDF is a program that reads and fills in the blanks in existing PDF documents even for those with low-level programming capabilities.
- It can extract images from documents.
- It allows us to add headers and footers to documents, as well as text, images, bookmarks, watermarks, and more.
- It gives us the ability to split and merge pages in a new or existing document.
- Without utilizing Acrobat Reader, we can convert documents to PDF objects.
- A CSS file can be converted into a PDF document.
- Media files of the CSS file type can be turned into documents.
- Fill out existing PDF forms and add new ones.
What is iText 7
The iText 7 Suite is a comprehensive PDF SDK that comprises the open-source iText 7 Core PDF library as well as optional add-ons to meet your specific requirements. The iText 7 Core PDF library is a reworking of the popular iText 5 engine with a modular code structure, and low-level functionality, enabling future advancements and expansion as well as simplified coding.
The development of iText 7 was based on nearly a decade of lessons learned during the development of iText 5 (and iTextSharp). One add-on at a time, it's a simpler, more performant, and extensible library that's ready to manage the additional complexities of today's document processes.
iText 7 features
- PDF creation in bulk, including tagged PDFs with metadata describing the document's structure and the order of its elements (e.g. titles, text blocks, columns and pictures)
- Image-to-PDF conversion
- HTML-to-PDF conversion (with the pdfHTML iText add-on)
- iText 7 is unique in that it supports a wide range of languages, including Indic languages, Thai, Khmer, Arabi, Hebrew, Chinese, Japanese, Korean, and Cyrillic languages, among others (with the pdfCalligraph iText add-on)
Installing iText
Go to File -> New -> Project in Visual Studio.
Select Console App (.NET Framework) and give the project a name in the "New Project window".

Select "Manage NuGet Packages" from the context menu when right-clicking the project name.

Select "Browse" and type itext7 in the search box. Select itext7 from the results and install it

Installing IronPDF
There are four ways to obtain and install the IronPDF Library.
These are the following:
Using the Visual Studio NuGet Package Manager, Visual Studio is a program that gives you the ability to create and edit documents.
- Using the Command-Line in Visual Studio.
- Download directly from the NuGet website.
- Download directly from the IronPDF website.
Using Visual Studio
The NuGet Package Manager feature in the Visual Studio software allows you to install the package directly into the solution. The screenshot below demonstrates how to use the NuGet Package Manager.

It has a search box that displays the NuGet website's package list. We need to search for the keyword "IronPDF" in the package manager, as seen in the screenshot below:

We can see a list of relevant search results in the image above. We must first select the required option to add the package to the solution.
Using the Command-Line in Visual Studio
Navigate to Tools -> NuGet Package Manager -> Package Manager Console in Visual Studio.
In the package manager console tab, type the following line.
Install-Package IronPdf
Create enhanced PDF documents from URLs
Both PDF libraries assist us in converting HTML pages into attractive PDFs. Let's take a look at how to create a PDF file and the benefits PDFs can bring.
Using IronPDF
IronPDF makes it easy to create a PDF document by generating an HTML file from a URL and converting it to a PDF document. The HTML string will be downloaded using IronPDF's built-in chrome browser.
The steps below make it easy to create PDF documents:
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://www.google.co.in/");
Pdf.SaveAs("result.pdf");
or
var Renderer = new IronPdf.ChromePdfRenderer().
RenderUrlAsPdf("https://www.amazon.com/").SaveAs("result.pdf");
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://www.google.co.in/");
Pdf.SaveAs("result.pdf");
or
var Renderer = new IronPdf.ChromePdfRenderer().
RenderUrlAsPdf("https://www.amazon.com/").SaveAs("result.pdf");
Dim Renderer As New IronPdf.ChromePdfRenderer()
Dim Pdf = Renderer.RenderUrlAsPdf("https://www.google.co.in/")
Pdf.SaveAs("result.pdf")
[or] var Renderer = (New IronPdf.ChromePdfRenderer()).RenderUrlAsPdf("https://www.amazon.com/").SaveAs("result.pdf")
We can convert the link into a document in two ways in the example above. The first approach is to create an IronPDF object, and the second is to create a Renderurlpdf object.
The above implies that we can turn it into a document using Renderurlaspdf. Only the save location and the link must be provided. It takes 4.28 seconds to convert a URL to a Pdf document.

Using iText 7
The example createPdf()/CreatePdf() method has a very simple implementation. Its body is made up of just one line:
public void createPdf(string html, string dest)
{
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create));
}
public void createPdf(string html, string dest)
{
HtmlConverter.ConvertToPdf(html, new FileStream(dest, FileMode.Create));
}
Public Sub createPdf(ByVal html As String, ByVal dest As String)
HtmlConverter.ConvertToPdf(html, New FileStream(dest, FileMode.Create))
End Sub
The HtmlConverter object provides a number of static convertToPdf()/ConvertToPdf() methods, each of which takes a different set of parameters based on the use case. The first parameter HTML in the first example is a string with the following value:
public static String HTML = "<h1>Test</h1><p>Hello World</p>";
public static String HTML = "<h1>Test</h1><p>Hello World</p>";
Public Shared HTML As String = "<h1>Test</h1><p>Hello World</p>"

Reading PDF documents
With the help of IronPDF and Docotic, we can also read PDF files. Libraries of pdf files. A document can easily be converted to a text string. To extract the text, we can utilize one of two approaches. The first is to get a single string containing all of the page data. The second is to obtain the data one page at a time. Each of the two ways is supported by both libraries.
Using IronPDF as a tool for creating PDF documents
IronPDF allows us to read a PDF file that already exists. The sample source code for reading existing PDFs using IronPDF is provided below.
The first approach is to retrieve all of the data as a string as shown below.
var pdfDocument = IronPdf.PdfDocument.FromFile("result.pdf");
string AllText = pdfDocument.ExtractAllText();
var pdfDocument = IronPdf.PdfDocument.FromFile("result.pdf");
string AllText = pdfDocument.ExtractAllText();
Dim pdfDocument = IronPdf.PdfDocument.FromFile("result.pdf")
Dim AllText As String = pdfDocument.ExtractAllText()
The Fromfile method is used to read the PDF from an existing file and transform it into a pdf-document object in the sample code above. We can read the text and images accessible on the PDF pages using this object. The object has a method called ExtractAllText that extracts all of the text from a PDF document into a string.
The second approach to obtaining the text from one page or multiple pages is shown below:
var pdfDocument =IronPdf.PdfDocument.FromFile("result.pdf");
string onePageText = pdfDocument.ExtractTextFromPage(0);
string pagesText = pdfDocument.ExtractTextFromPages(new[] { 1, 2 });
var pdfDocument =IronPdf.PdfDocument.FromFile("result.pdf");
string onePageText = pdfDocument.ExtractTextFromPage(0);
string pagesText = pdfDocument.ExtractTextFromPages(new[] { 1, 2 });
Dim pdfDocument =IronPdf.PdfDocument.FromFile("result.pdf")
Dim onePageText As String = pdfDocument.ExtractTextFromPage(0)
Dim pagesText As String = pdfDocument.ExtractTextFromPages( { 1, 2 })
Using iText 7
To read a PDF file using iText, follow the steps below.
- Make a PDFReader object and wrap it in a PDFDocument.
- Can also be used in java tool.
- Find out how many pages there are in the PDF that need to be read.
- Using PdfTextExtractor, iterate through the pages and extract the content of each one.
- Reading is done in PDF format.
import java.io.IOException;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor;
public class ReadPDF {
public static final String READ_PDF = "F://knpcode//result//List.pdf";
public static void main(String[] args) {
try {
// PDFReader
PdfReader reader = new PdfReader(READ_PDF);
PdfDocument pdfDoc = new PdfDocument(reader);
// get the number of pages in PDF
int noOfPages = pdfDoc.getNumberOfPages();
System.out.println("Extracted content of PDF---- ");
for(int i = 1; i <= noOfPages; i++) {
// Extract content of each page
String contentOfPage = PdfTextExtractor.getTextFromPage(pdfDoc.getPage(i));
System.out.println(contentOfPage );
}
pdfDoc.close();
}catch (IOException e) {
System.out.println("Exception occurred " + e.getMessage());
}
}
}
import java.io.IOException;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor;
public class ReadPDF {
public static final String READ_PDF = "F://knpcode//result//List.pdf";
public static void main(String[] args) {
try {
// PDFReader
PdfReader reader = new PdfReader(READ_PDF);
PdfDocument pdfDoc = new PdfDocument(reader);
// get the number of pages in PDF
int noOfPages = pdfDoc.getNumberOfPages();
System.out.println("Extracted content of PDF---- ");
for(int i = 1; i <= noOfPages; i++) {
// Extract content of each page
String contentOfPage = PdfTextExtractor.getTextFromPage(pdfDoc.getPage(i));
System.out.println(contentOfPage );
}
pdfDoc.close();
}catch (IOException e) {
System.out.println("Exception occurred " + e.getMessage());
}
}
}
Private java As import
Private com As import
Private com As import
Private com As import
Public Class ReadPDF
Public Shared String As final
Public Shared Sub main(ByVal args() As String)
Try
' PDFReader
Dim reader As New PdfReader(READ_PDF)
Dim pdfDoc As New PdfDocument(reader)
' get the number of pages in PDF
Dim noOfPages As Integer = pdfDoc.getNumberOfPages()
System.out.println("Extracted content of PDF---- ")
For i As Integer = 1 To noOfPages
' Extract content of each page
Dim contentOfPage As String = PdfTextExtractor.getTextFromPage(pdfDoc.getPage(i))
System.out.println(contentOfPage)
Next i
pdfDoc.close()
Catch e As IOException
System.out.println("Exception occurred " & e.getMessage())
End Try
End Sub
End Class
Digital signatures
Individuals and organizations commonly use digital signatures in PDF documents to demonstrate who examined the document content on a given date/time, and that it was not updated after being signed.
Depending on the standards and processes connected with contract signing, a single PDF document may include one or many signatures. The digital signature is a piece of the file's unseen, hashed, and encrypted metadata that is integrated with a certificate.
The PDF file may optionally include an optional visible representation of the signature in addition to the real digital signature. In the visible area of the signature, a signature photo and/or a signing certificate summary may be added.
Using IronPDF
Let's take a look at how to use C# to create an x509certificate2 to digitally sign a PDF.
You can use it for free to test your work during development. Then, choose your project. Are you going to make a new document or sign an existing PDF?
We utilized a C# form in the code example below to allow the user to select their preferred PDF, which can then be digitally signed with a single click.
We already have a.pfx file (Personal Information Exchange Format) that is used to send a certificate using a private key.
We select the file to sign using the "SignPdfFile(FileName)" function.
using System.Drawing;
using System.Windows.Forms;
using IronPdf;
namespace digitalsign
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
//select the desired pdf file
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
//Here we have called an PDFSignature method to digitally sign the Existing PDF
new PdfSignature("Ironpdf.pfx", "123456").SignPdfFile(textBox1.Text);
//Used as confirmation
label3.Text = "Completed !";
label3.BackColor = Color.LightGreen;
label3.ForeColor = Color.Black;
}
}
}
using System.Drawing;
using System.Windows.Forms;
using IronPdf;
namespace digitalsign
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
//select the desired pdf file
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = openFileDialog1.FileName;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
//Here we have called an PDFSignature method to digitally sign the Existing PDF
new PdfSignature("Ironpdf.pfx", "123456").SignPdfFile(textBox1.Text);
//Used as confirmation
label3.Text = "Completed !";
label3.BackColor = Color.LightGreen;
label3.ForeColor = Color.Black;
}
}
}
Imports System.Drawing
Imports System.Windows.Forms
Imports IronPdf
Namespace digitalsign
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'select the desired pdf file
If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
textBox1.Text = openFileDialog1.FileName
End If
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Here we have called an PDFSignature method to digitally sign the Existing PDF
Call (New PdfSignature("Ironpdf.pfx", "123456")).SignPdfFile(textBox1.Text)
'Used as confirmation
label3.Text = "Completed !"
label3.BackColor = Color.LightGreen
label3.ForeColor = Color.Black
End Sub
End Class
End Namespace
As you can see in the output below, we initially choose the PDF. The paper was correctly digitally signed as soon as we hit the Import Signature button. It only needed a single line of code with IronPDF.


Using iText 7
By supporting PAdES and being one of the first to support signatures in the current PDF 2.0 release, iText has always been at the forefront of digital signatures in PDF.
The mature and user-friendly API has been rigorously tested by the industry and proven to be a success across a variety of use cases.
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2019 iText Group NV
*/
/*
* This class is part of the white paper entitled
* "Digital Signatures for PDF documents"
* written by Bruno Lowagie
*
* For more info, go to: http://itextpdf.com/learn
*/
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.X509;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Pkcs;
namespace iText.Samples.Signatures.Chapter02
{
public class C2_01_SignHelloWorld
{
public static readonly string DEST = "../../results/signatures/chapter02/";
public static readonly string KEYSTORE = "../../resources/encryption/ks";
public static readonly string SRC = "../../resources/pdfs/hello.pdf";
public static readonly char[] PASSWORD = "password".ToCharArray();
public static readonly String[] RESULT_FILES =
{
"hello_signed1.pdf",
"hello_signed2.pdf",
"hello_signed3.pdf",
"hello_signed4.pdf"
};
public void Sign(String src, String dest, X509Certificate[] chain, ICipherParameters pk,
String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location)
{
PdfReader reader = new PdfReader(src);
PdfSigner signer = new PdfSigner(reader, new FileStream(dest, FileMode.Create), new StampingProperties());
// Create the signature appearance
Rectangle rect = new Rectangle(36, 648, 200, 100);
PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
appearance
.SetReason(reason)
.SetLocation(location)
// Specify if the appearance before field is signed will be used
// as a background for the signed field. The "false" value is the default value.
.SetReuseAppearance(false)
.SetPageRect(rect)
.SetPageNumber(1);
signer.SetFieldName("sig");
IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm);
// Sign the document using the detached mode, CMS or CAdES equivalent.
signer.SignDetached(pks, chain, null, null, null, 0, subfilter);
}
public static void Main(String[] args)
{
DirectoryInfo directory = new DirectoryInfo(DEST);
directory.Create();
Pkcs12Store pk12 = new Pkcs12Store(new FileStream(KEYSTORE, FileMode.Open, FileAccess.Read), PASSWORD);
string alias = null;
foreach (var a in pk12.Aliases)
{
alias = ((string) a);
if (pk12.IsKeyEntry(alias))
break;
}
ICipherParameters pk = pk12.GetKey(alias).Key;
X509CertificateEntry[] ce = pk12.GetCertificateChain(alias);
X509Certificate[] chain = new X509Certificate[ce.Length];
for (int k = 0; k < ce.Length; ++k)
{
chain[k] = ce[k].Certificate;
}
C2_01_SignHelloWorld app = new C2_01_SignHelloWorld();
app.Sign(SRC, DEST + RESULT_FILES[0], chain, pk, DigestAlgorithms.SHA256,
PdfSigner.CryptoStandard.CMS, "Test 1", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[1], chain, pk, DigestAlgorithms.SHA512,
PdfSigner.CryptoStandard.CMS, "Test 2", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[2], chain, pk, DigestAlgorithms.SHA256,
PdfSigner.CryptoStandard.CADES, "Test 3", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[3], chain, pk, DigestAlgorithms.RIPEMD160,
PdfSigner.CryptoStandard.CADES, "Test 4", "Ghent");
}
}
}
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2019 iText Group NV
*/
/*
* This class is part of the white paper entitled
* "Digital Signatures for PDF documents"
* written by Bruno Lowagie
*
* For more info, go to: http://itextpdf.com/learn
*/
using System;
using System.IO;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.X509;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
using iText.Signatures;
using Org.BouncyCastle.Pkcs;
namespace iText.Samples.Signatures.Chapter02
{
public class C2_01_SignHelloWorld
{
public static readonly string DEST = "../../results/signatures/chapter02/";
public static readonly string KEYSTORE = "../../resources/encryption/ks";
public static readonly string SRC = "../../resources/pdfs/hello.pdf";
public static readonly char[] PASSWORD = "password".ToCharArray();
public static readonly String[] RESULT_FILES =
{
"hello_signed1.pdf",
"hello_signed2.pdf",
"hello_signed3.pdf",
"hello_signed4.pdf"
};
public void Sign(String src, String dest, X509Certificate[] chain, ICipherParameters pk,
String digestAlgorithm, PdfSigner.CryptoStandard subfilter, String reason, String location)
{
PdfReader reader = new PdfReader(src);
PdfSigner signer = new PdfSigner(reader, new FileStream(dest, FileMode.Create), new StampingProperties());
// Create the signature appearance
Rectangle rect = new Rectangle(36, 648, 200, 100);
PdfSignatureAppearance appearance = signer.GetSignatureAppearance();
appearance
.SetReason(reason)
.SetLocation(location)
// Specify if the appearance before field is signed will be used
// as a background for the signed field. The "false" value is the default value.
.SetReuseAppearance(false)
.SetPageRect(rect)
.SetPageNumber(1);
signer.SetFieldName("sig");
IExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm);
// Sign the document using the detached mode, CMS or CAdES equivalent.
signer.SignDetached(pks, chain, null, null, null, 0, subfilter);
}
public static void Main(String[] args)
{
DirectoryInfo directory = new DirectoryInfo(DEST);
directory.Create();
Pkcs12Store pk12 = new Pkcs12Store(new FileStream(KEYSTORE, FileMode.Open, FileAccess.Read), PASSWORD);
string alias = null;
foreach (var a in pk12.Aliases)
{
alias = ((string) a);
if (pk12.IsKeyEntry(alias))
break;
}
ICipherParameters pk = pk12.GetKey(alias).Key;
X509CertificateEntry[] ce = pk12.GetCertificateChain(alias);
X509Certificate[] chain = new X509Certificate[ce.Length];
for (int k = 0; k < ce.Length; ++k)
{
chain[k] = ce[k].Certificate;
}
C2_01_SignHelloWorld app = new C2_01_SignHelloWorld();
app.Sign(SRC, DEST + RESULT_FILES[0], chain, pk, DigestAlgorithms.SHA256,
PdfSigner.CryptoStandard.CMS, "Test 1", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[1], chain, pk, DigestAlgorithms.SHA512,
PdfSigner.CryptoStandard.CMS, "Test 2", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[2], chain, pk, DigestAlgorithms.SHA256,
PdfSigner.CryptoStandard.CADES, "Test 3", "Ghent");
app.Sign(SRC, DEST + RESULT_FILES[3], chain, pk, DigestAlgorithms.RIPEMD160,
PdfSigner.CryptoStandard.CADES, "Test 4", "Ghent");
}
}
}
'
'
'This file is part of the iText (R) project.
'Copyright (c) 1998-2019 iText Group NV
'
'
'
'* This class is part of the white paper entitled
'* "Digital Signatures for PDF documents"
'* written by Bruno Lowagie
'*
'* For more info, go to: http://itextpdf.com/learn
'
Imports System
Imports System.IO
Imports Org.BouncyCastle.Crypto
Imports Org.BouncyCastle.X509
Imports iText.Kernel.Geom
Imports iText.Kernel.Pdf
Imports iText.Signatures
Imports Org.BouncyCastle.Pkcs
Namespace iText.Samples.Signatures.Chapter02
Public Class C2_01_SignHelloWorld
Public Shared ReadOnly DEST As String = "../../results/signatures/chapter02/"
Public Shared ReadOnly KEYSTORE As String = "../../resources/encryption/ks"
Public Shared ReadOnly SRC As String = "../../resources/pdfs/hello.pdf"
Public Shared ReadOnly PASSWORD() As Char = "password".ToCharArray()
Public Shared ReadOnly RESULT_FILES() As String = { "hello_signed1.pdf", "hello_signed2.pdf", "hello_signed3.pdf", "hello_signed4.pdf" }
Public Sub Sign(ByVal src As String, ByVal dest As String, ByVal chain() As X509Certificate, ByVal pk As ICipherParameters, ByVal digestAlgorithm As String, ByVal subfilter As PdfSigner.CryptoStandard, ByVal reason As String, ByVal location As String)
Dim reader As New PdfReader(src)
Dim signer As New PdfSigner(reader, New FileStream(dest, FileMode.Create), New StampingProperties())
' Create the signature appearance
Dim rect As New Rectangle(36, 648, 200, 100)
Dim appearance As PdfSignatureAppearance = signer.GetSignatureAppearance()
appearance.SetReason(reason).SetLocation(location).SetReuseAppearance(False).SetPageRect(rect).SetPageNumber(1)
signer.SetFieldName("sig")
Dim pks As IExternalSignature = New PrivateKeySignature(pk, digestAlgorithm)
' Sign the document using the detached mode, CMS or CAdES equivalent.
signer.SignDetached(pks, chain, Nothing, Nothing, Nothing, 0, subfilter)
End Sub
Public Shared Sub Main(ByVal args() As String)
Dim directory As New DirectoryInfo(DEST)
directory.Create()
Dim pk12 As New Pkcs12Store(New FileStream(KEYSTORE, FileMode.Open, FileAccess.Read), PASSWORD)
Dim [alias] As String = Nothing
For Each a In pk12.Aliases
[alias] = (CStr(a))
If pk12.IsKeyEntry([alias]) Then
Exit For
End If
Next a
Dim pk As ICipherParameters = pk12.GetKey([alias]).Key
Dim ce() As X509CertificateEntry = pk12.GetCertificateChain([alias])
Dim chain(ce.Length - 1) As X509Certificate
For k As Integer = 0 To ce.Length - 1
chain(k) = ce(k).Certificate
Next k
Dim app As New C2_01_SignHelloWorld()
app.Sign(SRC, DEST & RESULT_FILES(0), chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CMS, "Test 1", "Ghent")
app.Sign(SRC, DEST & RESULT_FILES(1), chain, pk, DigestAlgorithms.SHA512, PdfSigner.CryptoStandard.CMS, "Test 2", "Ghent")
app.Sign(SRC, DEST & RESULT_FILES(2), chain, pk, DigestAlgorithms.SHA256, PdfSigner.CryptoStandard.CADES, "Test 3", "Ghent")
app.Sign(SRC, DEST & RESULT_FILES(3), chain, pk, DigestAlgorithms.RIPEMD160, PdfSigner.CryptoStandard.CADES, "Test 4", "Ghent")
End Sub
End Class
End Namespace
Pricing and Licensing
The dual-license model is used by iText. As a result, it provides both commercial and AGPL licenses. We'll compare the two and explain the differences on this page.

IronPDF is a C# PDF library that is free to use. It's free for development, and you can get a 30-day deployment sample by emailing the engineering team at developers@ironpdf.com
. IronPDF provides transparent pricing with licenses from $749, with many customizable options. By browsing through the IronPDF licenses, you can find one that suits both your needs and your budget.

Conclusion
IronPDF solves the substantial challenge of integrating PDF generation into your program by automating the conversion of prepared documents to enhance PDF documents. Within the IDE, all products are available for development and testing at no cost, and there are no time limits. NuGet can be used to install it. With .NET, it converts web forms, local HTML pages, and other web applications shipping to PDF, allowing users to download, email, or store documents in the cloud.
The iText 7 suite is a comprehensive PDF SDK that comprises the open-source iText 7 Core PDF library as well as optional add-ons to meet your specific requirements. The iText 7 Core PDF library is the latest version, a reworking of the popular iText 5 engine with a modular code structure and low-level functionality, enabling future advancements and expansion, as well as simplified coding. Under the terms of the open-source AGPL, you can use iText 7 Core and provide open-source add-ons for free and offer paid services.
If you want to distribute the iText software inside your product or deploy it on a network without releasing the source code of your own cloud apps under the AGPL license or a commercial license, you'll need to buy a license. On the other hand, IronPDF has much cheaper licensing starting from $749, and also offers a free trial.
For pragmatic coders who want to work swiftly and efficiently, IronPDF is a must-have. Most importantly, it helps you save time. It provides shortcodes that help your programming work become more effective. For example, using IronPDF, we can convert an ASP.NET page to create an ASP serving PDF files in C# with just a single line of code. IronPDF licensing packages include a cheap license with one year of free support, full access, and a closed-source product contact.
It is true that Iron Software software ranks highest! All API goods are top-of-the-line and provide you with the best in every category. For the time being, you can get our most user-friendly and up-to-date version of the five product suite API for the price of just two! Begin with the Lite package license, which starts at $749, then adjust it to the size of your team for your next winning project. We also offer one year of free support!