2017-03-07 1 views
1

私はcordovaを使用してハイブリッドアプリケーションを開発しています。私はアンドロイド版でアラビア語のテキストでzplのコンテンツを印刷することができます。しかし、同じzplコードはios版では動作しません。プリンタが信号を受信し、青色のライトが点滅します。コンテンツにアラビア語のテキストがある場合は印刷されません。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

次のように1ヶ月以上苦労した後、最終的にする問題の解決策を見つけた:

あなたのコードを追加

//-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私たちはZPLにHTMLを変換できますか? – ArgaPK

関連する問題