Android Question How to find out paper width for an ESC/POS printer?

Inman

Well-Known Member
Licensed User
Longtime User
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?
 

mc73

Well-Known Member
Licensed User
Longtime User
Not aware of such command.
You can of course, add a settings section for printers, defining their page width.
Alternatively, you can upon their "setup", download their info page (assuming they're connected to your network) and search in the html received for their width (for e.g. by searching 58 and 80). But not sure if this worths the effort. I would personally go for the first suggestion.
 
Upvote 0

emexes

Expert
Licensed User
A lot of ESC/POS printer manuals talk of a GS I n transmit printer ID command. Sadly, it doesn't seem to explicitly return the printer width; you'd have to work that out yourself from the other info that *is* provided, eg printer manufacturer and model name.

1602157416748.png
 
Upvote 0
Top