I'm working with QZ tray to do raw printing with ESC/P (not ESC/POS) printer 9pin [1]. Basically everything works fine, until I have to set absolute horizontal position (ESC $).
the problem same with [2], but it use Java, and QZ tray using JavaScript for its example [3], and declare all the command using hexadecimal escape sequence (\xFF) [4], character from 0 - 255 (\x00 - \xFF).
here's detail about problem:
set absolute horizontal position in 9-pin ESC/P [1]
ASCII: ESC $ nL nH Hex: 1B 24 nL nH 0 <= nH <= 127 0 <= nL <= 255
send data to QZ tray without problem if nL value 0 to 127.
var data = [ '\x1B' + '\x40', // init '\x1B' + '\x24' + '\x10' + '\x00', // set horizontal '0x10' + '\x0D' + '\x0A', // print position ok '\x1B' + '\x24' + '\x7F' + '\x00', // set horizontal '0x7F' + '\x0D' + '\x0A', // print position ok '\x1B' + '\x24' + '\x80' + '\x00', // set horizontal '0x80' + '\x0D' + '\x0A', // print position PROBLEM '\x1B' + '\x24' + '\x00' + '\x01', // set horizontal '1x00' + '\x0D' + '\x0A', // print position ok ]
how to represent character 128 using hexadecimal escape sequence, if '\x80' + '\x00' was incorrect?
I tried to use JavaScript typed array Uint8Array and Uint16Array, not successfully printed, I think it's because the ESC/P protocol want it as characters (array).
I have tried to search on QZ groups and stackoverflow, but it is quite hard to find the correct keyword.
any help would be appreciated. thank you.
[1]https://files.support.epson.com/pdf/general/escp2ref.pdf
[2]ESC/P Set Absolute Horizontal Print Position
[3]https://qz.io/wiki/2.0-raw-printing
[4]https://mathiasbynens.be/notes/javascript-escapes#hexadecimal
Force
ISO-8859-1
encoding and use the raw hex object notation.Note, this is the same general answer as proposed by @oon-arfiandwi, but typed out in code.