2017-03-07 6 views
1

cordova를 사용하여 하이브리드 응용 프로그램을 개발 중입니다. 나는 안드로이드 버전에서 아랍어 텍스트로 zpl 콘텐츠를 인쇄 할 수 있습니다. 하지만 동일한 zpl 코드는 ios 버전에서 작동하지 않습니다. 프린터가 신호를 받고 파란색 표시등이 깜박입니다. 그러나 내용이 아랍어 텍스트를 가지고있을 때는 인쇄되지 않습니다.cordova를 사용하여 ios에서 아랍어 텍스트가 포함 된 zpl 컨텐츠로 imz320에 인쇄

Zebra iMZ320 프린터를 사용하고 있습니다. 당신은 ios를위한 아랍어 컨텐츠와 함께 동일한 예제를 공유 할 수 있습니까? 다음과 같이

var TestPrint = "^XA^FO50,50^[email protected]:TT0003M_.TTF,N,50,50^FD"+"الفئة الرابعة عشر"+"^FS ^XZ"; 
 
//-- "ÙحاÙÙØ©" 
 
localStorage.iosConnected_ZebraPrinter_Name = 'XXXXJ142401535'; 
 
window.plugins.CordovaPrinter.print(
 
    function (success) { // Call the print method 
 
     console.log('Platform : ios, Successfully printed...' 
 
        + '\n thru. ',localStorage.iosConnected_ZebraPrinter_Name); 
 
     }, 
 
    function error(err) { 
 
     console.log('Error Printing to ' + localStorage.iosConnected_ZebraPrinter_Name); 
 
     console.log(err); 
 
    }, 
 
    localStorage.iosConnected_ZebraPrinter_Name, //serialArray[0], 
 
    TestPrint);

+0

코드를 추가 당신을 시도는 사람들이 대답하는 데 도움이됩니다. – Purus

+0

의견을 보내 주셔서 감사합니다 - Purus, 지금 코드를 공유했습니다 –

+0

콘솔에 오류 로그가 있습니까? – Purus

답변

0

개월 이상 고민 한 후, 마지막으로이 문제에 대한 해결책을 발견 :

//-ARABIC TEXT ENCODING - FOR IOS--------------------------- 
 
/*-----String to utf-8 encoded hex-----*/ 
 
function toHex(str,hex){ 
 
    try{ 
 
    //We have appended '-', because, you need to prefix the utf-8 hex code with an underscore, to be printed in ZPL 
 
    hex = '_' + unescape(encodeURIComponent(str)) 
 
    .split('').map(function(v){ 
 
     return v.charCodeAt(0).toString(16) 
 
    }).join('_') 
 
    } 
 
    catch(e){ 
 
    hex = str 
 
    console.log('invalid text input: ' + str) 
 
    } 
 
    return hex 
 
} 
 
//-EXAMPLE : console.log('toHex of ' + str + ' is : ' + toHex(str, 16)); 
 

 
//---------------------------------------------------------- 
 
var TestPrint = "^XA" + 
 
"^LH100,150" + 
 
"^CWT,E:TT0003M_.FNT" + 
 
"^CFT,30,30" + 
 
"^CI28" + 
 
"^FT0,0^FH^FDTesting 1 2 3...^FS" + 
 
"^FT0,50^FH^FD" +toHex(str, 16)+ "^FS" + 
 
"^FT0,100^B3^FDAAA001^FS" + 
 
"^XZ" ; 
 
console.log('TestPrint : ', TestPrint); 
 

 
localStorage.iosConnected_ZebraPrinter_Name = 'XXXXJ142401535'; 
 
window.plugins.CordovaPrinter.print(
 
    function (success) { // Call the print method 
 
     console.log('Platform : ios, Successfully printed...' 
 
        + '\n thru.', localStorage.iosConnected_ZebraPrinter_Name); 
 
     }, 
 
    function error(err) { 
 
     console.log('Error Printing to ' + localStorage.iosConnected_ZebraPrinter_Name); 
 
     console.log(err); 
 
    }, 
 
    localStorage.iosConnected_ZebraPrinter_Name, //serialArray[0], 
 
    TestPrint);

+0

@SSUBHAHARAN 우리는 HTML을 ZPL로 변환 할 수 있습니까? – ArgaPK