星期一, 10月 01, 2007

利用C#程式碼列印

/*
* 為 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);
}

沒有留言: