mtmsuhail / ESC-POS-USB-NET

This project is a simple .NET (C#) Implementation of the Epson ESC/POS Printing using USB Device Driver.
MIT License
202 stars 86 forks source link

How to ESC/POS raw printing right and left alignment #50

Open shifasks opened 2 years ago

shifasks commented 2 years ago

How to acheive like this.. https://user-images.githubusercontent.com/1809727/28242377-acfeb5de-69c7-11e7-802d-aab5f9d176bf.JPG

means...row wise printing with left ,center and right alighnment

phillmorgan28 commented 2 years ago

I padded each "column" to a fixed with with PadRight() for the first two, and then PadLeft() for the last column to make it right aligned. You have to make sure all of your Pad functions add up to the number of characters per line. For example:

string row = sku.PadRight(9) + " " + description.PadRight(28) + " " + price.PadLeft(9) This would equal 48 character width.

It is also worth truncating each column to the maximum characters for each column too as the Pad functions will not trim characters off the end for you.