how to read file and print in c# code example
Example: print file c#
private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float yPos = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
ev.Graphics.DrawString(sr.ReadToEnd(), printFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
}
private void CallPrint() {
printFont = new Font("Arial", 15);
sr = new StreamReader(@"MyFileToPrint.txt");
PrintDialog printDlg = new PrintDialog();
PrintDocument printDoc = new PrintDocument();
if (printDlg.ShowDialog() == DialogResult.OK)
{
printDoc.PrintPage += new PrintPageEventHandler(pd_PrintPage);
printDoc.Print();
}
}