How to Print A PDF Document in C#

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 IronPrint

Just 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.

  1. Install IronPrint with NuGet Package Manager

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

    IronPrint.Printer.Print("path/to/your/document.pdf");
  3. Deploy to test on your live environment

    Start using IronPrint in your project today with a free trial

    arrow pointer

Table of Contents

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);
    }
}
// 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);
    }
}
Imports System
Imports IronPrint

Public Class SilentPrint
    Public Shared Sub Main()
        ' Apply specific settings as necessary
        ' For example: set printer name, copies, etc.
        Dim settings As New PrintSettings()

        ' Print the document without displaying the print dialog
        Printer.Print("sample-document.pdf", settings)
    End Sub
End Class
$vbLabelText   $csharpLabel

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);
    }
}
// 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);
    }
}
Imports System
Imports IronPrint

Public Class DialogPrint
    Public Shared Sub Main()
        Dim settings As New PrintSettings()

        ' Show the print dialog so the user can customize print options
        Printer.ShowPrintDialog("sample-document.pdf", settings)
    End Sub
End Class
$vbLabelText   $csharpLabel

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);
    }
}
// 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);
    }
}
Imports System
Imports IronPrint

Public Class PrintSettingsExample
    Public Shared Sub Main()
        ' Set custom print settings such as grayscale and number of copies
        Dim settings As New PrintSettings With {
            .Grayscale = False,
            .NumberOfCopies = 2
        }

        ' Print the document using the configured settings
        Printer.Print("sample-document.pdf", settings)
    End Sub
End Class
$vbLabelText   $csharpLabel

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);
        }
    }
}
// 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);
        }
    }
}
Imports System
Imports IronPrint

Public Class PrinterInfo
    Public Shared Sub Main()
        ' Get an enumerable list of printer names
        Dim printerNames = Printer.GetPrinterNames()

        ' Print each printer name to the console
        Console.WriteLine("Available Printers:")
        For Each name In printerNames
            Console.WriteLine(name)
        Next
    End Sub
End Class
$vbLabelText   $csharpLabel

Frequently Asked Questions

How can I print documents silently in .NET C#?

You can use the Printer.Print() static method to execute print jobs without user interaction. This allows the document to be printed programmatically without displaying the print dialog.

What is the process to print a document with a print dialog in .NET C#?

You can initiate a print job with user interaction by using the Printer.ShowPrintDialog() static method. This displays the print settings dialog, allowing users to customize options before printing.

Is it possible to apply custom print settings programmatically in .NET C#?

Yes, you can programmatically apply custom print settings by creating a PrintSettings object and configuring properties such as grayscale and the number of copies. These settings can then be passed to the static Printer class methods, such as Printer.Print().

How can I retrieve available printer names in a .NET C# application?

You can retrieve available printer names using the Printer.GetPrinterNames() method. This provides an enumerable list of printer names installed on the system for selection or informative purposes.

Can I print different document formats using a .NET C# library?

Yes, the library supports printing various document formats, including PDF, PNG, HTML, TIFF, GIF, JPEG, IMAGE, and BITMAP, allowing for versatile document printing options.

What platforms are supported for printing documents using the .NET C# library?

The library supports multiple platforms, such as Windows, macOS, iOS, and Android, ensuring consistent and reliable printing capabilities across these operating systems.

How does silent printing differ from dialog-based printing in .NET C#?

Silent printing allows documents to be printed programmatically without user interaction, using the Printer.Print() method. Dialog-based printing involves displaying a print dialog for user customization, achieved through the Printer.ShowPrintDialog() method.

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 44,162 | Version: 2026.7 just released
Still Scrolling Icon

Still Scrolling?

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