【问题标题】:Mobile print format customization in mobile application移动应用程序中的移动打印格式自定义
【发布时间】:2015-10-17 03:51:02
【问题描述】:

我想使用蓝牙打印机 (Zebra) 从 MC75 [Windows mobile 6] 打印包含文本的收据。

我有这样的代码:工作正常。但我想改变我的打印格式

Private Sub SendZplOverBluetooth(ByVal theBtMacAddress As [String])
        Try

            Dim thePrinterConn As ZebraPrinterConnection = New BluetoothPrinterConnection(theBtMacAddress)
            thePrinterConn.Open()
            Dim zplData As [String] = "^XA^FO50,20^A0N,25,25^FD TestData.^FS^XZ"

            thePrinterConn.Write(Encoding.[Default].GetBytes(zplData))
            Thread.Sleep(500)

            thePrinterConn.Close()
        Catch e As Exception
            MsgBox("Error " & e.Message)
        End Try
    End Sub

这将打印“TestData”。我想让我的打印格式是这样的:

    Event Service
    ONsite Delivery

StandNo:

ITEM            Quantity
-------------------------
AB               1
BC               2
---------Nothing-----------
all goods are received
---------------------
Date : 

那么我该如何为此编写代码呢?感谢您的即时帮助。

提前致谢

【问题讨论】:

    标签: c# vb.net windows-mobile zebra-printers


    【解决方案1】:

    您可以尝试使用 Zebra Designer 生成主标签。打印并选择“文件”aß 输出。然后,您将在此文件中获取 zpl 代码。使用此代码,您可以随心所欲地工作和定制它。

    【讨论】:

      【解决方案2】:

      查看 ZPL II 编程指南,我建议使用 FieldBlock 运算符:

      ^FBw,l,, w=以点为单位的块宽度,l=块中的最大行数(其余可能的参数参见程序员指南)。 \& 开始一个新行

      在 ZPL II 中:

      ^XA
      ^CF0,30,30^FO25,50
      ^FB250,4,,
      ^FD
          Event Service\&
          ONsite Delivery\&
      \&
      StandNo:\&
      \&
      ITEM            Quantity\&
      -------------------------\&
      AB               1\&
      BC               2\&
      ---------Nothing-----------\&
      all goods are received\&
      ---------------------\&
      Date : ^FS
      ^XZ
      
      Dim zplData As [String] = "^XA^CF0,30,30^FO25,50^FB250,4,,^FD"
      zplData = zplData+"    Event Service\&"
      zplData = zplData+"    ONsite Delivery\&"
      zplData = zplData+"\&"
      ... 
      zplData = zplData+"^XZ"
      ...
      

      【讨论】:

      • 这是否涵盖可变数量的项目?
      • 这取决于... 您可以编写一个函数,该函数接受一个字符串数组,然后在构建 zplData 字符串时遍历该数组。您可能需要调整 ^FB 命令为块“保留”足够的行数(固定行数加上数组中的字符串数)。但这是非常基本的问题和解决方案。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-18
      相关资源
      最近更新 更多