Skip to main content
A newer version of this page is available. .

Specify the Paper Source and Printer Resolution

This example demonstrates how to select the paper source and set the printer resolution programmatically.

To do this, assign a report instance to a ReportPrintTool, and handle the PrintingSystemBase.StartPrint event of the Print Tool’s PrintToolBase.PrintingSystem.

using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System.Drawing.Printing;
// ...

private void button1_Click(object sender, System.EventArgs e) {
    ReportPrintTool printTool = new ReportPrintTool(new XtraReport1());
    printTool.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
    printTool.PrintDialog();
}

void PrintingSystem_StartPrint(object sender, PrintDocumentEventArgs e) {
    for (int i = 0; i < e.PrintDocument.PrinterSettings.PaperSources.Count; i++)
        if (e.PrintDocument.PrinterSettings.PaperSources[i].Kind ==
            PaperSourceKind.TractorFeed) {
            e.PrintDocument.DefaultPageSettings.PaperSource =
                e.PrintDocument.PrinterSettings.PaperSources[i];
            break;
        }

    for (int i = 0; i < e.PrintDocument.PrinterSettings.PrinterResolutions.Count; i++)
        if (e.PrintDocument.PrinterSettings.PrinterResolutions[i].Kind ==
            PrinterResolutionKind.High) {
            e.PrintDocument.DefaultPageSettings.PrinterResolution =
                e.PrintDocument.PrinterSettings.PrinterResolutions[i];
            break;
        }
}