PRODUCT COMPARISONS

A Comparison of Printing PDF in C# Between Itextsharp and IronPDF

Printing PDF documents using C# is a common requirement in many desktop and web applications. The ability to generate and print PDFs programmatically provides developers with greater flexibility in handling document printing tasks. In C#, developers have access to a wide range of libraries and APIs that enable them to generate and print PDF documents with ease. Whether it's printing invoices, receipts, or reports, the ability to generate PDF documents dynamically and print them directly from the application saves time and effort. This article explores how to print PDFs using C# and some popular libraries and APIs available for this purpose.

For this purpose, we will use the following libraries and compare them.

  1. IronPDF
  2. iTextSharp

In this article, we will see how you can print PDF files using IronPDF and ITextSharp. Both of these are advanced PDF manipulation APIs.

1. IronPDF

IronPDF is a powerful C# library that allows developers to create, manipulate, and process PDF documents with ease. It provides a wide range of features that make it a popular choice among developers, including the ability to convert HTML, CSS, and images to PDF, generate PDFs from scratch, and edit existing PDFs. IronPDF also supports a variety of document elements such as images, text, tables, and forms, and offers advanced functionalities such as digital signatures, watermarks, and encryption. Its user-friendly interface and comprehensive documentation make it a popular choice for .NET developers who want to integrate PDF functionality into their applications.

2. iTextSharp

iText is a popular open-source PDF library used by developers to create, manipulate, and extract data from PDF documents in Java and .NET environments. iTextSharp was a .NET port from the original iText library before it was discontinued after the release of iText 5. iText 7 is the latest version of the library, and it is a complete rewrite of the original iText library, providing more features, better performance, and improved extensibility. iText 7 offers a range of functionalities, including PDF generation and manipulating PDF documents, digital signatures, form filling, and support creating PDFs. It is widely used in various industries, including finance, legal, and government, and it is known for its high-quality output and flexibility.

3. Install IronPDF Library

Here are the steps to install the IronPDF library using the NuGet Package Manager:

  1. Open Visual Studio and create a new project or open an existing one.
  2. Right-click on the project in the Solution Explorer and select "Manage NuGet Packages".

    1

  3. In the "NuGet Package Manager" window, select the "Browse" tab.
  4. In the search bar, type "IronPDF" and hit Enter.
  5. Select "IronPdf" from the search results and click on the "Install" button.

    IronPDF NuGet package Search

  6. Review the dependencies that will be installed and click "OK" to proceed with the installation.
  7. Wait for the installation to complete. You can track the progress in the "Output" window.
  8. Once the installation is complete, the IronPDF Library will have been added to your project, so you can start using IronPDF.

That's it! You have successfully installed IronPDF using NuGet Package Manager. You can also download IronPDF directly from the IronPDF website or download the dll to manually install instead.

4. Install iTextsharp PDF Library

Here are the steps to install iTextsharp with NuGet Package Manager:

  1. Open Visual Studio and create a new or open an existing project.
  2. Right-click on the project in the Solution Explorer and select "Manage NuGet Packages".

    3

  3. In the "NuGet Package Manager" window, select the "Browse" tab.
  4. In the search bar, type "iTextsharp" and hit Enter.
  5. Select "iText 7" from the search results and click on the "Install" button.

    4

  6. Review the dependencies that will be installed and click "OK" to proceed with the installation.
  7. Wait for the installation to complete. You can track the progress in the "Output" window.
  8. Once the installation is complete, you can start using iTextsharp in your project.

That's it! You have successfully installed iTextsharp using the NuGet Package Manager.

5. Print a PDF Document using IronPDF

Printing PDFs is quite easy using IronPDF, and it provides many options to print a PDF file with just a few lines of code. Below, we will discuss a code example of printing the IronPDF tiger wiki page and sending instructions to the default printer using only IronPDF's render PDF object, without any other library.

using IronPdf;

// Initialize ChromePdfRenderer to render a URL as PDF
var renderer = new ChromePdfRenderer();

// Render the PDF from a URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

// Print the PDF at 300 DPI to the default printer
pdf.Print(300, true);

// Get a PrintDocument for additional customization if needed
System.Drawing.Printing.PrintDocument printDocYouCanWorkWith = pdf.GetPrintDocument();
using IronPdf;

// Initialize ChromePdfRenderer to render a URL as PDF
var renderer = new ChromePdfRenderer();

// Render the PDF from a URL
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

// Print the PDF at 300 DPI to the default printer
pdf.Print(300, true);

// Get a PrintDocument for additional customization if needed
System.Drawing.Printing.PrintDocument printDocYouCanWorkWith = pdf.GetPrintDocument();
Imports IronPdf

' Initialize ChromePdfRenderer to render a URL as PDF
Private renderer = New ChromePdfRenderer()

' Render the PDF from a URL
Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")

' Print the PDF at 300 DPI to the default printer
pdf.Print(300, True)

' Get a PrintDocument for additional customization if needed
Dim printDocYouCanWorkWith As System.Drawing.Printing.PrintDocument = pdf.GetPrintDocument()
$vbLabelText   $csharpLabel

The above code demonstrates how to obtain data from a URL that IronPDF uses to create a PDF file. Then, the code sets the printer parameters and sends the PDF file to the default printer to print the PDF document directly.

6. Print a PDF File using iTextSharp

Creating PDF documents using iTextSharp is quite easy, but when it comes to printing PDF files, it requires the help of other 3rd party libraries.

using iText.Kernel.Pdf;
using System.Drawing.Printing;

// Method to print a PDF using iTextSharp and another library (e.g., PrintDocument)
public void PrintPDF(string filePath) {
    // Create a PdfReader to read the PDF file
    PdfReader reader = new PdfReader(filePath);

    // Create a PdfDocument to interact with the PDF data
    PdfDocument pdfDoc = new PdfDocument(reader);

    // Assuming there exists a PrintHelper class that can handle PDF printing
    PrintHelper printHelper = new PrintHelper(pdfDoc);

    // Print the PDF document using the helper
    printHelper.Print();

    // Close the PdfDocument to release resources
    pdfDoc.Close();
}    
using iText.Kernel.Pdf;
using System.Drawing.Printing;

// Method to print a PDF using iTextSharp and another library (e.g., PrintDocument)
public void PrintPDF(string filePath) {
    // Create a PdfReader to read the PDF file
    PdfReader reader = new PdfReader(filePath);

    // Create a PdfDocument to interact with the PDF data
    PdfDocument pdfDoc = new PdfDocument(reader);

    // Assuming there exists a PrintHelper class that can handle PDF printing
    PrintHelper printHelper = new PrintHelper(pdfDoc);

    // Print the PDF document using the helper
    printHelper.Print();

    // Close the PdfDocument to release resources
    pdfDoc.Close();
}    
Imports iText.Kernel.Pdf
Imports System.Drawing.Printing

' Method to print a PDF using iTextSharp and another library (e.g., PrintDocument)
Public Sub PrintPDF(ByVal filePath As String)
	' Create a PdfReader to read the PDF file
	Dim reader As New PdfReader(filePath)

	' Create a PdfDocument to interact with the PDF data
	Dim pdfDoc As New PdfDocument(reader)

	' Assuming there exists a PrintHelper class that can handle PDF printing
	Dim printHelper As New PrintHelper(pdfDoc)

	' Print the PDF document using the helper
	printHelper.Print()

	' Close the PdfDocument to release resources
	pdfDoc.Close()
End Sub
$vbLabelText   $csharpLabel

The above code retrieves a PDF file from a path, creates a new PDF document object, and then uses a helper class to print the document by sending it to the default printer. Note that iTextSharp does not natively support printing, so an additional third-party library or code is required to handle the actual print job process.

7. Conclusion

Printing PDF documents using C# is an essential feature for many desktop and web applications. IronPDF and iTextSharp are two popular libraries used to create, manipulate, and print PDF documents with ease. Both libraries provide a range of functionalities, including converting HTML, CSS, and images to PDF, editing existing PDFs, and adding digital signatures, watermarks, and encryption. IronPDF is known for its user-friendly interface and comprehensive documentation, making it a popular choice for .NET developers. On the other hand, iTextSharp also offers a lot of PDF functionalities. Notably, however, it does not provide PDF printing functionality. To achieve this, we will have to use other third-party tools.

5

To learn more about printing PDFs using IronPDF, please visit the following link.

For a full comparison between IronPDF and iTextSharp, please visit this link.

Frequently Asked Questions

What is IronPrint?

IronPrint is Iron Software's .NET printing library offering compatibility across various platforms including Windows, macOS, Android, and iOS.

How can I print a PDF file using iTextSharp?

To print a PDF using iTextSharp, you need to download the library, load a PDF document using PdfReader, and then use a PrintHelper object to invoke the print method.

What features does IronPDF offer?

IronPDF offers features such as converting HTML, CSS, and images to PDF, generating PDFs from scratch, editing existing PDFs, and supporting document elements like images, text, tables, and forms. It also includes functionalities like digital signatures, watermarks, and encryption.

What is iTextSharp?

iTextSharp is a popular open-source PDF library for .NET environments, originally a port of the Java iText library, used for creating, manipulating, and extracting data from PDF documents.

How do I install the IronPDF library?

To install IronPDF using the NuGet Package Manager, open Visual Studio, right-click on the project, select 'Manage NuGet Packages', search for 'IronPDF', and click 'Install'.

What is the process to install iTextSharp?

To install iTextSharp using the NuGet Package Manager, open Visual Studio, right-click on the project, select 'Manage NuGet Packages', search for 'iTextsharp', and click 'Install'.

Can IronPDF print PDF files directly?

Yes, IronPDF can print PDF files directly using its render PDF object, allowing developers to send instructions to the default printer with just a few lines of code.

Does iTextSharp support native PDF printing?

No, iTextSharp does not natively support PDF printing. It requires additional third-party libraries or code to handle the print job process.

Why is IronPDF a popular choice among .NET developers?

IronPDF is popular due to its user-friendly interface, comprehensive documentation, and the wide range of functionalities it offers, making it easy to integrate PDF functionality into .NET applications.

Where can I find more information about printing PDFs using IronPDF?

For more information about printing PDFs using IronPDF, you can visit the IronPDF website and explore examples on paper printing PDFs.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.
< PREVIOUS
Comparison between IronPrint and IronPDF
NEXT >
PdfiumViewer Print PDF in C# (Alternative Tutorial)

Ready to get started? Version: 2025.6 just released

View Licenses >