A
Alberto
I have to print the content of a panel but I have two problems. The code
I've written is this:
Bitmap imagen = null;
private void btnImprimir_Click(object sender, EventArgs e)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
ppd.Document = doc;
CapturaImagen();
if (ppd.ShowDialog() == DialogResult.OK)
doc.Print();
}
void doc_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(imagen, 0, 0);
}
private void CapturaImagen()
{
int width = rbolActual.Width;
int height = rbolActual.Height;
imagen = new Bitmap(width, height);
Rectangle rec = new Rectangle(0, 0, width, height);
rbolActual.DrawToBitmap(imagen, rec);
}
1) The size of the image use to be 1008 x 626 pixels so it's larger than a
normal paper (A4).
2) I'd like to see a print preview dialog so that I could say the number of
copies and select the printer but I don't know how to do it.
Thank you very much.
I've written is this:
Bitmap imagen = null;
private void btnImprimir_Click(object sender, EventArgs e)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument doc = new PrintDocument();
doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
ppd.Document = doc;
CapturaImagen();
if (ppd.ShowDialog() == DialogResult.OK)
doc.Print();
}
void doc_PrintPage(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawImage(imagen, 0, 0);
}
private void CapturaImagen()
{
int width = rbolActual.Width;
int height = rbolActual.Height;
imagen = new Bitmap(width, height);
Rectangle rec = new Rectangle(0, 0, width, height);
rbolActual.DrawToBitmap(imagen, rec);
}
1) The size of the image use to be 1008 x 626 pixels so it's larger than a
normal paper (A4).
2) I'd like to see a print preview dialog so that I could say the number of
copies and select the printer but I don't know how to do it.
Thank you very much.