【问题标题】:I am trying to print via Ethernet on a thermal printer in VB.NET我正在尝试通过以太网在 VB.NET 中的热敏打印机上打印
【发布时间】:2023-04-02 02:26:01
【问题描述】:

我正在尝试通过以太网在 VB.NET 中的热敏打印机上进行打印。在互联网上搜索,我发现了这个程序,它显然存储在内存打印中,因为打印机什么都不做。然后,如果我从控制面板发出测试页,它会打印我在上面打印的内容 + 测试页。您是否错过了例程中的某些内容?非常感谢您能给我的帮助。

Dim cImpresion As String = Chr(27) & Chr(77) & Chr(64)
Dim tcpSender As TcpClient = New TcpClient()

tcpSender.SendBufferSize = 4096
tcpSender.Connect(whatIP, whatPort)
If tcpSender.Connected = False Then
  tcpSender.Close()
  Exit Sub
End If

Dim nStream As NetworkStream = tcpSender.GetStream()
If nStream.CanWrite = True Then
  Dim SendBytes As Byte
  SendBytes = System.Text.Encoding.ASCII.GetBytes("the text I want to print")
  nStream.Write(SendBytes, 0, SendBytes.Length)
  nStream.Flush()
End If

nStream.Close()
tcpSender.Close()

【问题讨论】:

    标签: vb.net printing ethernet


    【解决方案1】:

    尝试将 VbCrLf 添加到 SendBytes:

    SendBytes = System.Text.Encoding.ASCII.GetBytes("the text I want to print")
    SendBytes = SendBytes + vbCrLf
    

    或者使用 nStream.WriteLine 代替 nStream.Write

    【讨论】:

      猜你喜欢
      • 2012-10-05
      • 1970-01-01
      • 1970-01-01
      • 2022-08-03
      • 2019-12-06
      • 2017-03-12
      • 2013-03-16
      • 2014-06-27
      相关资源
      最近更新 更多