Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
To create, read, write and convert PDFs from different formats has always been a challenging task for developers. With the completion of numerous libraries, these issues have now been solved. Moreover, the easy integration of the libraries makes them more popular and easy to use in C# applications.
This article will compare two of the most popular PDF libraries for .NET and .NET Core developers. These two libraries are:
IronPDF and PDFTron are both libraries that provide methods to create, manipulate and print PDF 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 PDF files. 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.
The IronPDF C# Library — Standout Features
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: You can also check out other products besides IronPDF because you can now purchase Iron Suite for .NET and obtain five Licenses for the price of two, giving you IronPDF, IronOCR, IronXL, IronBarcode, and IronWebscraper.
The PDFTron SDK is built in-house to bring accurate and reliable rendering to your digital content of any size and complexity. It brings PDF, CAD & MS Office capabilities to any software on Windows, Mac OS, Linux, Android, iOS, and the web.
PDFTron Systems Inc. is a comprehensive cross-platform PDF and Office SDK that allows you to write stand-alone, cross-platform, and reliable commercial applications. PDFTron's PDFnet SDK is a high-quality, industry-strength .NET PDF library (with WPF/WinForms support) for the most demanding and diverse applications.
The PDFtron .NET PDF C# Library — Standout Features
Some of the important features include:
Convert from Multiple Formats
The rest of this article will look at the following topics:
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. These 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.
Figure 3 – Solution Explorer
Figure 4 – Project Menu > Manage NuGet Packages
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.
Reference the library in your project by following these steps:
All done! IronPDF is downloaded, installed, and ready to use. However, before that, we should install PDFTron.
The following steps help you to set up PDFtron SDK for users' work.
This article uses PDFNET_BASE as the path into the folder that you extracted.
PDFNET_BASE = path/to/extraction/folder/PDFNetDotNet4/
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
' Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5")
Note: PDFTron collects some data regarding your usage of the SDK for product improvement.
Figure 6 – PDFTron - copy_local_false
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
<configuration>
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
</configuration>
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'<configuration> <runtime> <loadFromRemoteSources enabled="true" /> </runtime> </configuration>
xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
This section will go through the NuGet integration steps.
Figure 7 – PDFTron - Installation using NuGet Package
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. 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.
using IronPdf;
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
using IronPdf;
IronPdf.ChromePdfRenderer Renderer = new IronPdf.ChromePdfRenderer();
var Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/");
Pdf.SaveAs("url.pdf");
Imports IronPdf
Private Renderer As New IronPdf.ChromePdfRenderer()
Private Pdf = Renderer.RenderUrlAsPdf("https://ironpdf.com/")
Pdf.SaveAs("url.pdf")
HTML2PDF Module is an optional add-on utility that can be used with PDFTron SDK to convert an HTML file to a PDF document without any external third-party dependencies.
Note: Requires the HTML2PDF (Download link) module add-on. The HTML2PDF module is packaged as a zip archive and is meant to be expanded directly into the directory of your previous PDFTron SDK download.
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
HTML2PDF converter = new HTML2PDF();
// add from a web page location
converter.InsertFromURL(webPageLocation);
// apply conversion
converter.Convert(doc);
doc.Save("url.pdf", SDFDoc.SaveOptions.e_linearized);
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
HTML2PDF converter = new HTML2PDF();
// add from a web page location
converter.InsertFromURL(webPageLocation);
// apply conversion
converter.Convert(doc);
doc.Save("url.pdf", SDFDoc.SaveOptions.e_linearized);
Imports pdftron
Imports pdftron.SDF
Imports pdftron.PDF
' Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5")
' Start with a PDFDoc (the conversion destination)
Dim doc As New PDFDoc()
Dim converter As New HTML2PDF()
' add from a web page location
converter.InsertFromURL(webPageLocation)
' apply conversion
converter.Convert(doc)
doc.Save("url.pdf", SDFDoc.SaveOptions.e_linearized)
IronPDF and PDFTron 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.
using IronPdf;
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");
using IronPdf;
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");
Imports IronPdf
Private 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")
HTML2PDF converter supports converts HTML from a string and offers many options to control page size and formatting.
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
HTML2PDF converter = new HTML2PDF();
// add from HTML String data
converter.InsertFromHtmlString("<h1>Html with CSS and Images</h1>");
// apply conversion
converter.Convert(doc);
doc.Save("html-with-assets.pdf", SDFDoc.SaveOptions.e_linearized);
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5");
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
HTML2PDF converter = new HTML2PDF();
// add from HTML String data
converter.InsertFromHtmlString("<h1>Html with CSS and Images</h1>");
// apply conversion
converter.Convert(doc);
doc.Save("html-with-assets.pdf", SDFDoc.SaveOptions.e_linearized);
Imports pdftron
Imports pdftron.SDF
Imports pdftron.PDF
' Demo license key
pdftron.PDFNet.Initialize("demo:1642970088321:7b229755030000000066e7418b621975e2121afda6cb46e1ecba7925a5")
' Start with a PDFDoc (the conversion destination)
Dim doc As New PDFDoc()
Dim converter As New HTML2PDF()
' add from HTML String data
converter.InsertFromHtmlString("<h1>Html with CSS and Images</h1>")
' apply conversion
converter.Convert(doc)
doc.Save("html-with-assets.pdf", SDFDoc.SaveOptions.e_linearized)
IronPDF can easily convert ASPX web pages to PDF with one line of code, while PDFTron technology lacks this feature of direct conversion.
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
In the IronPDF library, PDF solid documents can be easily constructed from one or more image files using the IronPdf.ImageToPdfConverter Class. You can load the images from the assets in your PDF generation software applications.
// 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
Here is some sample C# code to use PDFTron SDK for direct, high-quality conversion between PDF, XPS, EMF, SVG, TIFF, PNG, JPEG, and other image formats ('pdftron.PDF.Convert' namespace). It uses the Convert.ToPdf method and is oriented more towards MS office documents with office capabilities such as converting any printable document (ex. TXT, RTF, Word, MS Office, DXF, DWG, etc) to PDF or XPS using a universal document converter.
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
// Set the path of the image file
var filename = "sample-image.png";
// perform the conversion with no optional parameters
Convert.ToPdf(doc, filename);
doc.Save("sample-image.pdf", SDFDoc.SaveOptions.e_linearized);
using pdftron;
using pdftron.SDF;
using pdftron.PDF;
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();
// Set the path of the image file
var filename = "sample-image.png";
// perform the conversion with no optional parameters
Convert.ToPdf(doc, filename);
doc.Save("sample-image.pdf", SDFDoc.SaveOptions.e_linearized);
Imports pdftron
Imports pdftron.SDF
Imports pdftron.PDF
' Start with a PDFDoc (the conversion destination)
Private doc As New PDFDoc()
' Set the path of the image file
Private filename = "sample-image.png"
' perform the conversion with no optional parameters
Convert.ToPdf(doc, filename)
doc.Save("sample-image.pdf", SDFDoc.SaveOptions.e_linearized)
PDFTron SDK for .NET next-generation software applications is provided as a free trial product that can be tested with a demo license key. There are no details about the license and pricing of the product, and the licensing procedure here is definitely not straightforward, as you have to contact sales to get a custom quote as per your needs. You can visit this link to get more information.
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.
PDFTron is the most comprehensive MS Office and PDF SDK. It provides a separate add-on module for HTML2PDF which needs to be downloaded and placed in the path of PDFnet SDK. Similarly, other conversion options such as OCR and PDF to Word require additional module downloads. It is openly commercial and ready to be used for deployment, but licensing is not so straightforward, as you must first contact sales to get a quote.
Here, IronPDF has an advantage over PDFTron as it does not require additional downloads after the initial installation. This saves time and ensures that achieving the desired goal remains straightforward. IronPDF provides all the necessary functionalities with just one download. However, PDFTron does come with MS office capabilities and can better handle MS office documents. Other functionalities can be added by downloading specific modules. More importantly, IronPDF licensing is straightforward with details fully published on the website, thereby giving it further advantage over competitors. Currently, the special offer means that you can buy five IronPDF products for the price of just two.
9 .NET API products for your office documents