Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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;
        }
}