首先给你的窗体拽几个控件过来:pageSetupDialog、printPreviewDialog1、printDocument1; pageSetupDialog、printPreviewDialog1的Document属性对应printDocument1
private Bitmap memoryImage;
private void button2_Click(object sender, EventArgs e)
{
CaptureScreen();
pageSetupDialog1.PageSettings = new System.Drawing.Printing.PageSettings();
pageSetupDialog1.PageSettings.Landscape = true;
printPreviewDialog1.PrintPreviewControl.Zoom = 1.0;//预览比例100%
printPreviewDialog1.ShowDialog();
}
private void CaptureScreen()
{
Rectangle rc = this.Bounds;
rc.Offset(-this.Left, -this.Top);
memoryImage = new Bitmap(this.Width, this.Height);
this.DrawToBitmap(memoryImage, rc);
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}