[C#]프린터 출력 및 페이지 설정 예제 소스
프린터 출력 및 페이지 설정 예제 소스입니다.
아래의 소스는 폼 크기, 페이지 설정에 맞게 프린터 출력이 되는 걸 확인 할 수 있습니다.
using System.Drawing.Printing;
private void button1_Click(object sender, EventArgs e)
{
PrintDocument printDocument1 = new PrintDocument();
printDocument1.PrintPage += new PrintPageEventHandler(this.printDocument1_PrintPage);
printDocument1.PrinterSettings.Copies = 1;
PageSetupDialog pageSetup = new PageSetupDialog();
pageSetup.Document = printDocument1;
pageSetup.PageSettings = printDocument1.DefaultPageSettings;
if (pageSetup.ShowDialog() == DialogResult.OK)
{
printDocument1.Print();
printDocument1.Print();
}
}
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(bmpImage, 0, 0);
this.DrawToBitmap(bmpImage, new Rectangle(0, 0, this.Width, this.Height));
e.Graphics.DrawImage(bmpImage, 0, 0);
}