我有一个应用程序,可以使用 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);
}