Print Settings

Instantiate the PrintSettings class and configure it according to your requirements. Finally, pass the PrintSettings object to one of the print methods. Explore all the available print settings below:

  • DefaultSettings: Initializes a new instance of the IronPrint.PrintSettings class with default values.
  • PaperSize: Sets the paper size used by the printer.
  • PaperOrientation: Specifies the paper orientation (e.g., Portrait or Landscape).
  • Dpi: Represents the intended print resolution in dots per inch.
    • Remarks: The actual DPI used for printing might be limited by the capabilities of the printer.
  • NumberOfCopies: Indicates the number of identical copies to be generated when printing a document.
    • Remarks: In certain platforms, limitations may exist that prevent the accurate reproduction of multiple copies. In such cases, the specified value of IronPrint.PrintSettings.NumberOfCopies might be ignored, resulting in only one copy being printed.
  • PrinterName: Specifies the name of the printer to use for printing.
    • Remarks: If you choose the printer in a PrintDialog, this setting will be ignored. To obtain the available printer names, you can use IronPrint.Printer.GetPrinterNames or IronPrint.Printer.GetPrinterNamesAsync to fetch the printer name list.
  • PaperMargins: Sets the margins to use for printing in millimeters.
  • Grayscale: Indicates whether to print in grayscale.
  • Flatten: Flatten the PDF before printing, which is useful for displaying form field values and images.
    • Note: The default value is false, indicating that the PDF will be flattened before printing.
  • Tray: Printer tray used for the printing job. This allows users to specify a particular tray from which paper should be fed into the printer.
    • Remarks: If you choose the tray in a PrintDialog, this setting will be ignored. To obtain the available tray, you can use IronPrint.Printer.GetPrinterTrays(System.String) or IronPrint.Printer.GetPrinterTraysAsync(System.String). The default value is null, indicating the use of the default tray provided by the printer. This tray selection property is available only in Windows.
using IronPrint;

class PrintExample
{
    static void Main()
    {
        // Instantiates a new PrintSettings object with default settings
        PrintSettings printSettings = new PrintSettings();

        // Configure the paper size (A4, Letter, etc.)
        printSettings.PaperSize = "A4";

        // Set paper orientation to Portrait
        printSettings.PaperOrientation = PrintOrientation.Portrait;

        // Set the print resolution to 300 DPI
        printSettings.Dpi = 300;

        // Define the number of copies to print
        printSettings.NumberOfCopies = 2;

        // Specify the printer name (make sure the printer is available)
        printSettings.PrinterName = "YourPrinterName";

        // Set the paper margins in millimeters
        printSettings.PaperMargins = new Margins(10, 10, 10, 10);

        // Enable grayscale printing
        printSettings.Grayscale = true;

        // Define whether to flatten the PDF prior to printing
        printSettings.Flatten = false;

        // Select a specific tray for the printer (if necessary)
        printSettings.Tray = "Tray1"; // Ensure tray name matches one available in the printer

        // Example call to the print method using the configured PrintSettings
        IronPrint.Printer.Print("document.pdf", printSettings);
    }
}
using IronPrint;

class PrintExample
{
    static void Main()
    {
        // Instantiates a new PrintSettings object with default settings
        PrintSettings printSettings = new PrintSettings();

        // Configure the paper size (A4, Letter, etc.)
        printSettings.PaperSize = "A4";

        // Set paper orientation to Portrait
        printSettings.PaperOrientation = PrintOrientation.Portrait;

        // Set the print resolution to 300 DPI
        printSettings.Dpi = 300;

        // Define the number of copies to print
        printSettings.NumberOfCopies = 2;

        // Specify the printer name (make sure the printer is available)
        printSettings.PrinterName = "YourPrinterName";

        // Set the paper margins in millimeters
        printSettings.PaperMargins = new Margins(10, 10, 10, 10);

        // Enable grayscale printing
        printSettings.Grayscale = true;

        // Define whether to flatten the PDF prior to printing
        printSettings.Flatten = false;

        // Select a specific tray for the printer (if necessary)
        printSettings.Tray = "Tray1"; // Ensure tray name matches one available in the printer

        // Example call to the print method using the configured PrintSettings
        IronPrint.Printer.Print("document.pdf", printSettings);
    }
}
Imports IronPrint

Friend Class PrintExample
	Shared Sub Main()
		' Instantiates a new PrintSettings object with default settings
		Dim printSettings As New PrintSettings()

		' Configure the paper size (A4, Letter, etc.)
		printSettings.PaperSize = "A4"

		' Set paper orientation to Portrait
		printSettings.PaperOrientation = PrintOrientation.Portrait

		' Set the print resolution to 300 DPI
		printSettings.Dpi = 300

		' Define the number of copies to print
		printSettings.NumberOfCopies = 2

		' Specify the printer name (make sure the printer is available)
		printSettings.PrinterName = "YourPrinterName"

		' Set the paper margins in millimeters
		printSettings.PaperMargins = New Margins(10, 10, 10, 10)

		' Enable grayscale printing
		printSettings.Grayscale = True

		' Define whether to flatten the PDF prior to printing
		printSettings.Flatten = False

		' Select a specific tray for the printer (if necessary)
		printSettings.Tray = "Tray1" ' Ensure tray name matches one available in the printer

		' Example call to the print method using the configured PrintSettings
		IronPrint.Printer.Print("document.pdf", printSettings)
	End Sub
End Class
$vbLabelText   $csharpLabel