Closed FractalMind closed 3 years ago
Ok, I got it!
After passing a day analyzing the code.
There are 2 encoding processes.
1- Object to json with: this.printService.submit()
Don't worry about that it's automatic.
2- Base64 to bytes: byte[] bytes = Base64.decodeBase64(printDocument.getRawContent());
You must encode your ESC/POS commands UInt8Array to base64. And it's very picky on what type of encoder works. I find that this one: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727 works well.
this.printService.submit({
'type': 'INVOICE',
'raw_content': bytesToBase64(escposCommands)
});
A TS version is available.
Also very important de "type" in 'type': 'INVOICE'
is actually the NAME of the printer configured in the "Configurator" not the TYPE. Which is very ambiguous. Make sure it matches your printer.
hello we have a similar issue, the barcode and the image are printing on the same line as "This is a BIG text", is this is a coding issue? We are using the star SP700 printer.
I know the JSESCPOSBuilder ESCPOS commands are right because it works flawlessly with Ionic Native BluetoothSerial
I tried
JSON.stringify(escposCommands)
But I got :So now I use TextDecoder() and I get:
On the demo: /demo/printer-basic.htm The RAW printer demo don't work with the same error.
Any idea how to send the raw ESC/POS commands?
Thank you for your time