How to Retrieve Printer Names in C#
Knowing which printers are available on a system is a common prerequisite for any .NET application that sends documents to print. Whether the goal is to let users pick a printer from a dropdown or to route print jobs to a specific device automatically, retrieving printer names programmatically is the first step.
IronPrint exposes a single static method - Printer.GetPrinterNames() - that returns every installed printer on the current Windows machine as a List<string>. We cover installation, synchronous and asynchronous retrieval, and how to feed a selected printer name into a print job below.
- Install IronPrint via NuGet:
Install-Package IronPrint - Add
using IronPrint;to the file - Call
Printer.GetPrinterNames()to get aList<string>of printer names - Iterate over the list and display or store each name
- Pass a selected name to
PrintSettings.PrinterNamewhen printing
-
1Install IronPrint with NuGet Package Manager
-
2Copy and run this code snippet.
using IronPrint; // Retrieve every printer installed on this machine List<string> printers = Printer.GetPrinterNames(); foreach (var name in printers) { Console.WriteLine(name); }C# -
3Deploy 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.GetPrinterNames() - Iterate over the returned
List<string> - Assign a name to
PrintSettings.PrinterNameto target that printer - Pass the configured settings to
Printer.Print()to print
How Can I List All Installed Printer Names?
Printer.GetPrinterNames() queries the operating system and returns every registered printer as a List<string>. We call this method once and iterate over the result:
using IronPrint;
using System;
using System.Collections.Generic;
// List every installed printer
List<string> printerNames = Printer.GetPrinterNames();
Console.WriteLine($"Found {printerNames.Count} printer(s):\n");
// Print each printer name
foreach (string name in printerNames)
{
Console.WriteLine($" • {name}");
}Imports IronPrint
Imports System
Imports System.Collections.Generic
' List every installed printer
Dim printerNames As List(Of String) = Printer.GetPrinterNames()
Console.WriteLine($"Found {printerNames.Count} printer(s):" & vbCrLf)
' Print each printer name
For Each name As String In printerNames
Console.WriteLine($" • {name}")
NextConsole Output
Found 3 printer(s):
• Microsoft Print to PDF
• HP LaserJet Pro MFP M428
• OneNote (Desktop)
The returned list includes local printers, network printers, and virtual print drivers. Each string matches the exact name shown in the Windows Settings > Printers & scanners panel, so it can be used directly in print settings configuration.
If no printers are installed, the method returns an empty list rather than throwing an exception. A quick printerNames.Count check is all that's needed before presenting options to a user.
How Do I Retrieve Printer Names Asynchronously?
For applications where blocking the UI thread is not acceptable - WPF, MAUI, or ASP.NET web apps - IronPrint provides Printer.GetPrinterNamesAsync(). The method returns a Task<List<string>> and works identically to its synchronous counterpart:
using IronPrint;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
// Retrieve printer names asynchronously
List<string> printerNames = await Printer.GetPrinterNamesAsync();
// Print each printer name
foreach (string name in printerNames)
{
Console.WriteLine(name);
}Imports IronPrint
Imports System
Imports System.Collections.Generic
Imports System.Threading.Tasks
' Retrieve printer names asynchronously
Dim printerNames As List(Of String) = Await Printer.GetPrinterNamesAsync()
' Print each printer name
For Each name As String In printerNames
Console.WriteLine(name)
NextWe await the call just like any other async API. The result is the same List<string> returned by GetPrinterNames(), so no additional parsing or conversion is necessary. This async pattern integrates naturally with async Task controller actions and async void event handlers.
How Do I Print to a Specific Printer by Name?
Once we have the printer name, we assign it to PrintSettings.PrinterName and pass the settings object to Printer.Print(). This sends the document directly to the chosen printer without displaying a dialog:
using IronPrint;
using System.Collections.Generic;
// Retrieve available printers
List<string> printers = Printer.GetPrinterNames();
// Select a printer matching "LaserJet", or fall back to the first available
string targetPrinter = printers.Find(p => p.Contains("LaserJet"))
?? printers[0];
// Configure print settings
PrintSettings settings = new PrintSettings
{
PrinterName = targetPrinter,
PaperSize = PaperSize.A4,
NumberOfCopies = 1
};
// Print the document
Printer.Print("invoice.pdf", settings);Imports IronPrint
Imports System.Collections.Generic
' Retrieve available printers
Dim printers As List(Of String) = Printer.GetPrinterNames()
' Select a printer matching "LaserJet", or fall back to the first available
Dim targetPrinter As String = printers.Find(Function(p) p.Contains("LaserJet")) _
OrElse printers(0)
' Configure print settings
Dim settings As New PrintSettings With {
.PrinterName = targetPrinter,
.PaperSize = PaperSize.A4,
.NumberOfCopies = 1
}
' Print the document
Printer.Print("invoice.pdf", settings)PrintSettings supports additional properties such as Dpi, PaperOrientation, Grayscale, and PaperMargins. See the full list in the PrintSettings API reference and the print settings how-to guide.
We also retrieve available paper trays for a given printer using Printer.GetPrinterTrays(printerName), which is useful when a print job needs to pull paper from a specific tray.
What Are My Next Steps?
We covered four operations: installing IronPrint, listing all printer names with GetPrinterNames(), running the same query asynchronously with GetPrinterNamesAsync(), and routing a document to a specific printer through PrintSettings.PrinterName.
For further reading and deeper examples, explore these resources:
- IronPrint Tutorials - Print Document for end-to-end printing walkthroughs.
- PrintSettings How-To for configuring DPI, margins, orientation, and more.
- Printer Class API Reference for the complete list of static methods.
Get a free trial license to test every feature in a live environment, or view licensing options when you're ready to deploy.
Frequently Asked Questions
How can I retrieve printer names in C#?
You can use the IronPrint library and its method `Printer.GetPrinterNames()` to retrieve a list of installed printer names on a Windows machine.
Is there an asynchronous method to get printer names using IronPrint?
Yes, IronPrint provides `Printer.GetPrinterNamesAsync()`, which allows retrieval of printer names without blocking the UI thread.
How do I install the IronPrint library for C#?
To install IronPrint, you can use NuGet with the command `Install-Package IronPrint` in your .NET project.
Can I print to a specific printer using IronPrint?
Yes, after retrieving printer names, you can assign the desired printer name to `PrintSettings.PrinterName` and use `Printer.Print()` to send a document to that printer.
What should I do if no printers are installed?
If no printers are installed, the `Printer.GetPrinterNames()` method returns an empty list. You should check the list's count before using printer names.
What additional properties can I configure with PrintSettings?
With `PrintSettings`, you can configure properties like `Dpi`, `PaperSize`, `PaperOrientation`, `Grayscale`, and `PaperMargins`.
How do I iterate over printer names in C# using IronPrint?
You can use a foreach loop to iterate over the list returned by `Printer.GetPrinterNames()`, allowing you to display or store each printer name.
Can IronPrint work with network and virtual printers?
Yes, the list returned by `Printer.GetPrinterNames()` includes local printers, network printers, and virtual print drivers.
Where can I find more information on printing settings in IronPrint?
You can refer to the [PrintSettings How-To Guide](https://ironsoftware.com/csharp/print/how-to/print-settings/) and the [API Reference](https://ironsoftware.com/csharp/print/object-reference/api/IronPrint.PrintSettings.html) for detailed information.
Does IronPrint provide support for different paper trays?
Yes, you can use `Printer.GetPrinterTrays(printerName)` to retrieve available paper trays for a given printer.

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.