POS for .Net print formatting - can't use escape character (char)27

后端 未结 7 2058
不思量自难忘°
不思量自难忘° 2021-01-26 04:03

I figured out how to print basic text to our POS printer, but I can\'t figure out how to get the escape characters to work (for bold, text alignment, etc). For now I\'m just tes

7条回答
  •  梦毁少年i
    2021-01-26 04:20

    Hi just found out this answer and this works for me. try this one.

    string Bold = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'b', (byte)'C' });
    

    or You can simply declare this:

     string ESC = System.Text.ASCIIEncoding.ASCII.GetString(new byte[] {27});
    

    then use it in your format or text like this:

    ESC + "|cA" -- this is for center. ESC + "|bC" -- for bold.

    ESC + "|bC" + "hello world" -- this will bold the string.

提交回复
热议问题