Android Question Aligment center in printer

fifiddu70

Well-Known Member
Licensed User
Longtime User
hello, i have a problem when printer text, the text is left printer mode, i need to center aligment mode when print my document, is possible?
 

KMatle

Expert
Licensed User
Longtime User
Do you mean a POS receipt printer? I checked the ESC commands. It seems there is no "center" sequence. So just check how many chars it prints in one row (e.g. 40) and calculate the "center" depending on the lenght of the line you need to print.

If you need to print "Hello" then it's like this:

B4X:
40 / 2 = 20
"Hello".length = 5
5/2 = 2.5
20 - 2.5 = 18 (rounded)
Text2Print = 18 spaces & "Hello" 
Print
 
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
I am using a ZJ-5802LD ESC/POS printer and these codes work for me. As I only own one model, don't know if they are "ESC standard" or only for that model

B4X:
   Dim ESC_JUSTIFY_LEFT  As String = Chr(27)&"a"&Chr(0)    
   Dim ESC_JUSTIFY_CENTER As String = Chr(27)&"a"&Chr(1)
   Dim ESC_JUSTIFY_RIGHT  As String = Chr(27)&"a"&Chr(2)
   
   Dim ESC_FORMAT_NORMAL  As String = Chr(27)&"!"&Chr(0)
   Dim ESC_FORMAT_DWIDTH As String = Chr(27)&"!"&Chr(0x28)
 
Upvote 0
Top