/// <summary> /// 打印窗体控件 /// </summary> /// <param name="control">控件对象</param> public static void Print(Control control) { ScreenCapture capture = new ScreenCapture(); Image image = capture.CaptureWindow(control.Handle); ImagePrintHelper helper = new ImagePrintHelper(image); helper.PrintPreview(); }
/// <summary> /// 弹出打印窗体的预览对话框 /// </summary> /// <param name="form">窗体对象</param> public static void Print(Form form) { ScreenCapture capture = new ScreenCapture(); Image image = capture.CaptureWindow(form.Handle); ImagePrintHelper helper = new ImagePrintHelper(image); helper.PrintPreview(); }
private void btnPrintImage_Click(object sender, EventArgs e) { ImagePrintHelper imagePrint = new ImagePrintHelper(this.pictureBox1.Image, Path.GetFileName(this.txtFilPath.Text)); imagePrint.AllowPrintShrink = true; imagePrint.AllowPrintCenter = true; imagePrint.AllowPrintEnlarge = true; imagePrint.AllowPrintRotate = true; imagePrint.PrintWithDialog();//弹出打印对话框,确认进行打印 }
private void btnPrintView_Click(object sender, EventArgs e) { ImagePrintHelper imagePrint = new ImagePrintHelper(this.pictureBox1.Image, Path.GetFileName(this.txtFilPath.Text)); imagePrint.PrintPreview();//弹出打印预览页面 }