How to Print with a Dialog in C#

The print dialog is the standard OS window that lets users pick a printer, set the number of copies, choose a page range, and adjust paper options before printing. For desktop applications where users need control over how and where their documents print, showing this dialog is the expected behavior.

IronPrint provides a single method — Printer.ShowPrintDialog() — that displays the native print dialog, applies user selections, and sends the document to the chosen printer. We install one NuGet package and write one line of code.

Quickstart: Print with a Dialog

  1. Install IronPrint via NuGet: Install-Package IronPrint
  2. Add using IronPrint; to the file
  3. Call Printer.ShowPrintDialog("filepath") to open the native print dialog
  4. (Optional) Pass a PrintSettings object to pre-configure dialog defaults
  5. The user selects printer, copies, and options, then clicks Print
  1. Install IronPrint with NuGet Package Manager

    PM > Install-Package IronPrint
  2. Copy and run this code snippet.

    using IronPrint;
    
    // Display the print dialog and print the document
    Printer.ShowPrintDialog("document.pdf");
  3. Deploy to test on your live environment

    Start using IronPrint in your project today with a free trial

    arrow pointer

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 — and clicks 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:

:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/show-print-dialog-open-and-print.cs
using IronPrint;

// Open the dialog, let the user configure settings, and print
Printer.ShowPrintDialog("quarterly-report.pdf");
Imports IronPrint

' Open the dialog, let the user configure settings, and print
Printer.ShowPrintDialog("quarterly-report.pdf")
$vbLabelText   $csharpLabel

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.

:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/preconfigure-dialog-settings.cs
using IronPrint;

// Pre-configure defaults for the dialog
var settings = new PrintSettings
{
    PrinterName = "HP LaserJet Pro",
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 2,
    Grayscale = false
};

// Open dialog with pre-filled settings
Printer.ShowPrintDialog("invoice.pdf", settings);
Imports IronPrint

' Pre-configure defaults for the dialog
Dim settings As New PrintSettings With {
    .PrinterName = "HP LaserJet Pro",
    .PaperSize = PaperSize.A4,
    .PaperOrientation = PaperOrientation.Portrait,
    .Dpi = 300,
    .NumberOfCopies = 2,
    .Grayscale = False
}

' Open dialog with pre-filled settings
Printer.ShowPrintDialog("invoice.pdf", settings)
$vbLabelText   $csharpLabel

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 — essential for WPF, MAUI, and any application where a frozen interface creates a poor user experience.

:path=/static-assets/print/content-code-examples/how-to/print-with-dialog/show-print-dialog-async.cs
using IronPrint;

// Non-blocking dialog — the UI remains responsive
await Printer.ShowPrintDialogAsync("report.pdf");
Imports IronPrint

' Non-blocking dialog — the UI remains responsive
Await Printer.ShowPrintDialogAsync("report.pdf")
$vbLabelText   $csharpLabel

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?

The choice depends on whether the user needs control over the print job.

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()

Use the dialog when users need to verify or change settings before printing — report exports, invoice prints, or any scenario where the wrong printer causes a wasted page. Use silent printing when the application controls the entire job and no human decision is needed. The print document tutorial demonstrates both approaches side by side.

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.

:path=/static-assets/print/content-code-examples/how-to/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)
$vbLabelText   $csharpLabel

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. The IronPrint vs. IronPDF comparison explains when to use each.

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 $749.

Curtis Chau
Technical Writer

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.

...

Read More
Ready to Get Started?
Nuget Downloads 37,845 | Version: 2026.3 just released
Still Scrolling Icon

Still Scrolling?

Want proof fast? PM > Install-Package IronPrint
run a sample watch your document hit the printer.