我正在开发一个超市系统,它将使用.net。
开票后打印pos账单对于票据打印,我在.net。
中使用System.Drawing.Printing问题是当项目列表太长时,当它增加一页限制时,打印机只打印第一页并剪纸。
以下是我使用的打印代码示例。请帮我解决这个问题。
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
答案 0 :(得分:1)
对所有人而言。我找到了解决方案。我必须根据项目列表检查页面高度,并在页面超出时添加以下内容。
e.HasMorePages = True