I have been using this class by @agraham to print on a Bluetooth thermal printer and it works great. Now my client is planning to get new printers with different paper sizes. Previously all printers were of the same paper size. Now with varying size, I am looking for a way to dynamically figure out the paper width or more specifically the number of characters that can be fit per line in an ESC/POS printer.
Why I need this is because I am trying to align some words in a line to the left and some to the right. As you know ESC/POS only lets you set alignment for the entire line. So to align words manually, I need to find the total number of characters that can be fit in a single line, subtract the character count of words in the line and fill the rest with empty spaces. For that, I need to find the maximum number of characters that can be fit in a single line.
Any idea how to do this?
Why I need this is because I am trying to align some words in a line to the left and some to the right. As you know ESC/POS only lets you set alignment for the entire line. So to align words manually, I need to find the total number of characters that can be fit in a single line, subtract the character count of words in the line and fill the rest with empty spaces. For that, I need to find the maximum number of characters that can be fit in a single line.
Any idea how to do this?