private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { float linesPerPage = 0; float yPos = 0; int count = 0; float leftMargin = e.MarginBounds.Left; float topMargin = e.MarginBounds.Top; string line = null; // Calculate the number of lines per page. linesPerPage = 30; //MessageBox.Show("Turn the page to continue"); // Print each line of the file. while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null)) { yPos = topMargin + (count * printFont.GetHeight(e.Graphics)); e.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, new StringFormat()); count++; } if (line != null) { e.HasMorePages = true; } else { e.HasMorePages = false; }
while (count < linesPerPage && ((line = streamToPrint.ReadLine()) != null)) { //here the condition is true and //lines are printed to the limit } //check: limit was reached or there is no more lines if (line != null) { //limit was reached } else { //no more lines ;) }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)