How to Specify the Printer Name in C#

IronPrint's PrintSettings class exposes a PrinterName property that directs print jobs to a specific printer. We assign the exact name of the target printer as a string, pass the configured PrintSettings object to any IronPrint print method, and the document goes to that printer instead of the system default.

This guide walks through setting a printer name, discovering available printers at runtime, and combining printer selection with other print settings.

Quickstart: Specify the Printer Name

  1. Install IronPrint with NuGet Package Manager

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

    using IronPrint;
    
    // Print a document to a specific printer
    Printer.Print("report.pdf", new PrintSettings
    {
        PrinterName = "HP LaserJet Pro M404"
    });
  3. Deploy to test on your live environment

    Start using IronPrint in your project today with a free trial

    arrow pointer

How Do I Specify a Printer Name in C#?

We specify the target printer by assigning its name to the PrinterName property on a PrintSettings object. We then pass that object to Printer.Print.

Input

invoice.pdf is a styled A4 B2B invoice with line items and totals, printed to a specific named printer via PrintSettings.PrinterName.

:path=/static-assets/print/content-code-examples/how-to/specify-printer-name/specify-printer-name-set-printer-name.cs
using IronPrint;

// Configure print settings with a target printer
PrintSettings settings = new PrintSettings();
settings.PrinterName = "Microsoft Print to PDF";

// Print to the specified printer
Printer.Print("invoice.pdf", settings);
Imports IronPrint

' Configure print settings with a target printer
Dim settings As New PrintSettings()
settings.PrinterName = "Microsoft Print to PDF"

' Print to the specified printer
Printer.Print("invoice.pdf", settings)
$vbLabelText   $csharpLabel

We first instantiate PrintSettings, which initializes with PrinterName = null, meaning the OS default printer. We then override PrinterName with the exact string name of the target printer. When we call Printer.Print, IronPrint sends the job directly to that printer's queue.

Output

The invoice is sent directly to the named printer. The job appears in the printer queue as seen in the silent printing example.

Invoice output printed to "Microsoft Print to PDF" using PrinterName.

Two details to keep in mind. First, the printer name must match exactly what the operating system reports; this comparison is case-sensitive. A mismatch like "hp laserjet" instead of "HP LaserJet" will fail silently or throw an error. Second, if the user opens a print dialog via ShowPrintDialog, the dialog selection overrides whatever PrinterName was set in code, giving users final control.

If the printer name is not known ahead of time, we can query all installed printers at runtime instead of hardcoding the value.

How Do I Discover Available Printers?

Rather than hardcoding printer names, we can query the system at runtime using Printer.GetPrinterNames. This method returns a List<string> containing every installed printer on the machine.

Input

report.pdf is an A4 business report with a summary section and data table, printed to the first dynamically discovered printer.

:path=/static-assets/print/content-code-examples/how-to/specify-printer-name/specify-printer-name-discover-printers.cs
using IronPrint;

// List every installed printer
List<string> printers = Printer.GetPrinterNames();

// Print each printer name
foreach (string name in printers)
{
    Console.WriteLine(name);
}

// Print to the first available printer
if (printers.Count > 0)
{
    Printer.Print("report.pdf", new PrintSettings
    {
        PrinterName = printers[0]
    });
}
Imports IronPrint

' List every installed printer
Dim printers As List(Of String) = Printer.GetPrinterNames()

' Print each printer name
For Each name As String In printers
    Console.WriteLine(name)
Next

' Print to the first available printer
If printers.Count > 0 Then
    Printer.Print("report.pdf", New PrintSettings With {
        .PrinterName = printers(0)
    })
End If
$vbLabelText   $csharpLabel

We call GetPrinterNames to retrieve every printer the operating system knows about, including local, network, and virtual printers like "Microsoft Print to PDF." We then iterate through the list and select a printer by index, name matching, or any custom logic the application requires.

Output

The report is sent to the first available printer. The job appears in the printer queue as seen above.

Report output printed to the first available printer via GetPrinterNames.

This discover-then-print pattern is essential for applications deployed across different machines. Hardcoding a printer name works for single-machine scenarios, but production applications should query available printers and either let the user choose or select one programmatically based on naming conventions.

Printer selection can also be paired with paper size, DPI, copy count, and margins in a single configuration object.

How Do I Combine Printer Name with Other Settings?

The PrintSettings class exposes PrinterName alongside properties for paper size, orientation, DPI, margins, copy count, and more. We configure everything in a single object.

Input

quarterly-report.pdf is an A4 quarterly financial report with KPI cards and charts, printed with PrinterName combined with paper size, DPI, and copy count in one PrintSettings object.

:path=/static-assets/print/content-code-examples/how-to/specify-printer-name/specify-printer-name-combined-settings.cs
using IronPrint;

// Configure full print settings with a named printer
PrintSettings settings = new PrintSettings
{
    PrinterName = "Office Color Printer",
    PaperSize = PaperSize.A4,
    PaperOrientation = PaperOrientation.Portrait,
    Dpi = 300,
    NumberOfCopies = 2,
    PaperMargins = new Margins(15, 15, 15, 15),
    Grayscale = false
};

// Print the quarterly report
Printer.Print("quarterly-report.pdf", settings);
Imports IronPrint

' Configure full print settings with a named printer
Dim settings As New PrintSettings With {
    .PrinterName = "Office Color Printer",
    .PaperSize = PaperSize.A4,
    .PaperOrientation = PaperOrientation.Portrait,
    .Dpi = 300,
    .NumberOfCopies = 2,
    .PaperMargins = New Margins(15, 15, 15, 15),
    .Grayscale = False
}

' Print the quarterly report
Printer.Print("quarterly-report.pdf", settings)
$vbLabelText   $csharpLabel

We use object initializer syntax for readability. PrinterName routes the job to "Office Color Printer" while the remaining properties control the output format. Dpi at 300 produces sharp text and graphics. PaperMargins accepts millimeter values through the Margins constructor. For the full list of available properties, see the print settings guide.

Output

The quarterly report prints with the named printer, A4 portrait, 300 DPI, 2 copies, and 15 mm margins combined in one job. The job appears in the printer queue as seen above.

Quarterly report output with PrinterName, A4, 300 DPI, 2 copies, and 15 mm margins.

IronPrint validates the configuration as a unit and submits the combined settings to the printer driver in a single job.

Applications that cannot block the main thread during printer discovery or printing can use the async equivalents of both operations.

How Do I Select a Printer and Print Asynchronously?

For WPF and WinForms apps where blocking the main thread is not an option, we use Printer.GetPrinterNamesAsync and Printer.PrintAsync. Both return a Task, keeping the UI responsive.

:path=/static-assets/print/content-code-examples/how-to/specify-printer-name/specify-printer-name-async-printer-select.cs
using IronPrint;
using System.Threading.Tasks;

public class PrintService
{
    public async Task PrintToFirstAvailableAsync(string filePath)
    {
        // Discover available printers asynchronously
        List<string> printers = await Printer.GetPrinterNamesAsync();

        // Exit if no printers are installed
        if (printers.Count == 0)
        {
            Console.WriteLine("No printers found.");
            return;
        }

        // Configure settings for the first available printer
        PrintSettings settings = new PrintSettings
        {
            PrinterName = printers[0],
            Dpi = 300
        };

        // Print asynchronously
        await Printer.PrintAsync(filePath, settings);
    }
}
Imports IronPrint
Imports System.Threading.Tasks

Public Class PrintService
    Public Async Function PrintToFirstAvailableAsync(filePath As String) As Task
        ' Discover available printers asynchronously
        Dim printers As List(Of String) = Await Printer.GetPrinterNamesAsync()

        ' Exit if no printers are installed
        If printers.Count = 0 Then
            Console.WriteLine("No printers found.")
            Return
        End If

        ' Configure settings for the first available printer
        Dim settings As New PrintSettings With {
            .PrinterName = printers(0),
            .Dpi = 300
        }

        ' Print asynchronously
        Await Printer.PrintAsync(filePath, settings)
    End Function
End Class
$vbLabelText   $csharpLabel

This class-based example wraps the discover-and-print logic in a reusable service. We call GetPrinterNamesAsync to retrieve the printer list without freezing the UI, then assign the first available printer to PrinterName. The await Printer.PrintAsync call sends the job asynchronously.

Output

The invoice is printed asynchronously to the first discovered printer. The job appears in the printer queue as seen above.

Invoice output printed asynchronously to the first available printer.

In production, we might replace printers[0] with logic that matches a naming convention, such as searching for printers containing "Label" for shipping labels or "Color" for branded documents. IronPrint's async methods all accept the same PrintSettings object, so PrinterName behavior is identical between synchronous and asynchronous paths.

With static assignment, runtime discovery, combined settings, and async workflows all covered, a handful of related resources are worth bookmarking.

What Are My Next Steps?

We covered specifying a printer name via PrintSettings.PrinterName, from static assignment to dynamic runtime discovery with Printer.GetPrinterNames. The key points: printer names must match exactly (case-sensitive), null defaults to the OS default printer, and print dialogs override programmatic selection.

The get printer names example provides a standalone discovery snippet, while the print settings guide covers every configurable property in detail. The Printer class API reference documents all static printing methods, and the PrintSettings API reference lists every field and default. For an end-to-end walkthrough, the Print Document tutorial ties everything together.

Start a free 30-day trial to test printer selection in a live project. When ready, view licensing options starting at $999.

https://ironsoftware.com/csharp/print/object-reference/api/IronPrint.PrintSettings.html https://ironsoftware.com/csharp/print/object-reference/api/IronPrint.PrintSettings.html https://ironsoftware.com/csharp/print/object-reference/api/IronPrint.Printer.html https://ironsoftware.com/csharp/print/how-to/print-settings/ https://ironsoftware.com/csharp/print/object-reference/api/IronPrint.Printer.html

Frequently Asked Questions

How can I specify a printer name in C# using IronPrint?

With IronPrint, you can specify a printer name in C# by setting the PrinterName property. This allows you to target a specific printer for your printing tasks.

What is IronPrint?

IronPrint is a library from Iron Software that enables developers to manage printing tasks in C# applications, providing functionality to specify printer names and other printing options.

How do I discover available printers in C#?

Using IronPrint, you can easily discover available printers in your network by accessing the list of printers and selecting the desired PrinterName for your printing job.

Can I set the PrinterName property dynamically?

Yes, with IronPrint you can dynamically set the PrinterName property in your C# code to select the desired printer at runtime.

Is it possible to print to a network printer using IronPrint?

Yes, IronPrint allows you to specify and print to network printers by setting the appropriate PrinterName property in your C# application.

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 40,390 | Version: 2026.5 just released
Still Scrolling Icon

Still Scrolling?

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