C# Print Document Tutorial with IronPrint
IronPrint is a powerful printing library designed to assist .NET C# developers in integrating printing capabilities into their applications. With a broad compatibility spectrum spanning across Windows, macOS, iOS, and Android platforms, IronPrint works consistently and reliably across diverse operating systems. Whether you are creating applications for desktop environments, Apple's macOS ecosystem, or mobile platforms like iOS and Android, IronPrint simplifies the implementation of printing features, providing a versatile and user-friendly solution for all your printing needs in the .NET C# environment.
Quickstart: Silently Print a Document with IronPrintJust one line of code and you're printing - no dialogs, no fuss. Use IronPrint.Printer.Print(...) to silently send PDFs or images straight to the printer using default or custom settings.
-
1Install IronPrint with NuGet Package Manager
-
2Copy and run this code snippet.
IronPrint.Printer.Print("path/to/your/document.pdf");C# -
3Deploy to test on your live environment
Start using IronPrint in your project today with a free trial
Table of Contents
- Print Document
- Apply Print Settings
- Get Printer Information
Print Document
Print Silently
Print documents seamlessly without displaying the print dialog. The print settings can then be done directly within the code.
// Programmatically print a document without showing the print dialog.
// Define your print job and settings here as needed.
using System;
using IronPrint;
public class SilentPrint
{
public static void Main()
{
// Apply specific settings as necessary
// For example: set printer name, copies, etc.
var settings = new PrintSettings();
// Print the document without displaying the print dialog
Printer.Print("sample-document.pdf", settings);
}
}
Print With Dialog
Initiate the printing process with the print setting dialog displayed. This allows users to customize print options interactively.
// Start a print job with user interaction through the print dialog.
using System;
using IronPrint;
public class DialogPrint
{
public static void Main()
{
var settings = new PrintSettings();
// Show the print dialog so the user can customize print options
Printer.ShowPrintDialog("sample-document.pdf", settings);
}
}
Apply Print Settings
Programmatically adjust print settings to meet specific requirements. This section provides the capability to fine-tune printing configurations through code.
// Example code to apply custom print settings programmatically.
using System;
using IronPrint;
public class PrintSettingsExample
{
public static void Main()
{
// Set custom print settings such as grayscale and number of copies
var settings = new PrintSettings
{
Grayscale = false,
NumberOfCopies = 2
};
// Print the document using the configured settings
Printer.Print("sample-document.pdf", settings);
}
}
Get Printer Information
Get Printer Names
Access a list of all available printers. Retrieve the names of printers installed on the system for informative purposes or dynamic printer selection in your application.
// Retrieve and display a list of printer names available on the system.
using System;
using IronPrint;
public class PrinterInfo
{
public static void Main()
{
// Get an enumerable list of printer names
var printerNames = Printer.GetPrinterNames();
// Print each printer name to the console
Console.WriteLine("Available Printers:");
foreach (var name in printerNames)
{
Console.WriteLine(name);
}
}
}
Frequently Asked Questions
What platforms does IronPrint support for printing documents?
IronPrint supports printing across a wide range of platforms including Windows, macOS, iOS, and Android, ensuring seamless integration in diverse operating systems.
How can I print a document without displaying the print dialog using IronPrint?
With IronPrint, you can silently print a document using a single line of code: `IronPrint.Printer.Print("path/to/your/document.pdf");`. This allows you to send PDFs directly to the printer without any dialog interruptions.
Can I customize print settings programmatically using IronPrint?
Yes, you can programmatically customize print settings with IronPrint by defining settings such as printer name, copies, and more within your C# application code.
Is it possible to interactively set print options with IronPrint?
IronPrint allows users to start a print job with interactive options by utilizing the print dialog, which helps customize various print settings according to user preferences.
How do I retrieve the names of available printers using IronPrint?
You can retrieve the list of available printers using IronPrint by implementing the `Printer.GetPrinterNames()` method, which provides an enumerable list of printer names installed on the system.
What are some of the document types IronPrint can handle?
IronPrint can handle multiple document types including PDF, PNG, HTML, TIFF, GIF, JPEG, and more, making it a versatile tool for various printing needs.
Is IronPrint compatible with both desktop and mobile applications?
Yes, IronPrint is compatible with both desktop environments (Windows and macOS) and mobile platforms (iOS and Android), allowing for flexible printing solutions across different devices.
Can IronPrint perform grayscale printing and adjust the number of copies programmatically?
Yes, you can set custom print settings such as enabling grayscale and specifying the number of copies directly within your C# code using IronPrint's `PrintSettings` class.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.