|
Posted on
2008-06-23 09:11
JieNet
阅读( 226)
评论()
收藏
举报
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
 {
int charactersOnPage = 0;//字符串中的字符数。
int linesPerPage = 0;//字符串中的文本行数。

//根据字体,区域测量每页的字符串个数和行数。
e.Graphics.MeasureString(stringToPrint, this.Font,
e.MarginBounds.Size, StringFormat.GenericTypographic,
out charactersOnPage, out linesPerPage);

e.Graphics.DrawString(stringToPrint, this.Font, Brushes.Black,
e.MarginBounds, StringFormat.GenericTypographic);

stringToPrint = stringToPrint.Substring(charactersOnPage);

e.HasMorePages = stringToPrint.Length > 0;
}
|