/*
* 為 PrintDocument 增加PrintPageEventHandler事件handler
*/
private void btnPrint_Click(object sender, EventArgs e)
{
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
//if print() is invoked, the event printDoc_PrintPage will be called.
printDoc.Print();
}
public void printDoc_PrintPage(object sender, PrintPageEventArgs e)
{
Point ulCorner = new Point(300, 300);//location
e.Graphics.DrawImage(pictureBox1.Image, ulCorner);
}
沒有留言:
張貼留言