private void pd_PrintPage(object sender, PrintPageEventArgs ev) { float linesPerPage = 0; float yPos = 0; int count = 0; float leftMargin = ev.MarginBounds.Left; float topMargin = ev.MarginBounds.Top; string line = null; // Calculate the number of lines per page... linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics); if ((range.Checked == true && int.Parse(Startrange.Text) > page)) { while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null)) { count++; } } // Print each line of the file... if ((all.Checked == true) || (range.Checked == true && int.Parse(Startrange .Text) <= page)) { while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null)) { yPos = topMargin + (count * printFont.GetHeight(ev.Graphics)); ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos); count++; } } // If more lines exist, print another page... if (range.Checked == true && page == int.Parse(Endrange .Text)) { ev.HasMorePages = false; return; } ev.HasMorePages = true; page++; if ((line != null) && (all.Checked == true)) ev.HasMorePages = true; if ((line == null) && (all.Checked == true)) ev.HasMorePages = false; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)