Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Working with PDF files in C# has proved difficult for developers over the years. There is a wide variety of factors to take into account when rendering content from PDF files, and even more so when converting content from different formats to PDF. These issues have now been solved with the completion of numerous libraries designed to read, write, create, and convert to PDF 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 Select PDF are both libraries that provide methods to create, manipulate and print PDFs in .NET and .NET Core. The next question is to decide which C# PDF Library is best suited for your .NET project. You can weigh up your decision as you read the following comparison between the two libraries and their respective standout features for converting and manipulating PDFs.
Let's look firstly at what both libraries have to offer, and then move on to the comparison itself.
The IronPDF .NET PDF Library solution is a dream for developers, especially software engineers who use C#. You can easily create a core pdf library for .NET with this excellent tool.
IronPDF uses a .NET Chromium engine to render HTML pages to PDFs. With HTML to PDF there is no need to use complex APIs to position or design PDFs. IronPDF supports standard web documents: HTML, ASPX, JS, CSS, and images.
It also enables you to create a .NET PDF library using HTML5, CSS, JavaScript, and images. You can effortlessly edit, stamp, and add headers and footers to a PDF. Further, it makes it very easy to read PDF text and extract images. This all in one package attracts developers for free as well as the deployment of commercial applications.
Some of the important features include:
Create PDFs (HTML to PDF)
Edit Existing PDF Documents without Adobe Acrobat
Manipulate Existing PDF Documents
Convert from Multiple Formats
Save and Print
Note: Now you can purchase Iron Suite for .NET (IronPDF, IronOCR, IronXL, IronBarcode, IronWebscraper) 7 Licenses for the price of 2 making it a standout feature among its competitors.
Select PDF for .NET is a professional PDF library that can be used for creating, writing, editing, handling and reading PDF files without any external dependencies within .NET applications. Using this .NET PDF library, you can implement rich capabilities to create PDFs from scratch, or process existing PDF documents entirely through C#/VB.NET without installing Adobe Acrobat.
Select PDF provides versions for .NET and .NET Core 2.0 and above (through .NET Standard 2.0). Select PDF only works on Windows. Select PDF works on Azure cloud, including Azure Web Apps (Basic Plan or above) with some limitations.
Select Pdf for .NET free version contains ready-to-use samples for Windows Forms, ASP.NET, ASP.NET MVC with Razor and ASPX engines.
Note: Select Pdf works online and currently works only on Windows systems. There is no support for Linux, Xamarin, or other platforms.
SelectPDF Library Features
Here are some of the most important Select PDF Features:
General Features
HTML to PDF Converter Features
Use the following steps to create an ASP.NET website:
Figure 1 – New Project Dialog Box
Figure 2 – Web Forms
Now the project is created and we are almost ready to test the libraries. However, we still need to install and integrate them into our project. Let's install IronPDF first.
There are four ways to download and install the IronPDF library. They are as follows:
Let’s take a closer look at each one.
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 3 and 4.
Figure 3 – Project Menu > Manage NuGet Packages
Figure 4 – Right Click Solution Explorer
Once selected, browse for the IronPDF package and install it, as shown in the screenshot below.
Figure 5 – Install IronPDF from NuGet Package
Another way to download and install 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 directly download the IronPDF .DLL file directly from the website. It can be directly downloaded from the IronPDF DLL download.
Figure 6 – Direct Download IronPDF C# Library
Reference the library in your project by using the following steps:
All done! IronPDF is downloaded, installed, and ready to use. However, we should first download and set up the EVO HTML to PDF Converter.
The Select PDF Library for .NET – 2021 Vol 2 is now available.
There are two ways to install the Select PDF library:
Let's have a closer look at each one.
The easiest way to install Select Pdf is by using a NuGet Package, go to NuGet Package Manager and install one of the following packages:
.NET version - AnyCPU (.NET 2.0 and .NET 4.0-4.5) Select.Pdf: https://www.nuget.org/packages/Select.Pdf/.
.NET version - x64 optimized version Select.Pdf.x64: https://www.nuget.org/packages/Select.Pdf.x64/.
.NET Core and .NET 5 version - Windows only (and .NET 4.6.1 and .NET 4.7.2) - Select.Pdf.NetCore: https://www.nuget.org/packages/Select.Pdf.NetCore/.
Note 1: If the x64 version is used, the application needs to target x64 platform and it needs to run in an x64 worker process.
Note 2: The .NET Core version is for .NET Core 2.0 or above through .NET Standard 2.0 (with with .NET Core 2.x, 3.x, .NET 5). Currently it requires a Windows system to run. It does not work on Linux or Mac or Xamarin.
Note 3: Blink rendering engine only works with .NET Core version and with .NET Framework (starting with 4.6.1). Blink rendering engine was introduced with Select Pdf v19.1.
SelectPdf can be downloaded from the product site: https://selectpdf.com. The free trial product archive download page can be found at this link: https://selectpdf.com/downloads/. SelectPdf is shipped as a product archive with the following structure:
Assemblies
It contains the assemblies and related files needed by SelectPdf Library for .NET.
Note: The .NET Core version and .NET versions (targeting 4.6.1 or above) have additional dependencies that need to be installed via NuGet.
Documentation
Project Setup
Both libraries provide the facility to convert an HTML webpage to PDF. Let's have a look at the code for each library one-by-one.
IronPDF makes it very straightforward to render HTML from existing URLs as PDF documents. There is a very high level of support for JavaScript, Images, Forms, and CSS.
The following code uses IronPDF to create a PDF document directly from a website address:
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
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")
Converting from HTML to PDF with SelectPDF is very easy. The following code uses SelectPDF to generate a PDF file directly from a website address.
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl("https://selectpdf.com/");
// save pdf document
doc.Save(file);
// close pdf document
doc.Close();
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting an url
PdfDocument doc = converter.ConvertUrl("https://selectpdf.com/");
// save pdf document
doc.Save(file);
// close pdf document
doc.Close();
' instantiate a html to pdf converter object
Dim converter As New HtmlToPdf()
'
' create a new pdf document converting an url
Dim doc As PdfDocument = converter.ConvertUrl("https://selectpdf.com/")
'
' save pdf document
doc.Save(file)
'
' close pdf document
doc.Close()
IronPDF and SelectPDF both provide the facility to generate PDF from a string containing HTML. Both use only two lines of code to accomplish this task.
The following code shows that a PDF document can be rendered using an HTML input string. You can choose simple HTML, or also incorporate CSS, images, and JavaScript.
var Renderer = new IronPdf.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");
var Renderer = new IronPdf.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");
Dim Renderer = New IronPdf.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")
Using SelectPDF HTML to Pdf Converter for .NET any raw HTML code can be converted to PDF. SelectPDF supports the latest HTML5 with CSS3 style sheets. The following code shows that a PDF can be generated using a string containing HTML.
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting an html string
PdfDocument doc = converter.ConvertHtmlString("<h1>Html with CSS and Images</h1>", baseUrl);
// save pdf document
doc.Save(Response, false, "Sample.pdf");
// close pdf document
doc.Close();
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting an html string
PdfDocument doc = converter.ConvertHtmlString("<h1>Html with CSS and Images</h1>", baseUrl);
// save pdf document
doc.Save(Response, false, "Sample.pdf");
// close pdf document
doc.Close();
' instantiate a html to pdf converter object
Dim converter As New HtmlToPdf()
' create a new pdf document converting an html string
Dim doc As PdfDocument = converter.ConvertHtmlString("<h1>Html with CSS and Images</h1>", baseUrl)
' save pdf document
doc.Save(Response, False, "Sample.pdf")
' close pdf document
doc.Close()
The next code for both IronPDF and SelectPDF creates a PDF from an ASP.NET web page.
The following code renders the ASPX web page file to PDF using IronPDF. This is a one-line code and very easy to use. More options can be added to the PDF settings while rendering.
protected void Page_Load(object sender, EventArgs e)
{
IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
protected void Page_Load(object sender, EventArgs e)
{
IronPdf.AspxToPdf.RenderThisPageAsPdf();
}
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
IronPdf.AspxToPdf.RenderThisPageAsPdf()
End Sub
Sometimes, there is a need in an ASP.NET application to convert a web page to PDF. SelectPDF HTML to Pdf Converter and an ASP.NET trick can be used to achieve this task. Take a look at the sample code below.
protected override void Render(HtmlTextWriter writer)
{
if (startConversion)
{
// get html of the page
TextWriter myWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(myWriter);
base.Render(htmlWriter);
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting the html string of the page
PdfDocument doc = converter.ConvertHtmlString(
myWriter.ToString(), Request.Url.AbsoluteUri);
// save pdf document
doc.Save(Response, false, "Sample.pdf");
// close pdf document
doc.Close();
}
else
{
// render web page in browser
base.Render(writer);
}
}
protected override void Render(HtmlTextWriter writer)
{
if (startConversion)
{
// get html of the page
TextWriter myWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(myWriter);
base.Render(htmlWriter);
// instantiate a html to pdf converter object
HtmlToPdf converter = new HtmlToPdf();
// create a new pdf document converting the html string of the page
PdfDocument doc = converter.ConvertHtmlString(
myWriter.ToString(), Request.Url.AbsoluteUri);
// save pdf document
doc.Save(Response, false, "Sample.pdf");
// close pdf document
doc.Close();
}
else
{
// render web page in browser
base.Render(writer);
}
}
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
If startConversion Then
' get html of the page
Dim myWriter As TextWriter = New StringWriter()
Dim htmlWriter As New HtmlTextWriter(myWriter)
MyBase.Render(htmlWriter)
' instantiate a html to pdf converter object
Dim converter As New HtmlToPdf()
' create a new pdf document converting the html string of the page
Dim doc As PdfDocument = converter.ConvertHtmlString(myWriter.ToString(), Request.Url.AbsoluteUri)
' save pdf document
doc.Save(Response, False, "Sample.pdf")
' close pdf document
doc.Close()
Else
' render web page in browser
MyBase.Render(writer)
End If
End Sub
Conversion from PDF to images is only provided by IronPDF. SelectPDF does not provide this facility to convert images to PDF. Instead, it allows the conversion from PDF to images. In the IronPDF library, PDF can be easily constructed from one or more image files using the IronPdf.ImageToPdfConverter Class.
// 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
SelectPdf Library for .NET is provided as a free trial product that can be tested without any limitations for 30 days. The free trial is fully functional, but without a license key; a watermark will be displayed on each page of the PDF files generated with the library. A license key is needed to unlock the product and remove the demo watermark. A Single Developer License starts from$749. Licenses are available for multiple developers as well. A complete list can be checked from the product website: https://selectpdf.com/pricing.
IronPDF is an openly commercial C# PDF library. It is free for development and can always be licensed for commercial deployment. Licenses are available for single-project use, single developers, agencies, and global corporations, as well as SaaS and OEM redistribution. All licenses include a 30-day money-back guarantee, one year of product support and updates, validity for dev/staging/production, and also a permanent license (one-time purchase). The Lite package starts from $749.
Summary
IronPDF does not render HTML to PDF from a remote server. It actually spins up an instance of a real standard compliant web browser behind the scenes (without any additional software needing to be installed). The HTML is rendered with complete accuracy — and in a vector format suitable for the highest standards of commercial printing. The output is a clean and high-quality PDF. It is openly commercial, with licensing and pricing details all published on the website.
SelectPDF is an HTML To PDF Online REST API. It implies the rendering of the web page being converted. Because of the support to run complex HTML/CSS/JavaScript, a number of things need to be taken into consideration when using SelectPDF to make sure your application remains secure. The generated PDFs are perfect, featuring different PDF file security settings and PDF page settings. The API is easy to use and the integration takes only a few lines of code. Licensing and pricing details are fully published on the website.
Conclusion
Here, IronPDF has an advantage over SelectPDF as it can work offline once installed. In comparison to SelectPDF, IronPDF provides conversion from different formats to PDF: e.g. XML to PDF, images to PDF, and Angular JS to PDF. IronPDF is highly recommended for pragmatic coders seeking to work effectively and efficiently. Most importantly, it is time-saving. SelectPDF can be useful when dealing with PDF documents in different server-side languages. Moreover, IronPDF packages provide a lifetime license, and there are no ongoing costs, while the SelectPDF Online REST API does have ongoing costs. Now you can buy IronPDF 5 .NET products just for the price of 2. This makes IronPDF proven winners among its competitors and yes it also saves production costs!
9 .NET API products for your office documents