hi,
I have problems to print the records which is saved in text file. It prints whatever in between the textfile but does not print whatever contents in the textfile. Can anyone guide me what goes wrong in the code.
Public Class Form1
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As Printing.PrintPageEventArgs)
Dim printFont = New Font("Arial", 10)
Dim linesPerPage As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing
Dim i As Integer = 0
Dim LAlign As Integer = 2
Dim arrayPIN As New ArrayList()
Dim obj As New PrintDoc()
Dim Lang As String
ReceiptLanguage(Lang)
i = PrintBlankLine(i, 3) ' reserve for logo print
prtStrArr(i) = "" : i += 1
If Lang = LANG_MALAY Then
prtStrArr(i) = vbCr & Space(31) & StrOfficialReceipt : i += 1
prtStrArr(i) = vbCr & Space(36) & StrCash : i += 1
Else
prtStrArr(i) = vbCr & Space(29) & StrOfficialReceipt : i += 1
prtStrArr(i) = vbCr & Space(37) & StrCash : i += 1
End If
prtStrArr(i) = "----------------------------------------------------------------" : i += 1
prtStrArr(i) = "" : i += 1
prtStrArr(i) = vbCr & Space(LAlign) & strTransNo & vbTab & ": " & TransactionNo : i += 1
prtStrArr(i) = vbCr & Space(LAlign) & strDate & ": " & CurrentTranxDate : i += 1
If Lang = LANG_MALAY Then
prtStrArr(i) = vbCr & Space(LAlign) & strTime & vbTab & ": " & CurrentTranxTime : i += 1
Else
prtStrArr(i) = vbCr & Space(LAlign) & strTime & ": " & CurrentTranxTime : i += 1
End If
prtStrArr(i) = vbCr & Space(LAlign) & strKioskID & vbTab & ": " & KioskNo : i += 1
If Lang = LANG_MALAY Then
prtStrArr(i) = vbCr & Space(LAlign) & strBranch & vbTab & vbTab & ": " & StoreCity : i += 1
Else
prtStrArr(i) = vbCr & Space(LAlign) & strBranch & vbTab & ": " & StoreCity : i += 1
End If
prtStrArr(i) = "" : i += 1
prtStrArr(i) = vbCr & Space(LAlign) & strPayDetails : i += 1
prtStrArr(i) = "----------------------------------------------------------------" : i += 1
prtStrArr(i) = "Agency Name" & vbTab & " A/C No " & vbTab & "Amount" & vbTab : i += 1
prtStrArr(i) = "" : i += 1
Dim aStr(8) As String
Dim FILE_NAME As String = "C:\Documents and Settings\Administrator\Desktop\PaymentRecords.txt"
If System.IO.File.Exists(FILE_NAME) = True Then
Dim objReader As New System.IO.StreamReader(FILE_NAME)
Do While objReader.Peek() <> -1
aStr = Split(objReader.ReadLine(), ";")
SESSION_AGENCY_NAME = aStr(0)
SESSION_AGENCY_ACCNO = aStr(1)
SESSION_AGENCY_BILLAMO = aStr(5)
prtStrArr(i) = SESSION_AGENCY_NAME & SESSION_AGENCY_ACCNO & SESSION_AGENCY_BILLAMO : i += 1
Loop
End If
' Calculate the number of lines per page.
'linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
linesPerPage = 11
' Print each line of the file.
While count < linesPerPage
line = streamToPrint.ReadLine()
If line Is Nothing Then
Exit While
End If
yPos = topMargin + count * printFont.GetHeight(ev.Graphics)
ev.Graphics.DrawString(line, printFont, Brushes.Black, leftMargin, yPos, New StringFormat())
count += 1
End While
prtStrArr(i) = "----------------------------------------------------------------" : i += 1
prtStrArr(i) = "Total Amount : " & TotalPayable : i += 1
prtStrArr(i) = "Total Convenience Fees : " & txtServiceCharge.Text : i += 1
prtStrArr(i) = "Total Paid : " & txtPaid.Text : i += 1
prtStrArr(i) = "----------------------------------------------------------------" : i += 1
prtStrArr(i) = vbCr & Space(31) & strTQ : i += 1
prtStrArr(i) = vbCr & Space(5) & strInfo : i += 1
prtStrArr(i) = vbCr & Space(28) & "1-000-000-000 or" : i += 1
prtStrArr(i) = vbCr & Space(23) & "Web: www.mmm.com.my" : i += 1
prtStrArr(i) = vbCr : i += 1
prtStrArr(i) = vbCr : i += 1
obj.printMyDoc(i)
Application.DoEvents()
If Not (line Is Nothing) Then
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
End Sub
End Class