Skip to content

DevExpress-Examples/reporting-winforms-print-report-in-dot-matrix-printer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reporting for WinForms - How to Print a Report on a Dot Matrix Printer

This example prints a report on a dot matrix printer. DevExpress Report components render reports in graphics mode only. So, for dot matrix devices, use the following approach:

  1. Export the report to text format (CSV or TXT).
  2. Send the resulting file to the printer driver.

Implementation Details

Export the report to CSV and save it to a temporary file (temporary.csv, in this example) in the current application directory. Then call the Process.Start method to initiate printing. Assign the Print verb to the ProcessStartInfo.Verb property. Then pass the ProcessStartInfo instance to Process.Start.

private void Form1_Load(object sender, EventArgs e) {
   XtraReport1 report = new XtraReport1();
   report.CreateDocument();
   printControl1.PrintingSystem = report.PrintingSystem;
}

private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    printControl1.PrintingSystem.ExportToCsv(Application.StartupPath + "\\temporary.csv", new DevExpress.XtraPrinting.CsvExportOptions(",", Encoding.Default));
    ProcessStartInfo startInfo = new ProcessStartInfo(Application.StartupPath + "\\temporary.csv");
    startInfo.Verb = "Open";
    foreach (var verb in startInfo.Verbs) {
        if (verb == "Print") startInfo.Verb = "Print";
    }
    Process.Start(startInfo);
}

Files to Review

Documentation

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

About

This example prints a report on a dot matrix printer.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •