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.
:path=/static-assets/print/content-code-examples/how-to/print-settings-set-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)
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.