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.
- Install IronPrint via NuGet:
Install-Package IronPrint - Add
using IronPrint;to the file - Create a
PrintSettingsobject - Set properties like
PaperSize,Dpi,PaperOrientation,NumberOfCopies, andGrayscale - Pass settings to
Printer.Print()orPrinter.ShowPrintDialog()
-
1Install IronPrint with NuGet Package Manager
-
2Copy and run this code snippet.
using IronPrint; // Print with custom settings Printer.Print("document.pdf", new PrintSettings { PaperSize = PaperSize.A4, PaperOrientation = PaperOrientation.Landscape, Dpi = 300, NumberOfCopies = 2, Grayscale = true });C# -
3Deploy to test on your live environment
Start using IronPrint in your project today with a free trial
Minimal Workflow (5 steps)
- Install the IronPrint C# printing library
- Create a
PrintSettingsobject - Configure paper size, orientation, DPI, copies, and more
- Pass settings to
Printer.Print()orPrinter.ShowPrintDialog() - Verify the printed document matches your configured settings
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;
// Path to the document you want to print
string document = "document.pdf";
// 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);
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);Imports IronPrint
' Invoice printing with specific business settings
Dim invoiceSettings As New PrintSettings With {
.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)What 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);Imports System
' Pre-configure settings but allow user to modify
Dim presetSettings As New PrintSettings With {
.PaperSize = PaperSize.A4,
.PaperOrientation = PaperOrientation.Portrait,
.Dpi = 300
}
' Show dialog with preset values
Printer.ShowPrintDialog("report.pdf", presetSettings)How 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
};Imports System
' Standard office document
Dim standardDocument As New PrintSettings With {
.PaperSize = PaperSize.A4,
.PaperOrientation = PaperOrientation.Portrait,
.Dpi = 300
}
' Detailed engineering drawing
Dim technicalDrawing As New PrintSettings With {
.PaperSize = PaperSize.A3,
.PaperOrientation = PaperOrientation.Landscape,
.Dpi = 600,
.Grayscale = False
}
' Draft mode for review
Dim draftMode As New PrintSettings With {
.PaperSize = PaperSize.Letter,
.PaperOrientation = PaperOrientation.Portrait,
.Dpi = 150,
.Grayscale = True,
.NumberOfCopies = 5
}
' High-volume batch printing
Dim batchPrint As New PrintSettings With {
.PaperSize = PaperSize.A4,
.PaperOrientation = PaperOrientation.Portrait,
.Dpi = 300,
.NumberOfCopies = 100,
.Tray = "Tray 2" ' Large capacity tray on Windows
}For 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 with IronPrint in C#?
To configure print settings in C#, use IronPrint's `PrintSettings` class. Instantiate this class, set preferences like paper size, DPI, and orientation, and then pass it to the `Print` method.
What are the essential print settings I should configure?
For most applications, configure `PaperSize`, `PaperOrientation`, and `Dpi` to ensure consistent document appearance and readability across different printers.
Can I print documents in grayscale using IronPrint?
Yes, you can print documents in grayscale by setting the `Grayscale` property in the `PrintSettings` class to `true`.
What happens if I don't specify any print settings?
If no print settings are specified, IronPrint will use the default settings from your system's default printer, which may not match your formatting or quality requirements.
How do I install IronPrint in my C# project?
Install IronPrint via NuGet with the command `Install-Package IronPrint`. Then, add `using IronPrint;` to your file to start configuring your print settings.
What are some 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.
How can I handle platform-specific print settings with IronPrint?
Check platform compatibility when using settings like Tray selection, which is only available on Windows. Provide fallback options for cross-platform applications.
Why is it important to configure print settings?
Configuring print settings is crucial to ensure documents print as intended with specific parameters like paper size, margins, and quality, maintaining consistency across different environments.
Can I allow users to modify print settings during the print process?
Yes, you can use the `ShowPrintDialog` method to pre-configure settings and allow users to modify them before printing.
What options are available for printing multiple copies of a document?
You can print multiple copies by setting the `NumberOfCopies` property in the `PrintSettings` class. Note that some platforms may have limitations on reproducing multiple copies.

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.