更新时间:2023-01-03 23:07:22
在PrintDocument PrintPage事件处理程序中,使用PrintPageEventArgs.Graphics对象:
In the PrintDocument PrintPage event handler, use the PrintPageEventArgs.Graphics object:
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
// Draw a picture.
e.Graphics.DrawImage(Image.FromFile(@"F:\Temp\MyPicture.bmp"), e.Graphics.VisibleClipBounds);
e.Graphics.DrawRectangle(myPen, myRectangle);
e.Graphics.DrawString("Hello!", myFont, myBrush, myPoint);
e.HasMorePages = false; //Last page
}
[edit]奇怪-右括号不会停留在我所说的位置...-OriginalGriff [/edit]
[edit]Strange - the close bracket would not stay where I put it... - OriginalGriff[/edit]
此 ^ ]应该可以帮助您入门.您只需要在PrintDocument.PrintPage()
事件中添加使这些方法生效,就可以立即进行打印.
快乐编码
This Drawing Lines and Shapes with GDI+[^] should get you started. You just need to add put these methods into effect in thePrintDocument.PrintPage()
event, and you should be printing in no time.
Happy Coding