I am developing a system for supermarket which will prints pos bill after invoicing using .net.
For the bill printing I am using System.Drawing.Printing in .net.
The issue was when the item list is too long , when it increase the one page limit pos printer only prints the first page and cut paper.
Following is the code sample for printing which I used. Please help me to solve this.
Private Sub printInvoice()
Dim printDocument As New PrintDocument
Dim printController As New StandardPrintController
printDocument.PrintController = printController
AddHandler printDocument.PrintPage, AddressOf PrintDocumnet_Event
printDocument.Print()
End Sub
Public Sub PrintDocumnet_Event(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Try
Dim dataFont As Font = New Font("Courier New", 9, FontStyle.Bold)
Dim leftMargin As Integer = 15
Dim topMargin As Integer = 65
For Each invoiceRow As DataRow In dtInvoice.Rows
Dim code As String = invoiceRow("Item_Code").ToString.Trim
Dim name As String = invoiceRow("Print_Name").ToString.Trim
Dim price As String = String.Format("{0:0.00}", Double.Parse(invoiceRow("Price"))) + "x"
Dim qty As String = String.Format("{0:0.###}", Double.Parse(invoiceRow("Qty")))
Dim amont As String = String.Format("{0:0.00}", Double.Parse(invoiceRow("Amount")))
Dim discount As String = String.Format("{0:0.00}", Double.Parse(invoiceRow("Discount")))
e.Graphics.DrawString(String.Format("{0,-8}", name), dataFont, Brushes.Black, leftMargin, topMargin)
topMargin += 15
e.Graphics.DrawString(String.Format("{0,-10} {1,7} {2,5} {3,8}", code, price, qty, amont), dataFont, Brushes.Black, leftMargin, topMargin)
topMargin += 20
Next
End Sub
Thanx for all. I found the solution. I had to check the page height according to item list and add the following when the page exceeds.