Consulta también:
- Como programar el boton imprimir en c# 2010
- Imprimir modo espejo word - Guide
- Imprimir formato libro word - Guide
- No funciona imprimir pantalla - Guide
- Imposible imprimir 50 brother - Foro impresora
- Como imprimir a doble cara y que coincidan - Foro impresora
1 respuesta
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace WindowsApplication4
{
public partial class Form1 : Form
{
private Button botonImprimir = new Button();
private PrintDocument printDocument1 = new PrintDocument();
public Form1()
{
botonImprimir.Text = "Imprimir Formulario";
botonImprimir.Click += new EventHandler(printButton_Click);
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
this.Controls.Add(botonImprimir);
}
void printButton_Click(object sender, EventArgs e)
{
CapturarPantalla();
printDocument1.Print();
}
Bitmap imagen;
private void CapturarPantalla()
{
Graphics g = this.CreateGraphics();
Size s = this.Size;
imagen = new Bitmap(s.Width, s.Height, g);
Graphics g2 = Graphics.FromImage(imagen);
g2.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
}
private void printDocument1_PrintPage(System.Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(imagen, 0, 0);
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace WindowsApplication4
{
public partial class Form1 : Form
{
private Button botonImprimir = new Button();
private PrintDocument printDocument1 = new PrintDocument();
public Form1()
{
botonImprimir.Text = "Imprimir Formulario";
botonImprimir.Click += new EventHandler(printButton_Click);
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
this.Controls.Add(botonImprimir);
}
void printButton_Click(object sender, EventArgs e)
{
CapturarPantalla();
printDocument1.Print();
}
Bitmap imagen;
private void CapturarPantalla()
{
Graphics g = this.CreateGraphics();
Size s = this.Size;
imagen = new Bitmap(s.Width, s.Height, g);
Graphics g2 = Graphics.FromImage(imagen);
g2.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
}
private void printDocument1_PrintPage(System.Object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(imagen, 0, 0);
}
}
}