Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Developers in C# have always faced challenges when it comes to reading, writing, creating, or converting PDFs between different file formats. However, with the emergence of numerous libraries, these issues have been resolved, and the easy integration of these libraries has made them more popular and easy to use in C# applications.
This article aims to compare two of the most popular PDF libraries for .NET Framework and .NET Core developers:
Both of these libraries are .NET C# libraries that offer methods to generate, convert, and edit PDFs in .NET and .NET Core. The main question is to decide which of these C# PDF libraries is best suited for our project. In this article, we will compare these two libraries in the most comprehensive manner, highlighting their standout features, so you can make an informed decision when choosing the right library for your project.
Firstly, let's take a look at what both of these libraries have to offer, and then we'll move ahead with the comparison itself.
IronPDF is a comprehensive .NET PDF library solution that is particularly beneficial for C# developers. With this library, you can easily implement all the functionalities necessary to create an excellent PDF reader or PDF viewer in C#.
IronPDF has a .NET Chromium engine that renders HTML content to PDF documents, making it easier to design or position PDFs without requiring complex APIs. Its HTML to PDF converter enables the creation of a .NET PDF library using HTML5, CSS, JavaScript, and images. Additionally, it allows you to edit PDFs, add headers and footers, and extract images from PDFs with ease. Furthermore, it makes reading PDF text a straightforward process.
Visit ExpertPDF's Official Site for Detailed Information for more about their .NET library that offers developers to convert from HTML to PDF on the fly. If you need to generate PDF reports or make a PDF reader, you don't have to use complex report generating software anymore.
ExpertPDF is easy to use but yet it is a powerful PDF editor. It contains a high class HTML to PDF converter that can be implemented into any .NET application within a few minutes. It works with .NET Framework, .NET Core, .NET 5 and .NET 6.
It is a powerful .NET library that helps you create PDF viewers and documents from any webpage URL or raw HTML markup, string, or file in .NET Framework or .NET Core applications.
Following are the important features:
The rest of the article will cover the following topics:
Follow the steps to create a console application in C# using Visual Studio 2022:
Open Visual Studio 2022 and click create a new project
Select C# Console App and click next
From the next screen, type the name of your project and click next
Choose the .NET Framework for your application. We will use latest version 6.0.
Now our Console project is created and we are ready to test our libraries. However, we still need step them up into our project. Let's first install IronPDF.
There are multiple ways to download and install the IronPDF library. These are as follows:
Visual Studio itself provides the NuGet Package Manager to install all NuGet packages in C# projects. You can access it either through:
Right-clicking the project in the Solution Explorer
Once it's selected, browse for IronPDF NuGet package and install it, as shown in the Figure below:
Another method is to download IronPDF from the NuGet website. Visit IronPDF NuGet Page directly and download the package. Follow the steps:
You can also download the IronPDF .DLL file directly from the IronPDF website. Click on Download IronPDF DLL to install.
Next, reference IronPDF in your project by following these steps:
All done! IronPDF is now installed, and ready to use. However, before that, we will install ExpertPDF for comparison.
There are two ways to download and install ExpertPDF Library:
We are going to work with new the .NET Framework so we'll install ExpertPDF using NuGet Package Manager.
Just like IronPDF, you can access NuGet Package Manager by:
Right-clicking the project in the Solution Explorer
Once it's selected, browse for ExpertPDF NuGet package and install it, as shown below:
Note: ExpertPDF only supports Windows operating system.
Both of the libraries have the ability to convert HTML markup to PDF. Now, let's take a look at the C# code for each library one by one.
IronPDF is very straightforward when rendering HTML from existing URLs as PDF. It has a very high level of support for CSS, JavaScript, images, and Forms.
The following code sample creates a PDF directly from a website URL.
using IronPdf;
ChromePdfRenderer Renderer = new ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
using IronPdf;
ChromePdfRenderer Renderer = new ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
Imports IronPdf
Private Renderer As New ChromePdfRenderer()
Private Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
'
Pdf.SaveAs("url.pdf")
ExpertPDF converts URL to PDF using a savePdfFromUrlToFile
method, which is fast, secure and efficient. The formatting of the page is saved as it is on the actual web browser.
using ExpertPdf.HtmlToPdf;
PdfConverter pd = new PdfConverter();
pd.SavePdfFromUrlToFile("https://www.html-to-pdf.net/", "output.pdf");
using ExpertPdf.HtmlToPdf;
PdfConverter pd = new PdfConverter();
pd.SavePdfFromUrlToFile("https://www.html-to-pdf.net/", "output.pdf");
Imports ExpertPdf.HtmlToPdf
Private pd As New PdfConverter()
pd.SavePdfFromUrlToFile("https://www.html-to-pdf.net/", "output.pdf")
IronPDF and Expert PDF both provide the ability to create PDFs from a markup string containing HTML.
The following code snippet demonstrates how a PDF document image is rendered using an HTML input string.
using IronPdf;
var Renderer = new ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").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
var PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
PDF.SaveAs("html-with-assets.pdf");
using IronPdf;
var Renderer = new ChromePdfRenderer();
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").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
var PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
PDF.SaveAs("html-with-assets.pdf");
Imports IronPdf
Private Renderer = New ChromePdfRenderer()
Renderer.RenderHtmlAsPdf("<h1>Html with CSS and Images</h1>").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 PDF = Renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", "C:\site\assets\")
PDF.SaveAs("html-with-assets.pdf")
ExpertPDF HTML To PDF converter supports conversion from HTML string to PDF. The code is simple and self-explanatory as URL to PDF:
using ExpertPdf.HtmlToPdf;
PdfConverter pd = new PdfConverter();
pd.SavePdfFromHtmlStringToFile("<h1>PDF using Expert PDF</h1>", "html-to-pdf.pdf");
using ExpertPdf.HtmlToPdf;
PdfConverter pd = new PdfConverter();
pd.SavePdfFromHtmlStringToFile("<h1>PDF using Expert PDF</h1>", "html-to-pdf.pdf");
Imports ExpertPdf.HtmlToPdf
Private pd As New PdfConverter()
pd.SavePdfFromHtmlStringToFile("<h1>PDF using Expert PDF</h1>", "html-to-pdf.pdf")
The first argument is the actual HTML string, and the second argument is the filename to which scanned document will be saved.
Both IronPDF and ExpertPDF offer the ability to merge multiple PDF files into a single PDF file. This feature is useful for consolidating scattered data and sending it over the internet more efficiently.
The following code renders two PDFs created from different HTML strings and then merges them using Merge
method. This one-line of code and is very easy to use. More options can be added to the PDF settings while rendering.
using IronPdf;
var html_a = @"<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_A] 2nd Page</p>";
var html_b = @"<p> [PDF_B] </p>
<p> [PDF_B] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_B] 2nd Page</p>";
var renderer = new ChromePdfRenderer();
var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
using IronPdf;
var html_a = @"<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_A] 2nd Page</p>";
var html_b = @"<p> [PDF_B] </p>
<p> [PDF_B] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_B] 2nd Page</p>";
var renderer = new ChromePdfRenderer();
var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
Imports IronPdf
Private html_a = "<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_A] 2nd Page</p>"
Private html_b = "<p> [PDF_B] </p>
<p> [PDF_B] 1st Page </p>
<div style='page-break-after: always;'></div>
<p> [PDF_B] 2nd Page</p>"
Private renderer = New ChromePdfRenderer()
Private pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
Private pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
Private merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
merged.SaveAs("Merged.pdf")
The Merge
method also has an overload that accepts multiple documents in the form of Enumerable objects. You can see an example of its use in this IronPDF Code Example for Merging PDFs.
Note that if the PDF files being merged contain editable forms, the resulting PDF's form fields will have their names appended with the index number.
ExpertPDF uses a Merge PDF component to complete this task. This must be installed from NuGet Package Manager in order to use it. There is an AppendPDFFile
method which appends a PDF file to PDFMerge class object. The code to merge the two PDFs created previously by ExpertPDF goes as follows:
using ExpertPdf.MergePdf;
PDFMerge pDF = new PDFMerge();
pDF.AppendPDFFile("output.pdf");
pDF.AppendPDFFile("html-to-pdf.pdf");
pDF.SaveMergedPDFToFile("merged.pdf");
using ExpertPdf.MergePdf;
PDFMerge pDF = new PDFMerge();
pDF.AppendPDFFile("output.pdf");
pDF.AppendPDFFile("html-to-pdf.pdf");
pDF.SaveMergedPDFToFile("merged.pdf");
Imports ExpertPdf.MergePdf
Private pDF As New PDFMerge()
pDF.AppendPDFFile("output.pdf")
pDF.AppendPDFFile("html-to-pdf.pdf")
pDF.SaveMergedPDFToFile("merged.pdf")
IronPDF has the ability to convert a variety of images to PDF files, while ExpertPDF does not offer this feature. However, ExpertPDF can extract images from PDF files, and can also convert PDF files to images, a feature that IronPDF also provides.
In IronPDF, PDF documents can be easily created from one or more images using the ImageToPdfConverter
Class. You can load the images from the any folder in your application.
// One or more images as IEnumerable. This example selects all JPEG images in a specific folder.
var ImageFiles = System.IO.Directory.EnumerateFiles(@"C:\project\assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg"));
// Convert the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(ImageFiles).SaveAs(@"C:\project\composite.pdf");
//Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
// One or more images as IEnumerable. This example selects all JPEG images in a specific folder.
var ImageFiles = System.IO.Directory.EnumerateFiles(@"C:\project\assets").Where(f => f.EndsWith(".jpg") || f.EndsWith(".jpeg"));
// Convert the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(ImageFiles).SaveAs(@"C:\project\composite.pdf");
//Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
' One or more images as IEnumerable. This example selects all JPEG images in a specific folder.
Dim ImageFiles = System.IO.Directory.EnumerateFiles("C:\project\assets").Where(Function(f) f.EndsWith(".jpg") OrElse f.EndsWith(".jpeg"))
' Convert the images to a PDF and save it.
ImageToPdfConverter.ImageToPdf(ImageFiles).SaveAs("C:\project\composite.pdf")
'Also see PdfDocument.RasterizeToImageFiles() method to flatten a PDF to images or thumbnails
In addition to converting a variety of images to PDF files, IronPDF can also convert scanned documents, paper documents, and business documents to separate images. It can also extract images from these types of files.
IronPDF is a fully open commercial C# PDF library available on the IronPDF website. It is free for private development and can be licensed anytime for commercial uses. A variety of Licenses are available for single projects, single or multiple developers, agencies, and global corporations. It also supports SaaS and OEM redistribution.
All licenses provide a 30 day money back guarantee along with one year of support and product updates. The licenses are perpetual, this means only one time purchase without extra fees. The Lite package for a single developer and single project starts from $749.
ExpertPDF offers purchasing licenses per developer or per company. You can try ExpertPDF for free. You can check the license features list in below figure.
ExpertComponents Toolkit Total developer license starts from $850 and ExpertPDF Toolkit starts from $750. You can also purchase single components. The Full Pricing list for ExpertPDF is available on the website.
IronPDF renders HTML to PDF locally thus not requiring an internet connection. In reality, it spins up an object of a real standard compliant web browser implicitly. The HTML render is completely accurate and in vector format which is suitable for the highest standards of commercial printing. The output is clean and a high-quality PDF is generated. It can be licensed for commercial use and all its pricing is listed on its website without any hidden fees.
ExpertPDF's HTML-to-PDF Converter Library is a versatile tool that can convert webpages and HTML code to PDF documents, generate PDF reports from ASP.NET web pages, and even sign contracts with electronic signatures. It is free to use but can also be licensed for additional features.
While both libraries are capable of working with PDF files and converting from popular formats, IronPDF has some advantages over ExpertPDF. IronPDF offers conversion from a wider range of formats, including XML, images, and AngularJS, as well as more robust features for generating, formatting, and editing PDFs. IronPDF is a time-saving solution and is recommended for pragmatic developers seeking efficiency.
ExpertPDF comes in separate components that must be installed individually, whereas IronPDF is a complete software with all functionalities in one place. ExpertPDF may be a good choice for projects that only require a single component, such as HTML-to-PDF conversion. IronPDF's packages offer lifetime licenses with no ongoing costs, while ExpertPDF requires renewals.
9 .NET API products for your office documents