How to send ESC/POS commands to a printer

How would I format ESC/POS commands to send to a printer so that I can get effects like bold, italic, underline, etc.?

Thanks
Steve

I don’t know the specific device being used here but I found this long list of commands for an Epson ESC/POS printer here, does your device have something similar?

It looks like if you can find the list in the documentation for the device, we could see how to send the commands for different types of formatting.

Ok, I have the codes for underline which are 1B 2D 01 to turn on and 1B 2D 00 to turn off.

Have tried this but it doesn’t work. I am doing this correctly??

Thanks
Steve

You may need to add in a another empty string between each each number or add a space after 1B and 2D since as it is now, this would print out as 1B2D01.