weixin_39518678
weixin_39518678
2020-12-09 02:19

Barcode Support

I have been trying and customizing the code for printing barcode. I could not succeed in developing a proper solution.

 php
<?php /* ASCII constants */
const ESC = "\x1b";
const GS="\x1d";
const NUL="\x00";

/* Output an example receipt */
echo ESC."@"; // Reset to defaults
echo GS."k".chr(4)."123123".NUL; // Print barcode
echo ESC."d".chr(1); // Blank line
exit(0);
code>

How should the above code be translated to go. I am missing something. I tried placing \x04 instead of 4 in middle. But it just prints empty line.

 go
//barcode is string
func (e *Escpos) PrintBarcode(barcode string, format string) {
    e.Write(fmt.Sprintf("\x1dk4%v\x00", barcode))
}

该提问来源于开源项目:kenshaw/escpos

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

5条回答

为你推荐