How to Configure Print Settings
A print setting refers to a configuration or set of parameters that dictate how a document or content should be printed. These settings include details such as paper size, orientation (e.g., portrait or landscape), print resolution (dots per inch - DPI), the number of copies, printer selection, margins, and options like grayscale printing. Users can customize these settings to achieve specific printing preferences and requirements.
Get started with IronPrint
Start using IronPrint in your project today with a free trial.
How to Configure Print Settings
- Download a C# library for configuring print settings
- Instantiate the PrintSettings class
- Configure the PrintSettings object according to your preferences
- Pass it to the
Print
orShowPrintDialog
method - Check the printed PDF document and see that the print settings have been applied
Set Print Settings
To configure print settings, instantiate the PrintSettings class and configure it according to your preferences. In the Print
or ShowPrintDialog
methods, pass the PrintSettings object as the second parameter. The code example below illustrates this usage.
// Import the necessary namespace for IronPrint
using IronPrint;
// Initialize a new instance of the PrintSettings class
PrintSettings settings = new PrintSettings();
// Configure various print settings
settings.PaperSize = PaperSize.A4; // Set paper size to A4
settings.PaperOrientation = PaperOrientation.Landscape; // Set paper orientation to Landscape
settings.Dpi = 300; // Set print resolution to 300 DPI
settings.NumberOfCopies = 2; // Set the number of copies to 2
settings.PrinterName = "MyPrinter"; // Set the name of the printer
settings.PaperMargins = new Margins(10, 10, 10, 10); // Set margins to 10mm on each side
settings.Grayscale = true; // Print in grayscale
// Use the PrintSettings in the Print method
IronPrint.Printer.Print(document, settings);
// Import the necessary namespace for IronPrint
using IronPrint;
// Initialize a new instance of the PrintSettings class
PrintSettings settings = new PrintSettings();
// Configure various print settings
settings.PaperSize = PaperSize.A4; // Set paper size to A4
settings.PaperOrientation = PaperOrientation.Landscape; // Set paper orientation to Landscape
settings.Dpi = 300; // Set print resolution to 300 DPI
settings.NumberOfCopies = 2; // Set the number of copies to 2
settings.PrinterName = "MyPrinter"; // Set the name of the printer
settings.PaperMargins = new Margins(10, 10, 10, 10); // Set margins to 10mm on each side
settings.Grayscale = true; // Print in grayscale
// Use the PrintSettings in the Print method
IronPrint.Printer.Print(document, settings);
' Import the necessary namespace for IronPrint
Imports IronPrint
' Initialize a new instance of the PrintSettings class
Private settings As New PrintSettings()
' Configure various print settings
settings.PaperSize = PaperSize.A4 ' Set paper size to A4
settings.PaperOrientation = PaperOrientation.Landscape ' Set paper orientation to Landscape
settings.Dpi = 300 ' Set print resolution to 300 DPI
settings.NumberOfCopies = 2 ' Set the number of copies to 2
settings.PrinterName = "MyPrinter" ' Set the name of the printer
settings.PaperMargins = New Margins(10, 10, 10, 10) ' Set margins to 10mm on each side
settings.Grayscale = True ' Print in grayscale
' Use the PrintSettings in the Print method
IronPrint.Printer.Print(document, settings)
Available Print Settings
Explore all available print settings options below:
- DefaultSettings: Initializes a new instance of the IronPrint.PrintSettings class with default values.
- PaperSize: Sets the paper size used by the printer. The default value is IronPrint.PaperSize.PrinterDefault.
- PaperOrientation: Specifies the paper orientation (e.g., Portrait or Landscape). The default value is IronPrint.PaperOrientation.Portrait.
- Dpi: Represents the intended print resolution in dots per inch. The default value is 300, a common setting used in commercial printing. 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. The default value is 1 copy. 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. The default value is null, meaning the current default printer of the operating system will be used. 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. The default value is null, indicating the use of the default margins provided by the printer.
- Grayscale: Indicates whether to print in grayscale. Remarks: The default value is false, indicating an attempt to print in color.
- Flatten: Flatten the PDF before printing, which is useful for displaying form field values and images. 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. 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.
Frequently Asked Questions
What is a print setting in IronPrint?
A print setting in IronPrint refers to a configuration or set of parameters that dictate how a document or content should be printed, such as paper size, orientation, DPI, number of copies, printer selection, and more.
How do I start configuring print settings using IronPrint?
To start configuring print settings with IronPrint, you first need to download a C# library for configuring print settings, instantiate the PrintSettings class, configure the PrintSettings object, and then pass it to the Print or ShowPrintDialog method.
How can I set the paper size and orientation using IronPrint?
Using IronPrint, you can set the paper size by assigning a value to the PaperSize property, and set the orientation by assigning a value to the PaperOrientation property of the PrintSettings class.
What is the default print resolution (DPI) in IronPrint?
The default print resolution in IronPrint is 300 DPI, which is a common setting used in commercial printing. However, the actual DPI used might be limited by the capabilities of the printer.
Can I print multiple copies of a document using IronPrint?
Yes, you can specify the number of identical copies to be printed by setting the NumberOfCopies property in the PrintSettings class. The default value is 1 copy.
How do I select a specific printer in IronPrint?
To select a specific printer, set the PrinterName property in the PrintSettings class. If this is not set, the current default printer of the operating system will be used.
What happens if I choose a tray in the PrintDialog?
If you choose a tray in the PrintDialog, the Tray property setting in the PrintSettings class will be ignored, and the tray selected in the dialog will be used.
Is it possible to print in grayscale using IronPrint?
Yes, you can print in grayscale by setting the Grayscale property to true in the PrintSettings class. By default, this property is set to false, which means an attempt will be made to print in color.
What is the purpose of the Flatten property in IronPrint?
The Flatten property in IronPrint is used to flatten the PDF before printing. This is useful for displaying form field values and images. By default, the Flatten property is set to false.
How can I configure the margins for printing in IronPrint?
You can configure the margins for printing by setting the PaperMargins property in the PrintSettings class to your desired millimeter values. If not set, the default margins provided by the printer will be used.