PRODUCT COMPARISONS

A Comparison between IronPDF and PDFTron

Published April 13, 2022
Share:

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
  • PDFTron

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 Library

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)

  • Create PDF documents from HTML 4 and 5, CSS, and JavaScript
  • Generate PDF documents from URL
  • Load URLs with custom-network login credentials, user-agents, proxies, cookies, HTTP headers, and form variables allowing login behind HTML login forms

Edit Existing PDF Documents Without Adobe Acrobat

  • Read and fill PDF forms-field data
  • Extract images and texts from PDFs
  • Stamp new HTML content onto any existing page
  • Add logical or HTML headers and footers
  • Annotations, digitally sign

Manipulate Existing PDF Documents

  • Load and parse existing documents
  • Merge and split content in documents
  • Add headers, footers, annotations, bookmarks, watermarks, text, and assets

Convert from Multiple Formats

  • ASPX WebForms — convert, with 3 lines of code, ASP.NET webforms to downloadable PDFs viewable in the browser
  • HTML Document — convert HTML to PDF
  • Custom ‘base URL’ to allow accessible asset files across the web
  • Responsive layouts through Virtual Viewport (width and height)
  • Accept HTML encoded in any major file encoding (Default to UTF-8)

Save and Print

  • Save and load from file, binary data, or MemoryStreams
  • Screen or Print CSS media types
  • Turn PDF files into a PrintDocument object and print without Adobe (with minimal code)
  • Export official log files with details about API success and debug errors in source code

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.

PDFTron Systems Library

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:

  • Viewing and editing PDF documents
  • Annotation and collaboration
  • Signing PDFs
  • Page manipulation, form fill, edit, and create
  • True redaction
  • Template generation
  • Measurement tools
  • PDF/A Library

Convert from Multiple Formats

  • Office to PDF — DOCX to PDF, XLSX to PDF, PPTX to PDF.
  • PDF to Office — Convert PDF to DOCX.
  • Legacy Office Support — DOC to PDF, XLS to PDF, PPT to PDF.
  • HTML to PDF — HTML to PDF.
  • PDF to HTML — PDF to HTML.
  • 3D to GLB/GLTF — Convert several 3D formats to web-optimized GLB/GLTF.
  • Image to PDF — TIFF to PDF, PNG to PDF, JPEG to PDF.
  • PDF to Image — PDF to TIFF, PNG, JPEG, SVG.
  • Advanced Imaging — Direct conversion from DICOM and other formats such as AAI, ARW, DCR, HEIC, and RAF to PDF.
  • CAD to PDF — DWG to PDF, DGN to PDF, DXF to PDF, DWF to PDF, RVT to PDF.

The rest of this article will look at the following topics:

  1. Creating a Project
  2. IronPDF C# Library Installation
  3. PDFTron SDK Installation
  4. Create a PDF from an Existing URL
  5. Create a PDF from HTML Input String
  6. Convert ASPX Pages to PDF
  7. Convert Images to PDF
  8. Licensing
  9. Summary and Conclusion

1. Creating an ASP.NET Project

Use the following steps to create an ASP.NET website:

  • Open Visual Studio 2019
  • Click on File from the menu and then click on "New Project" to create a new project
  • Select Web under Visual C# in the project type list box
  • Select ASP.NET Web Application (.Net) and click OK as shown in the below screenshot

Figure 1New Project Dialog Box

  • From the next screen, choose "Web Forms" as shown in the screenshot below.

Figure 2Web Forms

  • Once selected, click OK.

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.

2. IronPDF C# Library Installation

There are four ways to download and install the IronPDF library. These are as follows:

  1. Using Visual Studio
  2. The Developer Command Prompt
  3. Download the NuGet Package directly
  4. Download the IronPDF .DLL Library

Let’s take a closer look at each one.

2.1. Using Visual Studio

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 3Solution Explorer

Figure 4Project Menu > Manage NuGet Packages

Once selected, browse for the IronPDF package and install it, as shown in the screenshot below.

Figure 5Install IronPDF from NuGet Package

2.2. Using the Developer Command Prompt

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.

  • Open the Developer Command Prompt — usually found under the Visual Studio folder

Type the following command:

Install-Package IronPdf
  • Press Enter
  • This will download and install the package
  • Reload your Visual Studio project and begin using it

2.3. Download the NuGet Package Directly

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:

2.4. Install IronPDF by Downloading the Library

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:

  • Right-click the Solution in the Solution Explorer
  • Select "References"
  • Browse for the IronPDF.dll library
  • Click OK

All done! IronPDF is downloaded, installed, and ready to use. However, before that, we should install PDFTron.

3. PDFTron Library Installation

The following steps help you to set up PDFtron SDK for users' work.

3.1. Prerequisites

  • Visual Studio
  • Make sure that the .NET Desktop Development and .NET Framework 4.5.1+ development tools workload is part of your installation.
  • PDFTron's C# .NET PDF Library for Windows: .NET PDF SDK Download

3.2. Initial Setup

  1. Extract the folder from the .zip file.

This article uses PDFNET_BASE as the path into the folder that you extracted.

PDFNET_BASE = path/to/extraction/folder/PDFNetDotNet4/
  1. Get your PDFTron trial key and initialize.
// 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")
VB   C#

Note: PDFTron collects some data regarding your usage of the SDK for product improvement.

3.3. Integrate into your Application Manually

  1. Create a new .NET Framework console application project in Visual Studio for your preferred language. You can find them under the Visual C# category.
  2. Navigate into your project's folder. By default, the path should be similar to: C:/Users/User_Name/source/repos/myApp
  3. Copy the Lib folder from PDFNET_BASE to your project folder (the folder which contains your .csproj file).
  4. Find the Solution Explorer to the right. Right-click on References and select the Add Reference option. This opens a Reference Manager dialog.
  5. Click on Browse... at the bottom of the dialog. Navigate to the copied Lib folder and add PDFNetLoader.dll to the references.
  6. Also, add the appropriate version of PDFNet.dll from the x86 folder as another reference (path/to/your/project/folder/Lib/PDFNet/x86/PDFNet.dll). This version will allow the application to run on both 32-bit and 64-bit OS.
  7. Select PDFNet.dll and set its Copy Local property to False.

Figure 6PDFTron - copy_local_false

  1. Open App.config in the solution explorer and make sure the loadFromRemoteSources property is set to true:
<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>
VB   C#
  1. Right-click on your project and select Properties. In the left pane, select the Build Events tab. Under Post-Build Events, add the following code snippet:
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
VB   C#

3.4. NuGet using Visual Studio

This section will go through the NuGet integration steps.

  1. Perform the first two steps of integrating manually.
  2. Right-click on project Dependencies and click on Manage NuGet Packages... This will open the NuGet Package Manager.
  3. Click on the Browse tab near the top of the package manager. In the search bar enter: PDFTron.NET.x64
  4. Select the PDFTron.NET.x64 package by PDFTron Systems Inc. and click on the Install button in the panel with the package information. If you're prompted or an external dialog is opened for confirmation, click on Ok.

Figure 7PDFTron - Installation using NuGet Package

4. Create a PDF from an Existing URL

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.

4.1. Existing URL to PDF using IronPDF

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")
VB   C#

4.2. Existing URL to PDF using PDFTron Technology

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)
VB   C#

5. Create a PDF from HTML Input String

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.

5.1. HTML Input String using IronPDF

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")
VB   C#

5.2. HTML Input String using PDFTron

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)
VB   C#

6. Convert ASPX Web Pages to PDF

IronPDF can easily convert ASPX web pages to PDF with one line of code, while PDFTron technology lacks this feature of direct conversion.

6.1. ASPX Page to PDF using IronPDF

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
VB   C#

7. Convert Images to PDF

7.1. Images to PDF using IronPDF

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
VB   C#

7.2. Images to PDF using PDFTron Technologies

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)
VB   C#

8. Licensing

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.

9. Summary and Conclusion

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.

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.

Conclusion

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.

< PREVIOUS
A Comparison between IronPDF and GemBox.Pdf
NEXT >
A Comparison between IronPDF and HiQPdf C#

Ready to get started? Version: 2024.10 just released

Free NuGet Download Total downloads: 11,308,499 View Licenses >