Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Ever-improving technology means smarter solutions for everyone, especially developers. Automation is now the key to software development processes. Working with C# PDF files has been problematic for developers for many years. There are many factors to consider when creating content for PDF files, and even more so when converting content from different formats to PDF. These issues have now been resolved with the construction of multiple libraries designed to help read, write, create and convert to PDFs from different formats.
This article will compare two of the most popular PDF libraries for .NET and .NET Core developers. These two libraries are:
IronPDF and XFININUM.PDF are two libraries that provide methods for creating, manipulating, and printing PDFs in .NET and .NET Core. The next question is deciding which C# PDF library is best for your .NET project. You can weigh your decision by reading the following comparison between the two libraries and their respective outstanding features for PDF conversion and manipulation.
First, let's take a look at what the two libraries have to offer, and then move on to the comparison itself.
The XFINIUM.PDF library is a cross-platform library for PDF development. It provides a wide variety of capabilities both for the amateur and the superior PDF developer. Whether you want to create a report, fill a PDF form, construct a PDF portfolio, redact touchy data from a PDF report or convert a PDF report to a multipage TIFF image.
XFINIUM.PDF is available in two editions: the Generator Edition, which includes PDF production and editing, and the Viewer Edition, which contains all of the functionality of the Generator Edition plus PDF rendering and PDF viewing. The Features section explains which features are included in both editions, and which are only available in the Viewer Edition.
XFINIUM.PDF was written entirely in C# and is completely managed code. It is licensed per developer with royalty-free distribution, allowing you to freely distribute your program without incurring any further costs.
The Generator Edition is a subset of the Viewer Edition. The Generator Edition offers PDF functionality for creating and editing PDFs, while the Viewer Edition adds PDF rendering capabilities to the Generator Edition. The Viewer Edition can convert PDF pages to RAW, BMP, GIF, JPG, PNG, and TIFF images.
Some of the important features include:
The IronPDF .NET PDF library is a dream come true for developers, especially C# programmers. With this amazing tool, you can easily construct a core PDF library for .NET.
IronPDF converts HTML pages to PDF files using the .NET Chromium engine. There is no need to use complicated APIs to position or design PDFs with HTML to PDF. Standard online documents are supported by IronPDF, including HTML, ASPX, JS, CSS, and pictures.
You can also use HTML5, CSS, JavaScript, and pictures to develop a .NET PDF library. A PDF can be easily edited, stamped, and added with headers and footers. It also makes reading PDF text and extracting graphics a breeze.
Download IronPDF for free and start using it in your .NET projects today.
Here are some of the key features:
IronPDF availables almost all operating systems and frameworks compatible with C#, including the following:
There are four ways to download and install the IronPDF library. These are as follows:
Visual Studio provides the NuGet Package Manager to install NuGet packages in your projects. You can access it through the Project Menu, or by right-clicking your project in the Solution Explorer. Both these options are shown below in screenshots as Figures 1 and 2.
Once selected, browse for the IronPDF package and install it, as shown in the screenshot below.
Another way to download and install the IronPDF C# library is to make use of the following steps to install the IronPDF NuGet package through the Developer Command Prompt.
Type the following command:
Install-Package IronPdf
The third way to download and install IronPDF is to follow the steps below. This can be done by visiting the NuGet site directly and downloading the package. The steps are:
You can download the IronPDF .DLL file directly from the website.
Reference the library in your project by using the next steps:
All done! IronPDF is downloaded, installed, and ready to use. However, before that, we should install the XFINIUM.PDF API.
In .NET Core, we can install Xfinium PDF either as a cake addin or a cake tool.
// Install Xfinium.Pdf.NetCore as a Cake Addin
#addin nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
// Install Xfinium.Pdf.NetCore as a Cake Tool
#tool nuget:?package=Xfinium.Pdf.NetCore&version=10.2.0
Next, let's delve into the comparison between IronPDF and XXFINIUM.PDF.
In today's world, software developers must know how to create a PDF file dynamically using C# code, as this is needed in practically all projects. You might need to create a PDF file for a variety of reasons, such as generating a report from user input, saving user text as PDF, extracting HTML information and converting it to PDF, and so forth.
The ability to convert an HTML webpage to PDF is included in both libraries. Let's take a look at each library's code one by one.
IronPDF has multiple methods for creating PDF files.
IronPDF makes it simple to convert HTML into PDF documents from existing URLs. JavaScript, images, forms, and CSS all have a high level of support.
IronPDF is used in the following code to create a PDF document directly from a website address.
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
using var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
Dim Renderer As New IronPdf.ChromePdfRenderer()
Dim Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
Pdf.SaveAs("url.pdf")
The following code demonstrates how an HTML input string can be used to render a PDF page. You can use just HTML, or combine it with CSS, pictures, and JavaScript.
var Renderer = new IronPdf.ChromePdfRenderer();
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");
// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
var Renderer = new IronPdf.ChromePdfRenderer();
using var PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>");
PDF.SaveAs("pixel-perfect.pdf");
// Load external html assets: images, css and javascript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
using var AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
AdvancedPDF.SaveAs("html-with-assets.pdf");
Dim Renderer = New IronPdf.ChromePdfRenderer()
Dim PDF = Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>")
PDF.SaveAs("pixel-perfect.pdf")
' Load external html assets: images, css and javascript.
' An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
Dim AdvancedPDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
AdvancedPDF.SaveAs("html-with-assets.pdf")
Using XFINIUM.PDF to create a blank PDF document requires only three lines of code: one line to create the document, one line to create one page, and another line to save the document.
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();
document.Save("empty.pdf");
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();
document.Save("empty.pdf");
Dim document As New PdfFixedDocument()
Dim page As PdfPage = document.Pages.Add()
document.Save("empty.pdf")
Three additional lines of code are required to add text content to the document above: one for font creation for drawing the text, one for brush creation and for setting the text color, and the other for actually drawing text and graphics on the page.
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();
// Create a standard font with Helvetica face and 24 point size
PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);
// Create a solid RGB red brush.
PdfBrush brush = new PdfBrush(PdfRgbColor.Red);
// Draw the text on the page.
page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100);
document.Save("helloworld.pdf");
PdfFixedDocument document = new PdfFixedDocument();
PdfPage page = document.Pages.Add();
// Create a standard font with Helvetica face and 24 point size
PdfStandardFont helvetica = new PdfStandardFont(PdfStandardFontFace.Helvetica, 24);
// Create a solid RGB red brush.
PdfBrush brush = new PdfBrush(PdfRgbColor.Red);
// Draw the text on the page.
page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100);
document.Save("helloworld.pdf");
Dim document As New PdfFixedDocument()
Dim page As PdfPage = document.Pages.Add()
' Create a standard font with Helvetica face and 24 point size
Dim helvetica As New PdfStandardFont(PdfStandardFontFace.Helvetica, 24)
' Create a solid RGB red brush.
Dim brush As New PdfBrush(PdfRgbColor.Red)
' Draw the text on the page.
page.Graphics.DrawString("Hello World", helvetica, brush, 100, 100)
document.Save("helloworld.pdf")
Our object model closely resembles the PDF standard. This allows you to easily build complicated abstractions on top of it, such as flow documents.
The XFINIUM.PDF library can both create new PDF forms and fill existing PDF forms.
Each type of form field supported in the PDF specification is represented by the corresponding class:
The name of the field and its location on the page are the only pieces of information needed to construct a form field. After creating the field object, it must be added to the page before any other attributes may be specified.
PdfTextBoxField firstNameTextBox = new PdfTextBoxField("firstname");
pdfpage.Fields.Add(firstNameTextBox);
firstNameTextBox.Widgets [0].VisualRectangle =
new PdfVisualRectangle(150, 45, 200, 20);
PdfTextBoxField firstNameTextBox = new PdfTextBoxField("firstname");
pdfpage.Fields.Add(firstNameTextBox);
firstNameTextBox.Widgets [0].VisualRectangle =
new PdfVisualRectangle(150, 45, 200, 20);
Dim firstNameTextBox As New PdfTextBoxField("firstname")
pdfpage.Fields.Add(firstNameTextBox)
firstNameTextBox.Widgets (0).VisualRectangle = New PdfVisualRectangle(150, 45, 200, 20)
Existing PDF forms can be filled if they are loaded in a PdfFixedDocument object. After the form has been loaded, the document’s fields collection is populated automatically with the fields defined in the form. A field is located in the collection by index or by its name, and it is filled by setting the generic value property defined in the PdfField base class or the specific value properties defined on each field type.
PdfFixedDocument document = new PdfFixedDocument("form.pdf");
(document.Form.Fields ["firstname"] as PdfTextBoxField).Text = "John";
(document.Form.Fields ["lastname"] as PdfTextBoxField).Value = "Doe";
(document.Form.Fields ["sex"].Widgets [0] as PdfRadioButtonWidget).Checked = true;
(document.Form.Fields ["firstcar"] as PdfComboBoxField).SelectedIndex = 0;
(document.Form.Fields ["secondcar"] as PdfListBoxField).SelectedIndex = 1;
(document.Form.Fields ["agree"] as PdfCheckBoxField).Checked = true;
document.Save("form_filled.pdf");
PdfFixedDocument document = new PdfFixedDocument("form.pdf");
(document.Form.Fields ["firstname"] as PdfTextBoxField).Text = "John";
(document.Form.Fields ["lastname"] as PdfTextBoxField).Value = "Doe";
(document.Form.Fields ["sex"].Widgets [0] as PdfRadioButtonWidget).Checked = true;
(document.Form.Fields ["firstcar"] as PdfComboBoxField).SelectedIndex = 0;
(document.Form.Fields ["secondcar"] as PdfListBoxField).SelectedIndex = 1;
(document.Form.Fields ["agree"] as PdfCheckBoxField).Checked = true;
document.Save("form_filled.pdf");
Dim document As New PdfFixedDocument("form.pdf")
TryCast(document.Form.Fields ("firstname"), PdfTextBoxField).Text = "John"
TryCast(document.Form.Fields ("lastname"), PdfTextBoxField).Value = "Doe"
TryCast(document.Form.Fields ("sex").Widgets (0), PdfRadioButtonWidget).Checked = True
TryCast(document.Form.Fields ("firstcar"), PdfComboBoxField).SelectedIndex = 0
TryCast(document.Form.Fields ("secondcar"), PdfListBoxField).SelectedIndex = 1
TryCast(document.Form.Fields ("agree"), PdfCheckBoxField).Checked = True
document.Save("form_filled.pdf")
Let's look at how we can create fillable PDFs using the IronPDF C# library.
// PM> Install-Package IronPdf
using IronPdf;
// Step 1. Creating a PDF with editable forms from HTML using form and input tags
var FormHtml = @"
<html>
<body>
<h2>Editable PDF Form</h2>
<form>
First name:<br> <input type='text' name='firstname' value='' > <br>
Last name:<br> <input type='text' name='lastname' value='' >
</form>
</body>
</html>";
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("BasicForm.pdf");
// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");
//Set and Read the value of the "firstname" field
var FirstNameField = FormDocument.Form.GetFieldByName("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);
//Set and Read the value of the "lastname" field
IronPdf.Forms.FormField LastNameField = FormDocument.Form.GetFieldByName("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);
FormDocument.SaveAs("FilledForm.pdf");
// PM> Install-Package IronPdf
using IronPdf;
// Step 1. Creating a PDF with editable forms from HTML using form and input tags
var FormHtml = @"
<html>
<body>
<h2>Editable PDF Form</h2>
<form>
First name:<br> <input type='text' name='firstname' value='' > <br>
Last name:<br> <input type='text' name='lastname' value='' >
</form>
</body>
</html>";
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
Renderer.RenderingOptions.CreatePdfFormsFromHtml = true;
Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("BasicForm.pdf");
// Step 2. Reading and Writing PDF form values.
var FormDocument = PdfDocument.FromFile("BasicForm.pdf");
//Set and Read the value of the "firstname" field
var FirstNameField = FormDocument.Form.GetFieldByName("firstname");
FirstNameField.Value = "Minnie";
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value);
//Set and Read the value of the "lastname" field
IronPdf.Forms.FormField LastNameField = FormDocument.Form.GetFieldByName("lastname");
LastNameField.Value = "Mouse";
Console.WriteLine("LastNameField value: {0}", LastNameField.Value);
FormDocument.SaveAs("FilledForm.pdf");
' PM> Install-Package IronPdf
Imports IronPdf
' Step 1. Creating a PDF with editable forms from HTML using form and input tags
Private FormHtml = "
<html>
<body>
<h2>Editable PDF Form</h2>
<form>
First name:<br> <input type='text' name='firstname' value='' > <br>
Last name:<br> <input type='text' name='lastname' value='' >
</form>
</body>
</html>"
Private Renderer As New IronPdf.ChromePdfRenderer()
Renderer.RenderingOptions.CreatePdfFormsFromHtml = True
Renderer.RenderHtmlAsPdf(FormHtml).SaveAs("BasicForm.pdf")
' Step 2. Reading and Writing PDF form values.
Dim FormDocument = PdfDocument.FromFile("BasicForm.pdf")
'Set and Read the value of the "firstname" field
Dim FirstNameField = FormDocument.Form.GetFieldByName("firstname")
FirstNameField.Value = "Minnie"
Console.WriteLine("FirstNameField value: {0}", FirstNameField.Value)
'Set and Read the value of the "lastname" field
Dim LastNameField As IronPdf.Forms.FormField = FormDocument.Form.GetFieldByName("lastname")
LastNameField.Value = "Mouse"
Console.WriteLine("LastNameField value: {0}", LastNameField.Value)
FormDocument.SaveAs("FilledForm.pdf")
We begin by creating a form with HTML formatting tags in the following code. After that, we save it as a PDF document. We begin reading and writing PDF form values in Step #2. With the field name, you can get to the form field. The GetFieldByName function is available in IronPDF. The selected field's value is then set, and the newly-filled form is saved.
In the modern era, many people are working remotely. Filling and signing forms, sending files, and processing documents are just some of the principal activities businesses need to complete on a daily basis. One such principal activity is the signing of PDF documents, PDF portfolios, and PDF forms as alternatives to paper documents. Digital signatures have become essential as companies seek ways to sign agreements and contracts, as well as share PDF forms online.
A signature field in a PDF file is used to apply a digital signature (PdfSignatureField class). Although the signature field is a form field that appears on one of the document's pages, the digital signature is used to sign the entire document, not just that page.
The signing process begins with a PdfDigitalSignature object being used to set the signature attribute of a signature field. Because the signature is based on the actual binary layout of the PDF file, it is formed when the document is saved.
The PdfDigitalSignature class is the foundation for all XFINIUM digital signatures.
There are several signature classes to choose from:
Developers frequently inquire about utilizing IronPDF and C# to programmatically add a signature to a PDF. This can mean a variety of things to developers:
The first approach involves stamping a signature PNG into a PDF page that already exists. It can be used as a signature or a company stamp. Opacity is encouraged. Only a few lines of code are required to complete the procedure.
// open an existing PDF document or create a new one
PdfDocument Pdf = PdfDocument.FromFile(@"C:\Path\To\ASPX to PDF.pdf");
var SignatureStamp = new HtmlStamp() { Html = "<img src='signature.png' />", Width = 150, Height = 50, Bottom = 300, Left=85, ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent };
Pdf.StampHTML(SignatureStamp,1);
Pdf.SaveAs(@"C:\Path\To\ASPX to PDF.pdf");
// open an existing PDF document or create a new one
PdfDocument Pdf = PdfDocument.FromFile(@"C:\Path\To\ASPX to PDF.pdf");
var SignatureStamp = new HtmlStamp() { Html = "<img src='signature.png' />", Width = 150, Height = 50, Bottom = 300, Left=85, ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent };
Pdf.StampHTML(SignatureStamp,1);
Pdf.SaveAs(@"C:\Path\To\ASPX to PDF.pdf");
' open an existing PDF document or create a new one
Dim Pdf As PdfDocument = PdfDocument.FromFile("C:\Path\To\ASPX to PDF.pdf")
Dim SignatureStamp = New HtmlStamp() With {
.Html = "<img src='signature.png' />",
.Width = 150,
.Height = 50,
.Bottom = 300,
.Left=85,
.ZIndex = HtmlStamp.StampLayer.OnTopOfExistingPDFContent
}
Pdf.StampHTML(SignatureStamp,1)
Pdf.SaveAs("C:\Path\To\ASPX to PDF.pdf")
The following code cryptographically signs a PDF using a .pfx and .p12 X509Certificate2 digital certificate which can be created easily with just one line of code.
// 123456 below represents the signature password
new IronPdf.PdfSignature("CertificateFile.p12", "123456").SignPdfFile("ASPX to PDF.pdf");
// 123456 below represents the signature password
new IronPdf.PdfSignature("CertificateFile.p12", "123456").SignPdfFile("ASPX to PDF.pdf");
' 123456 below represents the signature password
Call (New IronPdf.PdfSignature("CertificateFile.p12", "123456")).SignPdfFile("ASPX to PDF.pdf")
This more advanced example allows the .pfx / .p12 X509Certificate2 digital id signing method to be combined with a scan of a handwritten sign.
var Signature = new IronPdf.PdfSignature("Iron.pfx", "123456");
PdfDocument doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
// Step 3. Optional signing options and a handwritten Signature graphic
Signature.SigningContact = "support@ironsoftware.com";
Signature.SigningLocation = "Chicago, USA";
Signature.SigningReason = "To show how to sign a PDF";
Signature.LoadSignatureImageFromFile("handwriting.png");
doc.SignPdfWithDigitalSignature(Signature);
doc.SaveAs("ASPX to PDF.pdf");
var Signature = new IronPdf.PdfSignature("Iron.pfx", "123456");
PdfDocument doc = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>");
// Step 3. Optional signing options and a handwritten Signature graphic
Signature.SigningContact = "support@ironsoftware.com";
Signature.SigningLocation = "Chicago, USA";
Signature.SigningReason = "To show how to sign a PDF";
Signature.LoadSignatureImageFromFile("handwriting.png");
doc.SignPdfWithDigitalSignature(Signature);
doc.SaveAs("ASPX to PDF.pdf");
Dim Signature = New IronPdf.PdfSignature("Iron.pfx", "123456")
Dim doc As PdfDocument = Renderer.RenderHtmlAsPdf("<h1>Testing 2048 bit digital security</h1>")
' Step 3. Optional signing options and a handwritten Signature graphic
Signature.SigningContact = "support@ironsoftware.com"
Signature.SigningLocation = "Chicago, USA"
Signature.SigningReason = "To show how to sign a PDF"
Signature.LoadSignatureImageFromFile("handwriting.png")
doc.SignPdfWithDigitalSignature(Signature)
doc.SaveAs("ASPX to PDF.pdf")
Each package is available in two editions: the Generator Edition, which provides PDF production and editing features, and the Viewer Edition, which contains all of the functionality of the Generator Edition, plus PDF rendering and PDF viewing.
The pricing ranges from $290.00 to $872.00 per year depending on the respective package.
IronPDF, on the other hand, is a C# PDF library. It is free to use for development and can be licensed for commercial use at any time. Single-project licenses, single developers, agencies, and multinational organizations, as well as SaaS and OEM redistribution, are all accessible. All licenses come with a 30-day money-back guarantee, a year of software support and upgrades, dev/staging/production validity, and a perpetual license (one-time purchase). The Lite package is available for $749. There are no recurring expenses with IronPDF products.
The Iron PDF library makes it easier to create PDF documents because it does not rely on proprietary APIs. "HTML-To-PDF" converts open standard document types such as HTML, JS, CSS, JPG, PNG, GIF, and SVG into pixel-perfect PDFs. In other words, it builds on the talents that developers currently have. It allows users to download documents, email them, or save them to the cloud, and make bills, quotes, reports, contracts, and other paperwork. It works with ASP.NET, ASP.NET Core, web forms, MVC, .NET Framework, and .NET Core Web APIs.
The XFINIUM.PDF library has a wide range of functionality for both novices and advanced PDF developers. Whether you need to make a simple report, fill out a PDF form, construct a PDF portfolio, redact sensitive information from a PDF file, or convert a PDF file to a multipage TIFF image, it has the tools you need. You have complete control over the PDF files generated because the basic object model adheres to the PDF specification. XFINIUM.PDF code can be compiled on all supported platforms without modification. The XFINIUM.PDF collection is available to assist you.
XFINIUM.PDF licenses come in two editions, the Generator and the Viewer, which start at $290 and $387 respectively. This is somewhat cheaper than IronPDF, which has a light version starting at $749. IronPDF is worth going for because it offers both single and multi-user licenses, while XFINIUM.PDF offers only a single-user license — meaning that you will need a license for every developer. On the other hand, IronPDF offers aprofessional license starting at $799 which can be used by an unlimited number of users.
With IronPDF, you can manipulate PDF files more easily than with XFINIUM.PDF. IronPDF uses fewer lines of code for complicated manipulations, which helps to ease the workload of the programmer.
The Iron Software company also offers all its customers the option to acquire the whole suite of packages with just two clicks. This means that for the price of just two libraries in the Iron Software suite, you can currently get all five libraries, along with uninterrupted support for all of them.
9 .NET API products for your office documents