I have develop a POS Application using Vb.net.
I write a text in notepad and from that i will print a receipt in Epson printer,
Now i need to auto cut the paper after the print complete using the vb.net code.
My code
Private Sub print_notepad()
Try
streamToPrint = New StreamReader("D:\Backup\Ramesh\DATA\bill.txt")
Try
printFont = New Font("Lucida Console", 12)
Dim pd As New PrintDocument()
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
Finally
streamToPrint.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs)
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
linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)
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
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If
End Sub
But it only print the text and not cut automatically.