Print Document Tutorial

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.

Table of Contents

C# NuGet Library for

Install with NuGet

Install-Package IronPrint

Print Document

Print Silently

Print documents seamlessly without displaying the print dialog. The print settings can then be done directly within the code.

:path=/static-assets/print/content-code-examples/tutorials/print-document-print-silently.cs
using IronPrint;

// Print the document
Printer.Print("newDoc.pdf");
Imports IronPrint

' Print the document
Printer.Print("newDoc.pdf")
VB   C#

Print With Dialog

Initiate the printing process with the print setting dialog displayed. This allows users to customize print options interactively.

:path=/static-assets/print/content-code-examples/tutorials/print-document-print-with-dialog.cs
using IronPrint;

// Show print dialog
Printer.ShowPrintDialog("newDoc.pdf");
Imports IronPrint

' Show print dialog
Printer.ShowPrintDialog("newDoc.pdf")
VB   C#

Apply Print Settings

Programmatically adjust print settings to meet specific requirements. This section provides the capability to fine-tune printing configurations through code.

:path=/static-assets/print/content-code-examples/tutorials/print-document-apply-print-setting.cs
using IronPrint;

// Configure print setting
PrintSettings printSettings = new PrintSettings();
printSettings.Dpi = 150;
printSettings.NumberOfCopies = 2;
printSettings.PaperOrientation = PaperOrientation.Portrait;

// Print the document
Printer.Print("newDoc.pdf", printSettings);
Imports IronPrint

' Configure print setting
Private printSettings As New PrintSettings()
printSettings.Dpi = 150
printSettings.NumberOfCopies = 2
printSettings.PaperOrientation = PaperOrientation.Portrait

' Print the document
Printer.Print("newDoc.pdf", printSettings)
VB   C#

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.

:path=/static-assets/print/content-code-examples/tutorials/print-document-get-printer-names.cs
using IronPrint;
using System;
using System.Collections.Generic;

// Retrieve printers' name
List<string> printersName = Printer.GetPrinterNames();

foreach (var printer in printersName)
{
    Console.WriteLine(printer);
}
Imports IronPrint
Imports System
Imports System.Collections.Generic

' Retrieve printers' name
Private printersName As List(Of String) = Printer.GetPrinterNames()

For Each printer In printersName
	Console.WriteLine(printer)
Next printer
VB   C#