{
PrintDocument MyPrintDoc = new PrintDocument();
MyPrintDoc.PrintPage+=new PrintPageEventHandler(MyPrintDoc_PrintPage);
MyPrintDoc.Print();
}
protected void MyPrintDoc_PrintPage(object sender, PrintPageEventArgs e)
{
String drawString = "Sample Text";
Font drawFont = new Font("Arial", 16);
SolidBrush drawBrush = new SolidBrush(Color.Black);
float x = 150.0F;
float y = 50.0F;
StringFormat drawFormat = new StringFormat();
drawFormat.FormatFlags = StringFormatFlags.NoWrap;
e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
e.HasMorePages=false;
}
http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/cpref/html/frlrfsystemdrawingprinting.asp更多内容请到微软官方网站。本来项目是想用GUI的方式自己画图来实现,不过后来感觉那样实现起来比较麻烦,所以转成了去研究水晶报表了,故把代码贴在这里,以后可以查看。