How to Print with a Dialog in C#
IronPrint provides Printer.ShowPrintDialog(): one method that opens the native OS print dialog, captures the user's printer and paper selections, and dispatches the document to the print queue. Install one NuGet package and write one line of code.
The print dialog is the standard OS window that lets users choose a printer, set copies, pick a page range, and adjust paper options before committing to print. Desktop applications that need to give users this control before every job are the primary use case.
Quickstart: Print with a Dialog
-
Install IronPrint with NuGet Package Manager
PM > Install-Package IronPrint -
Copy and run this code snippet.
using IronPrint; // Display the print dialog and print the document Printer.ShowPrintDialog("document.pdf"); -
Deploy to test on your live environment
Start using IronPrint in your project today with a free trial
Minimal Workflow (5 steps)
- Install the IronPrint C# printing library
- Call
Printer.ShowPrintDialog("filepath") - User selects printer, copies, and page range
- Click Print to send the document to the chosen printer
- Verify the document prints with the selected settings
How Does the Print Dialog Work in C#?
The Printer.ShowPrintDialog() method opens the operating system's native print dialog. The user sees the full set of print options: printer selection, number of copies, page range, orientation, and paper size. They click Print to send the job, or Cancel to dismiss the dialog without printing.
Under the hood, the native .NET approach requires creating a System.Windows.Forms.PrintDialog instance, wiring it to a PrintDocument, handling the PrintPage event to draw content onto the print graphics surface, checking the DialogResult, and then calling PrintDocument.Print(). That setup typically runs 15–25 lines of code. It also does not include built-in PDF or image rendering (printing a PDF through the native dialog means first parsing the PDF into drawable pages, which requires yet another library).
IronPrint handles the entire pipeline in one call:
Input
The quarterly-report.pdf passed to ShowPrintDialog, a styled corporate Q3 financial summary with KPI metric cards and division revenue tables, representing a typical business document sent to the print dialog.
:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/print-with-dialog-show-print-dialog-open-and-print.cs
using IronPrint;
// Open the print dialog and print
Printer.ShowPrintDialog("quarterly-report.pdf");
Imports IronPrint
' Open the print dialog and print
Printer.ShowPrintDialog("quarterly-report.pdf")
Output
The method accepts a file path as a string or raw file data as a byte[]. IronPrint detects the document format, renders it through the appropriate engine, and presents the dialog. When the user confirms, the document prints with their chosen settings. The print document tutorial walks through the full printing lifecycle in more detail.
How Do I Pre-Configure Dialog Settings?
We can set default values before the dialog opens by creating a PrintSettings object and passing it as the second parameter. The dialog will open with these values pre-selected, and the user can accept them as-is or override any setting.
Input
The invoice.pdf pre-loaded with A4 portrait settings at 300 DPI: a professional billing invoice with line items, discount, tax, and wire transfer instructions, showing a realistic document where the application already knows the required paper size and orientation.
:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/print-with-dialog-preconfigure-dialog-settings.cs
using IronPrint;
// Pre-configure default dialog settings
var settings = new PrintSettings
{
PrinterName = "HP LaserJet Pro",
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300,
NumberOfCopies = 2,
Grayscale = false
};
// Open the dialog with pre-filled settings
Printer.ShowPrintDialog("invoice.pdf", settings);
Imports IronPrint
' Pre-configure default dialog settings
Dim settings As New PrintSettings With {
.PrinterName = "HP LaserJet Pro",
.PaperSize = PaperSize.A4,
.PaperOrientation = PaperOrientation.Portrait,
.Dpi = 300,
.NumberOfCopies = 2,
.Grayscale = False
}
' Open the dialog with pre-filled settings
Printer.ShowPrintDialog("invoice.pdf", settings)
Output
This is useful when the application knows the likely printer or paper format in advance. For example, a point-of-sale system that always prints receipts on a specific thermal printer can default PrinterName to that device. The user still has the option to change it in the dialog.
To discover which printers are available on the system, we call Printer.GetPrinterNames(), which returns a List<string> of all installed printers. Similarly, Printer.GetPrinterTrays() returns available paper trays for a given printer.
The full list of configurable properties includes PrinterName, PaperSize, PaperOrientation, Dpi, NumberOfCopies, Grayscale, PaperMargins, Flatten (for PDF form fields), and Tray. The print settings how-to covers each property with code examples. Any property not set in PrintSettings defaults to the selected printer's standard configuration.
How Do I Show the Dialog Asynchronously?
The Printer.ShowPrintDialogAsync() method returns a Task, making it compatible with async/await. This prevents the dialog from blocking the UI thread, which is essential for WPF, MAUI, and any application where a frozen interface creates a poor user experience.
Input
The report.pdf awaited asynchronously: a multi-section IT infrastructure and security report, representing the kind of long-form document where non-blocking dialog presentation keeps the UI responsive while the file loads.
:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/print-with-dialog-show-print-dialog-async.cs
using IronPrint;
// Open the print dialog asynchronously
await Printer.ShowPrintDialogAsync("report.pdf");
Imports IronPrint
' Open the print dialog asynchronously
Await Printer.ShowPrintDialogAsync("report.pdf")
Output
ShowPrintDialogAsync() accepts the same parameters as the synchronous version: a file path or byte array, plus an optional PrintSettings object. The async pattern follows the same Task-based Asynchronous Pattern used throughout modern .NET development.
IronPrint works across WinForms, WPF, MAUI, and console applications. The dialog appearance adapts to the host platform and OS version, so the user always sees the native print window they expect.
When Should I Use a Dialog vs. Silent Printing?
Use the dialog when users need to choose printer settings before each job; use silent printing for automated workflows where no human decision is needed.
| Criteria | Print with Dialog | Silent Printing |
|---|---|---|
| User interaction | User selects printer, copies, page range | No interaction; prints immediately |
| Best for | Desktop apps, one-off prints, user-facing features | Batch jobs, background services, kiosk apps |
| Printer selection | User chooses from dialog | Set programmatically via PrintSettings |
| IronPrint method | Printer.ShowPrintDialog() |
Printer.Print() |
| Async variant | ShowPrintDialogAsync() |
PrintAsync() |
Report exports, invoice prints, and any job where the wrong printer wastes materials are good candidates for the dialog. Silent printing fits automated workflows where no human decision is needed between documents.
What File Formats Does the Print Dialog Support?
Printer.ShowPrintDialog() supports the same formats as silent printing: PDF, PNG, TIFF, JPEG, GIF, HTML, and BMP. We pass the file path regardless of format, and IronPrint handles rendering and print spooler communication. File data as a byte[] is also accepted, which is useful when the document is generated in memory or retrieved from a database.
Input
monthly-report.pdf read into a byte[], representing a document retrieved from a database or generated in memory before being sent to the dialog.
:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/print-with-dialog-print-dialog-image-and-byte-array.cs
using IronPrint;
// Print an image with the dialog
Printer.ShowPrintDialog("product-photo.png");
// Print from a byte array
byte[] reportData = File.ReadAllBytes("monthly-report.pdf");
Printer.ShowPrintDialog(reportData);
Imports IronPrint
' Print an image with the dialog
Printer.ShowPrintDialog("product-photo.png")
' Print from a byte array
Dim reportData As Byte() = File.ReadAllBytes("monthly-report.pdf")
Printer.ShowPrintDialog(reportData)
Output
The dialog opens as seen in the examples above. Format detection is automatic: whether we pass a file path or a byte[], IronPrint renders the document and presents the same native dialog.
The code examples page shows additional format-specific scenarios. For PDF-specific workflows (generating a PDF and printing it immediately), IronPDF pairs naturally with IronPrint.
Next Steps
Printing with a dialog comes down to two methods: Printer.ShowPrintDialog() for synchronous calls and Printer.ShowPrintDialogAsync() for non-blocking execution. Pre-configure defaults with PrintSettings and let the user adjust from there. Both methods support all of IronPrint's document formats and work across WinForms, WPF, MAUI, and console projects.
Explore the IronPrint tutorials for full walkthroughs, the Printer class API reference for every available method, or the print settings how-to for advanced configuration. The changelog tracks recent improvements and new features.
Start a free 30-day trial to test dialog printing in a live project, no credit card required. When ready to ship, view licensing options starting at $999.
Frequently Asked Questions
What is the primary function of IronPrint?
IronPrint allows developers to show and configure a print dialog in C# applications, making it easy to print PDFs and images with pre-configured settings.
How can I display a print dialog using IronPrint?
You can display a print dialog in your C# application by using IronPrint's ShowPrintDialog() method, which provides an interactive way to configure print settings.
Does IronPrint support asynchronous printing?
Yes, IronPrint supports asynchronous printing, which allows your application to remain responsive while handling print jobs.
Can I pre-configure print settings with IronPrint?
Yes, IronPrint enables you to pre-configure print settings such as paper size, orientation, and printer selection before showing the print dialog.
Is it possible to print images using IronPrint?
IronPrint supports printing both PDFs and images, providing flexibility for various document types in your C# application.
How does IronPrint enhance the print dialog experience in C#?
IronPrint enhances the print dialog experience by allowing developers to customize and configure print settings easily, supporting both synchronous and asynchronous operations.
What types of documents can I print with IronPrint?
With IronPrint, you can print a variety of documents, including PDFs and images, directly from your C# application.
Can IronPrint be integrated into existing C# applications?
Yes, IronPrint is designed to be easily integrated into existing C# applications, providing a simple way to add print dialog functionality.
What advantages does IronPrint offer for C# developers?
IronPrint offers advantages such as easy integration, customizable print settings, support for async printing, and capability to print PDFs and images.
How does IronPrint handle different printer configurations?
IronPrint allows you to configure different printer settings, ensuring compatibility with various printers and customization to meet specific printing needs.




