Ver Mensaje Individual
  #3 (permalink)  
Antiguo 03/02/2011, 14:29
Avatar de CarmenRocio
CarmenRocio
 
Fecha de Ingreso: junio-2010
Ubicación: Perú - Lima - Chorrillos
Mensajes: 116
Antigüedad: 13 años, 10 meses
Puntos: 8
Información Respuesta: imprimir varias páginas con el printdocument en vb.net

Primero lo que hago por el momento estoy llenando solo 2 registro mejor dicho dos trabajadores y lo que hago primero es click en el boton vista peliminar:
Private Sub btnPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPreview.Click
imprimir(True)
End Sub


Luego la función imprimir es esta:como es vista previa le doy true bueno es asi como estube analizando ya que empece de cero con esto y tengo ya dos días nuriendome:

Private Sub imprimir(ByVal esPreview As Boolean)
' imprimir o mostrar el PrintPreview
If prtSettings Is Nothing Then
prtSettings = New PrinterSettings
End If
If chkSelAntes.Checked Then
If seleccionarImpresora() = False Then Return
End If
If prtDoc Is Nothing Then
prtDoc = New PrintDocument
lineaActual = 0
prtDoc.PrinterSettings = prtSettings
Dim TamañoPersonal As Printing.PaperSize
Dim Ancho As Short
Dim Alto As Short
Try
Ancho = Short.Parse("1600")
Alto = Short.Parse("655")
TamañoPersonal = New Printing.PaperSize("imp", Ancho, Alto)
prtDoc.DefaultPageSettings.PaperSize = TamañoPersonal
prtDoc.OriginAtMargins = True
Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK)
End Try
AddHandler prtDoc.PrintPage, AddressOf prt_PrintPage
End If
If esPreview Then
Dim prtPrev As New PrintPreviewDialog
prtPrev.Document = prtDoc
prtPrev.ShowDialog()
Else
prtDoc.Print()
End If
End Sub


No olvidar que este código lo saque del guille pero lo he modificado a mis requerimientos por otro lado la funcion prt_PrintPage

Private Sub prt_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
' Este evento se produce cada vez que se va a imprimir una página
Dim printFont As System.Drawing.Font
printFont = prtFont

'Datos es una lista generica de mi base de datos trabajadores

For Each info As BoInfo In Datos
nContador += 1
e.Graphics.DrawRectangle(New Pen(Color.Red, 1), -75, -75, 1585, 639)

e.Graphics.DrawString("Código", printFont, Brushes.Black, 170, 60)
e.Graphics.DrawString(info.codigo, printFont, Brushes.Black, 460, 60)
Next
If nContador < Datos.Count Then
e.HasMorePages = True ' Todavia faltan mas paginas
End If
End Sub


ya este seria el código primero pasa por el primer trabajados luego el segundo y se chanca encima pero yo quiero que se imprima el segundo cliente en otra pagina ya que no solo es su código es un monto de registros que tengo que imprimir espero me ayudes etube bucando en la web pero solo hablan del

e.HasMorePages = True