Click here to Skip to main content
15,844,477 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i am trying to set font size with ESC/POS commands in c# by change it to hex value. use escape as


but not getting when i try to change font size using,

bw.Write(AsciiControlChars.Escape+" . " +(byte)'!'+" . "+AsciiControlChars.Line);
class as below,

namespace PurchaseDetailsPrint

public static class AsciiControlChars
public const char Escape = (char)0x1B;

public const char HorizontalTab = (char)0x09;

public const char Line = (char)0x38;


my printer is EPSON TM-T81 Receipt


Updated 19-Aug-14 1:34am

1 solution

You need to use an extra backslash. Have a look here:
Escaping in C#: characters, strings, string formats, keywords, identifiers[^]

Good luck!
Share this answer
E.F. Nijboer 19-Aug-14 9:56am    
What do you mean with (byte)'!'? Do you want to convert a byte to hex representation?
Try this:

byte b = Convert.ToByte('!');
String hex = b.ToString("x");

Try to check the results first to see if this is what you need. If you just want to add an exclamation (!) there is actually no reason to first convert it to byte at all, just add "!" directly.

It might also be easier to first write one byte at a time because it should matter. Something like:

Does this result in what you want?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900