Foros del Web » Programación para mayores de 30 ;) » .NET »

ayuda con impresion en vb.net

Estas en el tema de ayuda con impresion en vb.net en el foro de .NET en Foros del Web. pues tengo un problema con la impresion en vb.net, como utilizo vastantes e.graphics las lineas de impresion se salen de la hoja y no puedo ...
  #1 (permalink)  
Antiguo 08/06/2009, 23:56
 
Fecha de Ingreso: junio-2009
Mensajes: 2
Antigüedad: 14 años, 10 meses
Puntos: 0
ayuda con impresion en vb.net

pues tengo un problema con la impresion en vb.net, como utilizo vastantes e.graphics las lineas de impresion se salen de la hoja y no puedo hacer que me las imprima en mas de una hoja, pues aqui esta mi codigo

Código:
ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
            ypos += lineHeight
            ev.Graphics.DrawString("PADECIMIENTO ACTUAL POR PROBLEMAS", New Font("calibri", 15, FontStyle.Bold), Brushes.Black, 235, ypos)
            ypos += lineHeight
            ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
            ypos += lineHeight
            nuevo += 3
            While indiceproblemas < contproblemas

                If seleccionador = 1 Then
                    If cargarproblemas(indiceproblemas, 0) <> "" Then
                        ev.Graphics.DrawString("P " & contador & ": " & cargarproblemas(indiceproblemas, 0) & "", prfont, Brushes.Black, 70, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 2 Then
                    If cargarproblemas(indiceproblemas, 1) <> "" Then
                        ev.Graphics.DrawString("S: " & cargarproblemas(indiceproblemas, 1) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 3 Then
                    If cargarproblemas(indiceproblemas, 2) <> "" Then
                        ev.Graphics.DrawString("O: " & cargarproblemas(indiceproblemas, 2) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 4 Then
                    If cargarproblemas(indiceproblemas, 3) <> "" Then
                        ev.Graphics.DrawString("A: " & cargarproblemas(indiceproblemas, 3) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 5 Then
                    If cargarproblemas(indiceproblemas, 4) <> "" Then
                        ev.Graphics.DrawString("P: " & cargarproblemas(indiceproblemas, 4) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3
                        seleccionador = 0
                        indiceproblemas += 1
                        contador += 1
                    Else
                        seleccionador = 0
                        indiceproblemas += 1
                        contador += 1
                    End If
                End If

                If nuevo = 48 Then
                    seleccionador += 1
                    ev.HasMorePages = False
                    nuevo = 0
                    Exit Sub
                End If
                seleccionador += 1
            End While


                ypos += lineHeight
                ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("EXAMEN FISICO", New Font("calibri", 15, FontStyle.Bold), Brushes.Black, 340, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("Examen fisico:", prfont, Brushes.Black, 70, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString(" " & examenfisico & " ", prfont, Brushes.Black, 70, ypos)
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                examenimpreso = True
                nuevo += 11
 ev.Graphics.DrawString("Laboratoprios o estudios previos: ", prfont, Brushes.Black, 70, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("" & laboratorios & "", prfont, Brushes.Black, 70, ypos)
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                ypos += lineHeight
                estudiosimpreso = True
                nuevo += 8

ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("DIAGNOSTICOS", New Font("calibri", 15, FontStyle.Bold), Brushes.Black, 350, ypos)
                ypos += lineHeight
                ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
                ypos += lineHeight
                ypos += lineHeight
                nuevo += 3
                While indicediagnosticos < contdiagnosticos
                    ev.Graphics.DrawString("Diagnostico " & indicemas & ": " & cargardiagnosticos(indicediagnosticos, 0) & "", prfont, Brushes.Black, 70, ypos)
                    ypos += lineHeight
                    ypos += lineHeight
                    nuevo += 2
                    If nuevo >= 48 Then
                        nuevo = 0
                        ev.HasMorePages = False
                        Exit Sub
                    End If
                    indicediagnosticos += 1
                    indicemas += 1
                End While
tengo que aclarar que este no es el codigo completo, pero no cupo todo en el mensage, perro lo que falta es identico al primer while, la variable nuevo es un contador de lineas de un intento fallido de querer hacer el salto pero no funciono, si alguien tiene una respuesta, codigo similar me gustaria que me ayudaran, si es mejor con un ejemplo, pero bueno, cuanquier ayuda es valiosa, de antemano muchas gracias.
  #2 (permalink)  
Antiguo 11/06/2009, 17:04
Avatar de eledgarr  
Fecha de Ingreso: octubre-2008
Ubicación: La ciudad de la esperanza
Mensajes: 133
Antigüedad: 15 años, 6 meses
Puntos: 3
Respuesta: ayuda con impresion en vb.net

If MiSumaRegs >= Go_DataSet.Tables(MsTabElem).Rows.Count Then 'Si se imprimieron todos los registros termina
e.HasMorePages = False
Else
e.HasMorePages = True 'existen registros por imprimir continua en otra hoja
End If


Tu podrias poner algo asi como que si rebasa el alto de tu hoja continue en otra espero te sirva si no pon mas datos de tu codigo
  #3 (permalink)  
Antiguo 14/06/2009, 21:41
 
Fecha de Ingreso: junio-2009
Mensajes: 2
Antigüedad: 14 años, 10 meses
Puntos: 0
Respuesta: ayuda con impresion en vb.net

pues hace algo de tiempo intente algo similar pero no me hacia el salto, me generaba una segunda pagina en blanco y me seguia escribiendo sobre la primera.

Código:
ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
            ypos += lineHeight
            ev.Graphics.DrawString("PADECIMIENTO ACTUAL POR PROBLEMAS", New Font("calibri", 15, FontStyle.Bold), Brushes.Black, 235, ypos)
            ypos += lineHeight
            ev.Graphics.DrawString("__________________________________________________________________________________________________________", New Font("calibri", 10, FontStyle.Bold), Brushes.Black, 50, ypos)
            ypos += lineHeight
            nuevo += 3
            

While indiceproblemas < contproblemas

                If seleccionador = 1 Then
                    If cargarproblemas(indiceproblemas, 0) <> "" Then
                        ev.Graphics.DrawString("P " & contador & ": " & cargarproblemas(indiceproblemas, 0) & "", prfont, Brushes.Black, 70, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 2 Then
                    If cargarproblemas(indiceproblemas, 1) <> "" Then
                        ev.Graphics.DrawString("S: " & cargarproblemas(indiceproblemas, 1) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 3 Then
                    If cargarproblemas(indiceproblemas, 2) <> "" Then
                        ev.Graphics.DrawString("O: " & cargarproblemas(indiceproblemas, 2) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 4 Then
                    If cargarproblemas(indiceproblemas, 3) <> "" Then
                        ev.Graphics.DrawString("A: " & cargarproblemas(indiceproblemas, 3) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3

                    End If
                End If
                If seleccionador = 5 Then
                    If cargarproblemas(indiceproblemas, 4) <> "" Then
                        ev.Graphics.DrawString("P: " & cargarproblemas(indiceproblemas, 4) & "", prfont, Brushes.Black, 80, ypos)
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        ypos += lineHeight
                        nuevo += 3
                        seleccionador = 0
                        indiceproblemas += 1
                        contador += 1
                    Else
                        seleccionador = 0
                        indiceproblemas += 1
                        contador += 1
                    End If
                End If

                If nuevo > 48 Then
                    ev.HasMorePages = true
                    nuevo = 0
               Else 
                    ev.HasMorePages = false
                End If

                seleccionador += 1
            End While

tambien lo intente sacando el if del while, pero sucedia lo mismo
  #4 (permalink)  
Antiguo 16/06/2009, 11:19
Avatar de eledgarr  
Fecha de Ingreso: octubre-2008
Ubicación: La ciudad de la esperanza
Mensajes: 133
Antigüedad: 15 años, 6 meses
Puntos: 3
Respuesta: ayuda con impresion en vb.net

Con tu contador nuevo no vas a poder por que se puede acabar la hoja y el contador nunca sera mayor a 48

primero averigua el alto del area imprimible de la hoja:

AreaImpresion_Alto = PrintDocument.DefaultPageSettings.PrintableArea.He ight

y cuando rebases esta altura y todavia falten elementos por imprimir que salte a otra hoja

checa en este mismo foro una clase de impresión que puse igual y te sirve buscala como "clase ticket"
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:59.