neodynamic / JSPrintManager

Advanced Client-side Printing & Scanning Solution for Javascript
https://www.neodynamic.com/products/printing/js-print-manager/
248 stars 137 forks source link

Turkish Characters not printing correctly for dot-matrix printer. #6

Closed Mura7 closed 5 years ago

Mura7 commented 5 years ago

Hi, We try to print with Turkish characters but can not printing correctly for dot-matrix printer.

We try also text convert to ASCII code but still not working. Can you help us for this?

WhatsApp Image 2019-07-30 at 17 30 00

neodynamic commented 5 years ago

Which commands have you specified and how?

Mura7 commented 5 years ago

We already use webclientprint 2.0 and we can print correctly so i think printer settings is correct.

Our codes.

const cpj = new JSPM.ClientPrintJob()
cpj.clientPrinter = new JSPM.InstalledPrinter(printerName)
// cpj.printerCommands = '\xef\xbb\xbf' + command

let cmds = [
  String.fromCharCode(27)
  , String.fromCharCode(50)
  , String.fromCharCode(65)
  , String.fromCharCode(66)
  , String.fromCharCode(67)
  , String.fromCharCode(68)
  , String.fromCharCode(69)
  , String.fromCharCode(70)
  , String.fromCharCode(128)
  , String.fromCharCode(129)
  , String.fromCharCode(135)
  , String.fromCharCode(148)
  , String.fromCharCode(152)
  , String.fromCharCode(153)
  , String.fromCharCode(154)
  , String.fromCharCode(158)
  , String.fromCharCode(159)
  , String.fromCharCode(166)
  , String.fromCharCode(167)
].join('')

cmds += '\n\r'

cmds += "ABCDEFÇüçöiÖÜŞiĞğ"

console.log(cmds, command)
cpj.printerCommands = '\n\n\r' + cmds
neodynamic commented 5 years ago

This string "ABCDEFÇüçöiÖÜŞiĞğ" will be converted to bytes based on UTF-8 code page and that's not what the printer will expect. So, convert each of those Turkish chars to their correct hex byte values based on the Turkish Codepage e.g. try this instead

cmds += "ABCDEF\x80\x81\x87\x94i\x99\x9A\x9Ei\xA6\xA7"

Mura7 commented 5 years ago

Thank you for your interest. Solved. We updated to the new version (2.0.1). Converted to hex code.