如何在EPSON Printer中打印条形码和剪切页面ESC / POS命令?

时间:2017-10-06 10:09:18

标签: c# thermal-printer epson escpos

我正面临使用POS命令

的2个问题

对于POS Command,我使用从Nuget下载的dll: PrinterUtility

PrinterUtility.EscPosEpsonCommands.EscPosEpson

  

1)条形码不会打印字母数字字符   在此,

PrinterUtility.EscPosEpsonCommands.EscPosEpson obj = new PrinterUtility.EscPosEpsonCommands.EscPosEpson();

var ByteValue = PrintExtensions.AddBytes(ByteValue,obj.BarCode.Code128("454541234"));

它只接受数字值而非字母数字,所以我用另一种方式使用下面的代码生成条形码,但不生成条形码。

public byte[] BarcodeGenrate(string BarcodeNO)
        {
            string GS = "\u001D";
            string ESC = Convert.ToString((char)27);
            string COMMAND = "";
            COMMAND = GS + "h" + 50;//Set barcode height
            COMMAND += GS + "H" + 2; //Select print position of HRI characters: 
            COMMAND += GS + "f" + 1; //Select font for HRI characters:
            COMMAND += GS + "k" + 4 + BarcodeNO + 0; //Print barcode: (A) format, barcode system = CODE39
            var result = System.Text.Encoding.Unicode.GetBytes(COMMAND);
            return result;

        }
  

2)剪切页面:这也不起作用

 public byte[] CutPage()
        {
            string GS = Convert.ToString((char)29);
            string ESC = Convert.ToString((char)27);
            string COMMAND = "";
            COMMAND = ESC + "@";
            COMMAND = GS + "V" + (char)1;
            var result = System.Text.Encoding.Unicode.GetBytes(COMMAND);
            return result;

        }

请帮我用ESC / POS命令生成条码Code128和CutPage命令

2 个答案:

答案 0 :(得分:0)

一种解决方案如下所示:

private byte[] CutPage() {
    List<byte> oby = new List<byte>();
    oby.Add(Convert.ToByte(Convert.ToChar(0X1D)));
    oby.Add(Convert.ToByte('V') 
    oby.Add((byte)66);
    oby.Add((byte)3);

    return oby.ToArray();
}

答案 1 :(得分:-1)

var BytesValue;
BytesValue = PrintExtensions.AddBytes(BytesValue, obj.BarCode.Code128("12345"));