Back to Devexpress

PageSettingsHelper Class

corelibraries-devexpress-dot-xtraprinting-865608bd.md

latest3.7 KB
Original Source

PageSettingsHelper Class

Enables you to override the default printer settings in your application.

Namespace : DevExpress.XtraPrinting

Assembly : DevExpress.Printing.v25.2.Core.dll

NuGet Package : DevExpress.Printing.Core

Declaration

csharp
public class PageSettingsHelper
vb
Public Class PageSettingsHelper

The following members return PageSettingsHelper objects:

Remarks

To make the report document use the settings defined by the default system printer, use the XtraReport.DefaultPrinterSettingsUsing property.

These settings include the PrinterSettingsUsing.UseLandscape or PrinterSettingsUsing.UsePaperKind properties that define whether or not the XtraReport.Landscape and XtraReport.PaperKind properties of a report should be taken into account. When the printer’s settings are used, the values of the corresponding report properties will be ignored.

To override the default printer settings in your application, use the static properties and methods of the PageSettingsHelper class.

To assign the page margins defined for a specific printer to the XtraReport.Margins property of a report, use the approach illustrated in the following example.

csharp
using System.Drawing;
using System.Drawing.Printing;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    XtraReport1 report = new XtraReport1();
    PrinterSettings printerSettings = new PrinterSettings(); 

    // Specify the PrinterName if the target printer is not the default one.
    printerSettings.PrinterName = "Printer Name";

    // Assign minimum margins supported for the selected printer to the report document.
    report.Margins = PageSettingsHelper.GetMinMargins(printerSettings.DefaultPageSettings);

    // Send the report to the specified printer.
    ReportPrintTool printTool = new ReportPrintTool(report);
    printTool.Print("Printer Name");
}
vb
Imports System.Drawing
Imports System.Drawing.Printing
' ...

Private Sub button1_Click(sender As Object, e As System.EventArgs)
    Dim report As New XtraReport1()
    Dim printerSettings As New PrinterSettings()

    ' Specify the PrinterName if the target printer is not the default one.
    printerSettings.PrinterName = "Printer Name"

    ' Assign minimum margins supported for the selected printer to the report document.
    report.Margins = PageSettingsHelper.GetMinMargins(printerSettings.DefaultPageSettings)

    ' Send the report to the specified printer.
    Dim printTool As New ReportPrintTool(report)
    printTool.Print("Printer Name")
End Sub

Inheritance

Object PageSettingsHelper

See Also

PageSettingsHelper Members

DevExpress.XtraPrinting Namespace