2016-04-15 6 views
0

edittextに英語のテキストを入力すると、Android-Bluetooth-Printer .itがうまく動作しますが、ソフトキーボードからヒンディー語を選択して印刷しますが、紙には何も表示されません。Bluetoothプリンタを使用してヒンディー語やグジャラート語のフォントを表示するには?

public class BlueToothPrinterApp extends Activity  
{  

    EditText message; 
    Button printbtn; 

    byte FONT_TYPE; 
    private static BluetoothSocket btsocket; 
    private static OutputStream btoutputstream; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     message = (EditText)findViewById(R.id.message); 
     printbtn = (Button)findViewById(R.id.printButton); 

     printbtn.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       connect(); 
      } 
     }); 
    } 

    protected void connect() { 
     if(btsocket == null){ 
      Intent BTIntent = new Intent(getApplicationContext(), BTDeviceList.class); 
      this.startActivityForResult(BTIntent, BTDeviceList.REQUEST_CONNECT_BT); 
     } 
     else{ 

      OutputStream opstream = null; 
      try { 
       opstream = btsocket.getOutputStream(); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } 
      btoutputstream = opstream; 
      print_bt(); 

     } 

    } 


    private void print_bt() { 
     try { 
      try { 
       Thread.sleep(1000); 
      } catch (InterruptedException e) { 
       e.printStackTrace(); 
      } 

      btoutputstream = btsocket.getOutputStream(); 

      byte[] printformat = { 0x1B, 0x21, FONT_TYPE }; 
      btoutputstream.write(printformat); 
      String msg = message.getText().toString(); 
      btoutputstream.write(msg.getBytes()); 
      btoutputstream.write(0x0D); 
      btoutputstream.write(0x0D); 
      btoutputstream.write(0x0D); 
      btoutputstream.flush(); 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 

    } 

    @Override 
    protected void onDestroy() { 
     super.onDestroy(); 
     try { 
      if(btsocket!= null){ 
       btoutputstream.close(); 
       btsocket.close(); 
       btsocket = null; 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     try { 
      btsocket = BTDeviceList.getSocket(); 
      if(btsocket != null){ 
       print_bt(); 
      } 

     } catch (Exception e) { 
      e.printStackTrace(); 
     } 
    } 
}   

いずれか1人でこれを手伝ってもらえますか?

+0

あなたが(PCL、ESC/POS、ZPLなど)。画像へのあなたの出力を変換しようとすると、プリンタが理解エミュレーションを使用してバイトとしてプリンタに送ることができ、これを解決するために

は、あなたはこれを達成しています。私も同じことが必要です。 – Murali

+0

@ムラリはい、ちょうど与えられた答えで試してください –

+0

私は画像の印刷を試みました。しかし、プリンタがスタックオーバーフローに落ちます。可能であれば、あなたの作業コードを投稿してください。 – Murali

答えて

1

プリンタには、事前定義された文字セットが組み込まれています。これらの文字セットはcode pagesとして知られています。

あなたのBluetoothプリンタは、ほとんどのPOSプリンタと同様に、Unicodeをサポートしていないようです。

関連する問題