用于CPCL语言的Zebra打印代码示例(其他然后是TEST示例)

时间:2017-02-06 12:55:32

标签: android-bluetooth zebra

exceptions   =>   [
                    'regex1',
                    'regex2',
                    'regexN',
                  ],

这些行附带Zebra测试演示代码,我对CPCL语言和相应的命令不太满意,例如

String cpclConfigLabel = "! 0 200 200 406 1\n" + "ON-FEED IGNORE\n" + "BOX 20 20 10 10 8\n" + "T 0 6 137 177 TEST\n" + "PRINT\n";

如何从此打印命令获取字节,因此,任何人都可以提出一些建议如何使用CPCL打印收据命令?

赞赏你的努力。

2 个答案:

答案 0 :(得分:1)

我有一份你可以研究的好文件,它有很多例子, 请在1找到该文档,请查看我用于打印收据的示例:

! 0 200 200 600 1
PCX 0 1 !<B.PCX
T 0 4 1 125  Paid: 5 $
T 5 0 125 160        Date: 12/12/2012
T 5 0 125 179        Time: 12:12
T 5 0 125 217        User: AAA
T 5 0 125 236        Details
T 5 0 125 255        Card Price: 2
T 5 0 125 274        Balance: 3
T 5 0 25 293             Thank you 
T 5 0 40 312                   www.aa.aa.aa
FORM
PRINT

此命令PCX 0 1 !<B.PCX用于打印在打印机上下载的徽标。 其余的是TEXT命令。

希望这有帮助。

答案 1 :(得分:0)

为时已晚,但我想回答这个问题。也许有人需要这个。

这里是文档 CPCL Programming Language Documentation

签出。

您准备好收据,然后必须对打印机进行粉碎。

这是Xamarin.Android示例:

public override Task<int> Print(byte[] command)
    {
        return Task.Run(async () =>
        {
            if (string.IsNullOrEmpty(DeviceName))
                return -1;

            using BluetoothAdapter bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
            BluetoothDevice device = (from bd in bluetoothAdapter?.BondedDevices
                                      where bd?.Name == DeviceName
                                      select bd).FirstOrDefault();

            if (device == null)
                throw new Exceptions.PrinterException("Device Not Found!", new NullReferenceException());

            try
            {
                using BluetoothSocket bluetoothSocket = device.CreateRfcommSocketToServiceRecord(
                    //UUID.FromString(Guid.NewGuid().ToString())
                    UUID.FromString("00001101-0000-1000-8000-00805f9b34fb")
                    );
                if (!bluetoothSocket.IsConnected)
                    await bluetoothSocket.ConnectAsync();

                bluetoothSocket.OutputStream.Flush();
                await bluetoothSocket.OutputStream.WriteAsync(command, 0, command.Length);
                bluetoothSocket.OutputStream.Flush();
                bluetoothSocket.Close();
                return 1;
            }
            catch (Exception exp)
            {
                throw new Exceptions.PrinterException("An error occurred.", exp);
            }
        });
    }

使用:

string receipt = Encoding.ASCII.GetBytes(YourReceiptAsString);
await Print(receipt);

我希望这会帮助某人。 保重!