2

我正在为超市开发一个系统,该系统将在使用 .net 开发票后打印 pos bill。

对于账单打印,我在 .net 中使用 System.Drawing.Printing。

问题是当项目列表太长时,当它增加单页限制时,pos 打印机只打印第一页并剪纸。

以下是我使用的打印代码示例。请帮我解决这个问题。

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
4

1 回答 1

1

谢谢大家。我找到了解决方案。我必须根据项目列表检查页面高度,并在页面超出时添加以下内容。

 e.HasMorePages = True 
于 2012-11-01T01:22:51.597 回答