Print Document

han

Member
Joined
Aug 7, 2003
Messages
5
HI...

anybody can help me?

I want to print my txt files but I dont have any idea how to put

space between the string...

thanks

Code:
Private WithEvents m_oDoc As PrintDocument
    Private m_oFile As StreamReader

    Private Sub MenuPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuPrint.Click
         m_oFile = File.OpenText(LastFile) -> ("C:/Text.txt")
        m_oDoc = New PrintDocument()
        m_oDoc.Print()
    End Sub

    Private Sub OnPagePrint(ByVal Sender As Object, _
    ByVal arg As System.Drawing.Printing.PrintPageEventArgs) _
    Handles m_oDoc.PrintPage
        Dim sngCurY As Single
        Dim sngLineHeight As Single
        Dim oFont As Font

        oFont = New System.Drawing.Font("Courier New", 12)
        
        sngLineHeight = oFont.GetHeight(arg.Graphics)

        sngCurY = arg.MarginBounds.Top

        If m_oFile.Peek() <> -1 Then
            Do

                sngCurY += sngLineHeight

                arg.Graphics.DrawString(m_oFile.ReadLine(), oFont, Brushes.Black, _
                arg.MarginBounds.Left, sngCurY)
            Loop Until sngCurY >= arg.MarginBounds.Bottom Or _
            m_oFile.Peek() = -1
        End If

        If m_oFile.Peek <> -1 Then
            arg.HasMorePages = True
        Else
            arg.HasMorePages = False
        End If
    End Sub


This code will print like this:

11,1224
33,Leon Armstrong,229
,Stanley Adams,382
,,612
55,David Craft,918
 
Back
Top