System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument(); p.PrinterSettings.PrinterName = cbInstalledPrinter.Text; char splitter = '\n'; char splitter2 = '\r'; string[] test1 = txtTextToPrint.Text.Split(splitter); foreach (string s in test1) { Console.WriteLine(s); } p.PrintPage += delegate(object sender1, System.Drawing.Printing.PrintPageEventArgs e1) { float x = 10; float y = 5; float height = 0F; Font drawFont = new Font("Times New Roman", 8, FontStyle.Regular); string[] test = txtTextToPrint.Text.Split(splitter); foreach (string s in test) { string text = s.Trim(); e1.Graphics.DrawString(text, drawFont, new SolidBrush(Color.Black), new RectangleF(x, y, p.DefaultPageSettings.PrintableArea.Width, height)); y += e1.Graphics.MeasureString(text, drawFont).Height; e1.Graphics.Flush(); } }; p.Print();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)