void PrintPage(object sender, PrintPageEventArgs ev)
{
Graphics g = ev.Graphics;
float yPos = ev.MarginBounds.Top;
while (curLineNr < Document.TotalNumberOfLines) {
LineSegment curLine = Document.GetLineSegment(curLineNr);
if (curLine.Words != null) {
float drawingHeight = MeasurePrintingHeight(g, curLine, ev.MarginBounds.Width);
if (drawingHeight + yPos > ev.MarginBounds.Bottom) {
break;
}
DrawLine(g, curLine, yPos, ev.MarginBounds);
yPos += drawingHeight;
}
++curLineNr;
}
// If more lines exist, print another page.
ev.HasMorePages = curLineNr < Document.TotalNumberOfLines;
}
#endregion