使用vb.net自动在POS(Epson)打印机中剪切纸张 [英] Auto Cut the Paper in POS (Epson) Printer using vb.net

查看:107
本文介绍了使用vb.net自动在POS(Epson)打印机中剪切纸张的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Vb.net开发了一个POS应用程序。

我在记事本中写了一个文本,然后我将在Epson打印机上打印一张收据,

现在我需要在打印完成后使用vb.net代码自动剪纸。



我的代码



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 '...Left...
      Dim topMargin As Single = ev.MarginBounds.Top
      Dim line As String = Nothing

      ' Calculate the number of lines per page.
      linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics)

      ' 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
     
          ev.HasMorePages = True
      Else
          ev.HasMorePages = False
      End If
  End Sub









但它只打印文本而不是自动剪切。





But it only print the text and not cut automatically.

推荐答案

这篇关于使用vb.net自动在POS(Epson)打印机中剪切纸张的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆