This example demonstrates how to print a report in a dot matrix printer. First, a report is exported to the CSV format and saved to a temporary file in the current application directory. Then the Process.Start() method initiates the printing process. Note that the "Print" verb is assigned to the ProcessStartInfo.Verb property of the ProcessStartInfo instance passed to the Process.Start() method.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace RepPrintOnDotMatrix {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
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 psi = new ProcessStartInfo();
psi.FileName = Application.StartupPath + "\\temporary.csv";
psi.Verb = "Print";
Process.Start(psi);
}
}
}
Facebook
Twitter
Google+