How to Configure Print Settings in C# with IronPrint
Configure print settings in C# using IronPrint's PrintSettings class to control paper size, orientation, DPI, margins, and more. Simply instantiate PrintSettings, set your preferences, and pass it to the Print method.
Quickstart: Configure and Print Using IronPrint Settings
Get started by creating a PrintSettings object, setting properties like paper size, orientation, DPI, copies, and grayscale. Then call Printer.Print(...) to apply these settings instantly — no complex setup required.
Get started making PDFs with NuGet now:
Install IronPrint with NuGet Package Manager
Copy and run this code snippet.
IronPrint.Printer.Print("document.pdf", new IronPrint.PrintSettings { PaperSize = IronPrint.PaperSize.A4, PaperOrientation = IronPrint.PaperOrientation.Landscape, Dpi = 300, NumberOfCopies = 2, Grayscale = true });Deploy to test on your live environment
Minimal Workflow (5 steps)
- Download a C# library for configuring print settings
- Instantiate the
PrintSettingsclass - Configure the
PrintSettingsobject according to your preferences - Pass it to the
PrintorShowPrintDialogmethod - Check the printed PDF document and see that the print settings have been applied
How Do I 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. For more detailed examples, check the print settings code examples page.
// 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)Why Do I Need 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 (portrait or landscape), print resolution (dots per inch - DPI), the number of copies, printer selection, margins, and options like grayscale printing. Customize these settings to achieve specific printing preferences and requirements.
IronPrint's comprehensive print settings features provide developers with fine-grained control over every aspect of the printing process. Whether building desktop applications or ASP.NET web applications, proper configuration ensures consistent results across different environments.
When Should I Use Custom Print Settings?
Custom print settings are essential when precise control over printed output is needed, such as when printing reports with specific margins, generating multiple copies of documents, or ensuring documents print in the correct orientation for business needs.
Here's a practical example for printing invoices with specific requirements:
// Example: Printing invoices with business requirements
using IronPrint;
// Invoice printing with specific business settings
var invoiceSettings = new PrintSettings
{
PaperSize = PaperSize.Letter, // US Letter size for business documents
PaperOrientation = PaperOrientation.Portrait,
Dpi = 600, // High quality for professional output
NumberOfCopies = 3, // Original + customer copy + file copy
PaperMargins = new Margins(15, 15, 15, 25), // Extra bottom margin for footer
Grayscale = false, // Keep company logo in color
PrinterName = "Office Color Printer" // Specific high-quality printer
};
// Print the invoice
Printer.Print("invoice_2024_001.pdf", invoiceSettings);// Example: Printing invoices with business requirements
using IronPrint;
// Invoice printing with specific business settings
var invoiceSettings = new PrintSettings
{
PaperSize = PaperSize.Letter, // US Letter size for business documents
PaperOrientation = PaperOrientation.Portrait,
Dpi = 600, // High quality for professional output
NumberOfCopies = 3, // Original + customer copy + file copy
PaperMargins = new Margins(15, 15, 15, 25), // Extra bottom margin for footer
Grayscale = false, // Keep company logo in color
PrinterName = "Office Color Printer" // Specific high-quality printer
};
// Print the invoice
Printer.Print("invoice_2024_001.pdf", invoiceSettings);IRON VB CONVERTER ERROR developers@ironsoftware.comWhat Happens If I Don't Specify Print Settings?
If print settings aren't specified, IronPrint uses the default settings from your system's default printer, which may not match your intended output format or quality requirements. To discover available printers on your system, use the GetPrinterNames method to retrieve all connected printers programmatically.
What Print Settings Are Available?
Explore all available print settings options below. The complete API reference provides detailed documentation for each property and method:
| Setting | Description | Default Value | Remarks |
|---|---|---|---|
| DefaultSettings | Initializes a new instance of the IronPrint.PrintSettings class with default values | N/A | N/A |
| PaperSize | Sets the paper size used by the printer | IronPrint.PaperSize.PrinterDefault | N/A |
| PaperOrientation | Specifies the paper orientation (e.g., Portrait or Landscape) | IronPrint.PaperOrientation.Portrait | N/A |
| Dpi | Represents the intended print resolution in dots per inch | 300 | 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 | 1 | 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 | null (uses OS default printer) | 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 | null (uses printer default margins) | N/A |
| Grayscale | Indicates whether to print in grayscale | false (attempts color printing) | N/A |
| Flatten | Flatten the PDF before printing, which is useful for displaying form field values and images | false | N/A |
| 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 | null (uses printer default tray) | 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). This tray selection property is available only in Windows |
Which Print Settings Should I Always Configure?
For most business applications, always configure PaperSize, PaperOrientation, and Dpi to ensure consistent output across different printers and systems. These three settings have the most impact on document appearance and readability.
When working with dialog-based printing, combine custom settings with user interaction using the ShowPrintDialog method:
// Pre-configure settings but allow user to modify
var presetSettings = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300
};
// Show dialog with preset values
Printer.ShowPrintDialog("report.pdf", presetSettings);// Pre-configure settings but allow user to modify
var presetSettings = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300
};
// Show dialog with preset values
Printer.ShowPrintDialog("report.pdf", presetSettings);IRON VB CONVERTER ERROR developers@ironsoftware.comHow Do I Handle Platform-Specific Settings?
Some settings like Tray selection are only available on Windows. Always check platform compatibility when using platform-specific features, and provide fallback behavior for cross-platform applications. For troubleshooting platform-specific issues, consult the engineering support guide.
What Are Common Print Setting Combinations?
Common combinations include A4/Portrait/300 DPI for standard documents, A3/Landscape/600 DPI for detailed reports, and Letter/Portrait/300 DPI/Grayscale for draft printing to save ink.
Here's an example showcasing different scenarios:
// Standard office document
var standardDocument = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300
};
// Detailed engineering drawing
var technicalDrawing = new PrintSettings
{
PaperSize = PaperSize.A3,
PaperOrientation = PaperOrientation.Landscape,
Dpi = 600,
Grayscale = false
};
// Draft mode for review
var draftMode = new PrintSettings
{
PaperSize = PaperSize.Letter,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 150,
Grayscale = true,
NumberOfCopies = 5
};
// High-volume batch printing
var batchPrint = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300,
NumberOfCopies = 100,
Tray = "Tray 2" // Large capacity tray on Windows
};// Standard office document
var standardDocument = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300
};
// Detailed engineering drawing
var technicalDrawing = new PrintSettings
{
PaperSize = PaperSize.A3,
PaperOrientation = PaperOrientation.Landscape,
Dpi = 600,
Grayscale = false
};
// Draft mode for review
var draftMode = new PrintSettings
{
PaperSize = PaperSize.Letter,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 150,
Grayscale = true,
NumberOfCopies = 5
};
// High-volume batch printing
var batchPrint = new PrintSettings
{
PaperSize = PaperSize.A4,
PaperOrientation = PaperOrientation.Portrait,
Dpi = 300,
NumberOfCopies = 100,
Tray = "Tray 2" // Large capacity tray on Windows
};IRON VB CONVERTER ERROR developers@ironsoftware.comFor more comprehensive examples and advanced printing scenarios, explore the print document tutorial which covers the complete printing workflow from start to finish.
When implementing print settings in production environments, especially in web applications using Web.config, review the guide on setting license keys in Web.config to ensure proper configuration.
Frequently Asked Questions
How do I configure print settings in C#?
To configure print settings in C#, instantiate the PrintSettings class from IronPrint and set properties like PaperSize, PaperOrientation, Dpi, NumberOfCopies, and Grayscale. Then pass this PrintSettings object as the second parameter to the Print or ShowPrintDialog methods.
What print settings can I customize?
IronPrint's PrintSettings class allows you to customize paper size (A4, Letter, etc.), orientation (Portrait/Landscape), DPI resolution, number of copies, printer selection, paper margins, and grayscale printing options.
How do I set paper size and orientation?
Set paper size using the PaperSize property (e.g., PaperSize.A4) and orientation using the PaperOrientation property (e.g., PaperOrientation.Landscape) in the IronPrint PrintSettings object before calling the Print method.
Can I print multiple copies of a document?
Yes, you can print multiple copies by setting the NumberOfCopies property in the PrintSettings class. For example, settings.NumberOfCopies = 2 will print two copies of your document using IronPrint.
How do I set custom margins for printing?
Set custom margins using the PaperMargins property in PrintSettings with the Margins class. For example: settings.PaperMargins = new Margins(10, 10, 10, 10) sets 10mm margins on all sides when printing with IronPrint.
Can I print in grayscale instead of color?
Yes, enable grayscale printing by setting the Grayscale property to true in the PrintSettings object. This will convert color documents to grayscale when printing through IronPrint.






