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
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


0