Visual Basic.NET - Necesito Ayuda :(

 
Vista:

Necesito Ayuda :(

Publicado por Leonardo Daniel (3 intervenciones) el 08/12/2007 19:12:17
tengo el siguiente programa para realizar la impresion de un archivo de texto

Private OptPrnPage As New PageSettings()
Private StrToPrn As String
Private FontPrn As New Font("Times New Roman", 10)

Private Sub btnPrnFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnPrnFile.Click
Try
PrintDocument3.DefaultPageSettings = OptPrnPage
StrToPrn = RTB.Text
PrintDialog3.Document = PrintDocument3
Dim DR As DialogResult = PrintDialog3.ShowDialog
If DR = DR.OK Then
PrintDocument3.Print()
End If
Catch ex As Exception
MsgBox("Ex : " & ex.ToString)
End Try
End Sub

Private Sub btnOpenFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles btnOpenFile.Click
'OFD.Filter = "Archivos De Control RFID|*.rfd"
OFD.ShowDialog()
If OFD.FileName <> vbNullString Then
Try
Dim FS As New FileStream(OFD.FileName, FileMode.Open)
RTB.LoadFile(FS, RichTextBoxStreamType.PlainText)
FS.Close()
StrToPrn = RTB.Text
Catch ex As Exception
MsgBox("Ex : " & ex.ToString)
End Try
End If
End Sub


Private Sub printdocument3_PrintPage(ByVal sender As System.Object, ByVal e As _
System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument3.PrintPage
Dim nChars As Integer
Dim nLines As Integer
Dim sPage As String
Dim sFormat As New StringFormat()
Dim rectAng As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, _
e.MarginBounds.Width, e.MarginBounds.Height)
Dim MySize As New SizeF(e.MarginBounds.Width, e.MarginBounds.Height - FontPrn.GetHeight(e.Graphics))
sFormat.Trimming = StringTrimming.Word
e.Graphics.MeasureString(StrToPrn, FontPrn, MySize, sFormat, nChars, nLines)
StrToPrn = StrToPrn.Substring(0, nChars)
e.Graphics.DrawString(sPage, FontPrn, Brushes.Black, rectAng, sFormat)
If nChars < StrToPrn.Length Then
StrToPrn = StrToPrn.Substring(nChars)
e.HasMorePages = True
Else
e.HasMorePages = False
StrToPrn = rtb.Text
End If
End Sub

me muestra todos los cuadros de dialogos, pero no me imprime ninguna linea en la hoja, siendo que el documento esta repleto de texto

me urge la ayuda, necesito presentar mi proyecto de fin de semestre y es lo unico que me hace falta

ayuda por favor :(

gracias
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Necesito Ayuda :(

Publicado por Harold V. (411 intervenciones) el 13/12/2007 23:12:32
Hola espero esto te pueda ayudar

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim leftMargin As Single = 30 'e.MarginBounds.Left
Dim topMargin As Single = e.MarginBounds.Top - 50
Dim line As String = Nothing
linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics)

Dim Fil, Col As Int32
Dim LString As String = "aqui va todo tu texto"

yPos = topMargin + (count * printFont.GetHeight(e.Graphics))
e.Graphics.DrawString(LString, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
If Not (line Is Nothing) Then
e.HasMorePages = True
Else
e.HasMorePages = False
End If

End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar