How to Print PDF Files in C# Without Using Adobe
1. Introduction
Are you looking for a way to print PDF files without using Adobe Acrobat? The increased use of PDFs in the modern world means that it has become important to have a reliable and efficient solution for printing these kinds of files. Many people use Adobe Acrobat for this purpose, but it is not always available, or affordable.
In this article, we will discuss how you can print PDF documents using C# .NET applications without using Adobe Reader. For this purpose, we will use the IronPDF C# PDF library.
2. The IronPDF C# PDF Library
IronPDF is a C# PDF library that enables developers to generate, convert, and manipulate PDF documents with ease. It provides a simple API that allows developers to create and edit PDF files with just a few lines of code. With IronPDF, developers can easily add headers and footers, split and merge PDFs, and perform other common PDF operations. The library supports a wide range of file formats, including HTML, images, and Microsoft Office documents, making it easy to convert these formats to PDF. IronPDF is a powerful and flexible solution for C# developers looking to work with PDFs.
Using IronPDF, printing PDFs without a PDF reader is a piece of cake — just follow the instructions below.
3. Prerequisites
Before we get to the stage of printing documents, some requirements first need to be fulfilled.
- Create a C# .NET project in Visual Studio.
- Install IronPDF using NuGet.
3.1. Create a New Project
First, open Visual Studio.
A start-up window will appear — click on "Create a new project".
New Visual Studio Project
In the next window, select "Console Application" and click the Next button in the bottom right corner.
New Visual Studio Console Application
Another window will now appear — write the name of your project, select its location, and click the Next button.
Project Name
Your new C# Console Application project is now created and ready to use.
New Project Creation Finished
3.2. Install IronPDF using NuGet
Once the project is created, all that is left to do before you can print PDFs without Adobe is to install the IronPDF C# library in your project.
There are many different ways to install IronPDF, but, to keep this article short, we will only be demonstrating one of them — the NuGet Package Manager.
In your newly created project, click on Tools in the menu bar and a dropdown menu will appear.
NuGet Package Manager UI
From this dropdown menu, hover your mouse over "NuGet Package Manager", and a side menu will appear. From this menu, click on "Manage NuGet Packages for solutions...".
Manage NuGet Packages for Solutions...
A new page will open where you can navigate and browse pages.
The NuGet Package Manager Window opened
In the search bar, write IronPDF, and you will see the list of IronPDF packages. Simply click on the most recent package and install it.
Browsing for NuGet Packages
It will only take a couple of minutes to install. and it will then be ready to use for printing PDF files.
4. Print PDF Documents using C#
To print PDF documents using C#, you can use IronPDF, a C# PDF library that supports printing. With IronPDF, you can easily print a PDF document directly from code by using the Print method. Using IronPDF, you can convert HTML files to PDF files and print PDF documents in runtime using a single line of code. You can also print PDF documents directly from URLs.
4.1. Print PDF files from HTML files
With IronPDF, you can easily convert an HTML file to a PDF document and then print it. Here is an example of how you can print a PDF file from an HTML file in C# using IronPDF:
using IronPdf;
// Create a new HTML to PDF renderer
var renderer = new IronPdf.HtmlToPdf();
// Render HTML as a PDF document
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Send the PDF to the default printer to print at 300 DPI without showing a user dialog
pdf.Print(300, true);
using IronPdf;
// Create a new HTML to PDF renderer
var renderer = new IronPdf.HtmlToPdf();
// Render HTML as a PDF document
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Send the PDF to the default printer to print at 300 DPI without showing a user dialog
pdf.Print(300, true);
Imports IronPdf
' Create a new HTML to PDF renderer
Private renderer = New IronPdf.HtmlToPdf()
' Render HTML as a PDF document
Private pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>")
' Send the PDF to the default printer to print at 300 DPI without showing a user dialog
pdf.Print(300, True)
The above sample code is for the silent printing of PDF documents. If you want to save the created PDF files and open them in a PDF viewer, you need to change pdf.Print(300, true)
to pdf.Print(300, false)
. This small change allows you to save the PDF files before printing.
Print Output File Location
Below is the output from printing the PDF document.
IronPDF PDF Printing
IronPDF also offers an easy approach to convert Microsoft Office files to PDFs such as PPT to PDF files or Excel files to PDFs.
4.2. Print PDF Documents from URLs
Using IronPDF, you can print PDF documents directly from URLs without using Adobe Acrobat Reader, just by using a few lines of code. Below is the code for printing PDF documents directly from URLs.
using IronPdf;
// Create a new Chrome PDF renderer
var renderer = new ChromePdfRenderer();
// Render URL as a PDF document
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Send the PDF to the default printer to print at 300 DPI
pdf.Print(300, false);
using IronPdf;
// Create a new Chrome PDF renderer
var renderer = new ChromePdfRenderer();
// Render URL as a PDF document
PdfDocument pdf = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf");
// Send the PDF to the default printer to print at 300 DPI
pdf.Print(300, false);
Imports IronPdf
' Create a new Chrome PDF renderer
Private renderer = New ChromePdfRenderer()
' Render URL as a PDF document
Private pdf As PdfDocument = renderer.RenderUrlAsPdf("https://www.nuget.org/packages/IronPdf")
' Send the PDF to the default printer to print at 300 DPI
pdf.Print(300, False)
Just run the above code and your URL will be converted to a PDF document and printing will begin. You can also save this file to read later.
Save the PDF file
Below is the output of the saved file that was printed.
The output PDF file from the NuGet website
5. Conclusion
This article has demonstrated how you can print PDF documents without using Adobe Acrobat by using IronPDF, a C# PDF library.
IronPDF provides a straightforward API that allows developers to create and edit PDF files with just a few lines of code. The library supports a wide range of file formats, including HTML, images, and Microsoft Office documents, making it easy to convert these formats to PDF. With IronPDF, you can easily print a PDF document directly from code, convert HTML files to PDF, and print PDF documents directly from URLs. The article has demonstrated how to install IronPDF using NuGet and provided code examples of how to print PDF documents from HTML files and URLs. For more advanced and detailed C# printing tutorials, please refer to the library documentation pages, specifically this tutorial and this code example.
IronPDF is free for development purposes but requires a license for commercial use. You can get additional information on licensing from our Licensing page.
Frequently Asked Questions
How can I print a PDF document in C# without Adobe Reader?
You can use the IronPDF C# library to print PDF documents without Adobe Reader. Simply integrate IronPDF into your C# .NET project and utilize its API to handle PDF printing programmatically.
What platforms does IronPrint support?
IronPrint is a .NET printing library by Iron Software that supports multiple platforms, including Windows, macOS, Android, and iOS, allowing for versatile PDF printing across different environments.
Can IronPDF convert and print HTML files as PDFs?
Yes, IronPDF allows you to convert HTML files to PDF documents. After conversion, you can print these PDFs using IronPDF's API, making it an efficient tool for web-based document management.
How do I install IronPDF in a C# .NET project?
To install IronPDF in your C# .NET project, use the NuGet Package Manager in Visual Studio. Search for IronPDF, and install it to get started with PDF tasks.
Is it possible to print PDF documents directly from URLs using IronPDF?
Yes, IronPDF allows you to print PDF documents directly from URLs. You can fetch the PDF using the URL and print it programmatically with just a few lines of code.
What are the prerequisites for using IronPDF in a C# project?
To use IronPDF, ensure you have a C# .NET project set up in Visual Studio and install IronPDF through the NuGet Package Manager. This setup is necessary for leveraging IronPDF's full capabilities.
Can IronPDF convert Microsoft Office files to PDF?
Yes, IronPDF supports the conversion of Microsoft Office files to PDF, enabling you to handle various document formats and print them as needed.
How do I perform silent printing with IronPDF?
To perform silent printing using IronPDF, use the Print
method with the silent parameter set to true. This allows printing without any user interaction or dialog boxes.
Is IronPDF free to use for commercial purposes?
IronPDF is free for development purposes. However, you will need to purchase a license if you intend to use it for commercial applications.
Where can I learn more about using IronPDF?
For comprehensive tutorials and documentation, visit the IronPDF documentation pages. These resources offer detailed examples and guides for using the library effectively.