Get started with IronPrint


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()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Initialize a silent print job
        var printJob = new PrintJob(document);

        // Apply specific settings as necessary
        // For example: set printer name, copies, etc.

        // Execute the print job
        printJob.PrintSilently();
    }
}
// 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()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Initialize a silent print job
        var printJob = new PrintJob(document);

        // Apply specific settings as necessary
        // For example: set printer name, copies, etc.

        // Execute the print job
        printJob.PrintSilently();
    }
}
' Programmatically print a document without showing the print dialog.

' Define your print job and settings here as needed.



Imports System

Imports IronPrint



Public Class SilentPrint

	Public Shared Sub Main()

		' Create a print document instance

		Dim document = New PrintDocument("sample-document.pdf")



		' Initialize a silent print job

		Dim printJob As New PrintJob(document)



		' Apply specific settings as necessary

		' For example: set printer name, copies, etc.



		' Execute the print job

		printJob.PrintSilently()

	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()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Initialize a print job with dialog
        var printJob = new PrintJob(document);

        // Execute the print job with display of print options dialog
        printJob.PrintWithDialog();
    }
}
// Start a print job with user interaction through the print dialog.

using System;
using IronPrint;

public class DialogPrint
{
    public static void Main()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Initialize a print job with dialog
        var printJob = new PrintJob(document);

        // Execute the print job with display of print options dialog
        printJob.PrintWithDialog();
    }
}
' Start a print job with user interaction through the print dialog.



Imports System

Imports IronPrint



Public Class DialogPrint

	Public Shared Sub Main()

		' Create a print document instance

		Dim document = New PrintDocument("sample-document.pdf")



		' Initialize a print job with dialog

		Dim printJob As New PrintJob(document)



		' Execute the print job with display of print options dialog

		printJob.PrintWithDialog()

	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()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Create a print job
        var printJob = new PrintJob(document);

        // Set custom print settings like duplex, color mode, etc.
        var settings = new PrintSettings
        {
            ColorMode = ColorMode.Color,
            DuplexMode = DuplexMode.OneSided,
            Copies = 2
        };

        // Apply settings to print job
        printJob.ApplySettings(settings);

        // Print the document
        printJob.PrintSilently();
    }
}
// Example code to apply custom print settings programmatically.

using System;
using IronPrint;

public class PrintSettingsExample
{
    public static void Main()
    {
        // Create a print document instance
        var document = new PrintDocument("sample-document.pdf");

        // Create a print job
        var printJob = new PrintJob(document);

        // Set custom print settings like duplex, color mode, etc.
        var settings = new PrintSettings
        {
            ColorMode = ColorMode.Color,
            DuplexMode = DuplexMode.OneSided,
            Copies = 2
        };

        // Apply settings to print job
        printJob.ApplySettings(settings);

        // Print the document
        printJob.PrintSilently();
    }
}
' Example code to apply custom print settings programmatically.



Imports System

Imports IronPrint



Public Class PrintSettingsExample

	Public Shared Sub Main()

		' Create a print document instance

		Dim document = New PrintDocument("sample-document.pdf")



		' Create a print job

		Dim printJob As New PrintJob(document)



		' Set custom print settings like duplex, color mode, etc.

		Dim settings = New PrintSettings With {

			.ColorMode = ColorMode.Color,

			.DuplexMode = DuplexMode.OneSided,

			.Copies = 2

		}



		' Apply settings to print job

		printJob.ApplySettings(settings)



		' Print the document

		printJob.PrintSilently()

	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 = PrinterSettings.GetAvailablePrinters();

        // 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 = PrinterSettings.GetAvailablePrinters();

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



Imports System

Imports IronPrint



Public Class PrinterInfo

	Public Shared Sub Main()

		' Get an enumerable list of printer names

		Dim printerNames = PrinterSettings.GetAvailablePrinters()



		' Print each printer name to the console

		Console.WriteLine("Available Printers:")

		For Each name In printerNames

			Console.WriteLine(name)

		Next name

	End Sub

End Class
$vbLabelText   $csharpLabel

Frequently Asked Questions

What is IronPrint?

IronPrint is a powerful printing library designed for .NET C# developers to integrate printing capabilities into their applications across various platforms like Windows, macOS, iOS, and Android.

How can I print documents silently using IronPrint?

You can print documents silently by using the PrintSilently() method of a PrintJob instance, which executes the print job without displaying the print dialog.

Can I customize print settings programmatically with IronPrint?

Yes, IronPrint allows you to adjust print settings programmatically. You can customize settings such as color mode, duplex mode, and the number of copies through code before executing the print job.

What platforms does IronPrint support?

IronPrint supports multiple platforms, including Windows, macOS, iOS, and Android, ensuring consistent and reliable printing capabilities across these operating systems.

How do I initiate a print job with a dialog using IronPrint?

To start a print job with a dialog, use the PrintWithDialog() method on a PrintJob instance, which allows users to interact with the print settings dialog before printing.

Is it possible to retrieve printer information using IronPrint?

Yes, you can retrieve a list of available printers on the system using the PrinterSettings.GetAvailablePrinters() method, which helps in dynamic printer selection.

Can IronPrint handle different document formats?

IronPrint can handle various document formats, including PDF, PNG, HTML, TIFF, GIF, JPEG, IMAGE, and BITMAP, allowing versatile document printing.

Chaknith Bin
Software Engineer
Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience.