Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/11/2014, 09:20
raul1986
 
Fecha de Ingreso: noviembre-2014
Mensajes: 4
Antigüedad: 9 años, 5 meses
Puntos: 0
Respuesta: C# Problema Impresión Imagen

ya he conseguido que funcione.
Sigo sin tener claro porqué antes el código no funcionaba, pero dándole la vuelta si imprime como quiero.

Código:
       private void btnImprimir_Click(object sender, EventArgs e)
        {
            try
            {
                int ncopias;
                int totcopias;
                DataGridViewRow fila;

                for (int p = 0; p < dtgv.Rows.Count; p++)
                {
                    fila = dtgv.Rows[p];

                    if (fila.Cells[0].Value.ToString() == "True")
                    {

                        ncopias = 0;
                        totcopias = Convert.ToInt32(fila.Cells[2].Value.ToString());
                        while (ncopias < totcopias)
                        {
                            intPosicion = p;
                            printDocument1.PrinterSettings = printDialog1.PrinterSettings;
                            printDocument1.PrintPage += new PrintPageEventHandler(print_my_page);
                            printDocument1.BeginPrint += new PrintEventHandler(begin_print);
                            printDocument1.DefaultPageSettings.Landscape = true;

                            printDocument1.Print();
                            
                            ncopias++;
                        }
                    }

                }
                
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString() + " - " + ex.StackTrace.ToString());
            }
        }
Código:
private void print_my_page(object sender, PrintPageEventArgs ev)
        {
            ev.Graphics.PageUnit = GraphicsUnit.Millimeter;
            
            DataGridViewRow row = dtgv.Rows[intPosicion];
            string strFoto = row.Cells[1].Value.ToString();
            picPlantilla.Image = new Bitmap(strFoto);

            ev.Graphics.DrawImage(picPlantilla.Image, 0, 8, 145, 95);

            ev.HasMorePages = false;
              
        }