Click here to Skip to main content
14,270,114 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,


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

bw.Write(AsciiControlChars.Escape).

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

bw.Write(AsciiControlChars.Escape+" . " +(byte)'!'+" . "+AsciiControlChars.Line);
bw.Write("hai");
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

Thanks

Thanks..
Posted
Updated 19-Aug-14 0:34am
v4

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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

Good luck!
   
Comments
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:
bw.Write(AsciiControlChars.Escape);
bw.Write('!');
bw.Write('.');
bw.Write(AsciiControlChars.Line');

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, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100