ESC POS 言語を使用してサーマル プリンターでチケットを印刷できるアプリがあります。私が現在使用しているコードは次のとおりです。
/* <-40char-> */
Socket sock = new Socket(Impresora.getImpresora_Tickets().getIp(), Impresora.getImpresora_Tickets().getPuerto());
OutputStreamWriter osw = new OutputStreamWriter(sock.getOutputStream(), Charset.forName("CP1252"));
PrintWriter oStream = new PrintWriter(osw);
/*Start*/
for(int i = 0; i<Impresora.getImpresora_Tickets().getInic().size(); i++)
oStream.print(Impresora.getImpresora_Tickets().getInic().get(i));
/*Set Font Size*/
for(int i = 0; i<Impresora.getImpresora_Tickets().getLetra4().size(); i++)
oStream.print(Impresora.getImpresora_Tickets().getLetra4().get(i));
oStream.println("HELLO WORLD");
そして、それはうまくいきます。問題は、タブレットでユーザーの署名を取得していて、それをチケットの最後に印刷したいということです。ビットマップ オブジェクトとして持っていますが、プリンターに送信する方法がわかりません。誰かが私を助けることができますか?ありがとう!
編集1:
何かをしようとしているのですが、うまくいかないと思います...
/**
* Redimensionar imagen
*/
Bitmap firma = Current_Mesa.getT().getFirma_credito();
firma = Bitmap.createScaledBitmap(firma, 255, 64, false);
/**
* Print imagen
*/
ByteArrayOutputStream stream = new ByteArrayOutputStream();
firma.compress(CompressFormat.JPEG, 70, stream);
byte[] firma_bytes = stream.toByteArray();
byte[] SELECT_BIT_IMAGE_MODE = {0x1B, 0x2A, 33};
byte[] SET_LINE_SPACE_24 = {0x1B, 0x33, 24};
byte[] PRINT_AND_FEED_PAPER = new byte[]{0x0A};
for(byte b : SELECT_BIT_IMAGE_MODE)
oStream.print((char)b);
for(byte b : SET_LINE_SPACE_24)
oStream.print((char)b);
for(int i = 0; i < firma_bytes.length; i+=8)
{
for(int plus = 0; plus < 8; plus++)
oStream.print(firma_bytes[i+plus]);
for(byte b : PRINT_AND_FEED_PAPER)
oStream.print((char)b);
}