Skip to main content

Specify the Paper Source and Printer Resolution

  • 2 minutes to read

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

Handle the PrintingSystemBase.StartPrint event using the XtraReport.PrintingSystem property. In the event handler, choose the paper source and printer resolution using the PrintDocument.PrinterSettings property, and provide the selected values to the PrintDocument.DefaultPageSettings property.

using System.Drawing.Printing;
using DevExpress.Xpf.Printing;
using DevExpress.XtraPrinting;
// ... 

private void simpleButton_Click(object sender, RoutedEventArgs e) {
    XtraReport1 report = new XtraReport1();
    report.PrintingSystem.StartPrint += PrintingSystem_StartPrint;
    PrintHelper.Print(report);
}

private void PrintingSystem_StartPrint(object sender, PrintDocumentEventArgs e) {
    // Select a paper source.
    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;
        }
    // Select a printer resolution.
    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;
        }
}