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:
- Export the report to text format (CSV or TXT).
- Send the resulting file to the printer driver.
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);
}
(you will be redirected to DevExpress.com to submit your response)