簡體   English   中英

如何打印到熱藍牙打印機?

[英]How can i print to thermal bluetooth printer?

我開發了一個帶有顫動的移動銷售點,但我不知道如何在藍牙熱敏打印機上打印收據

我目前正在為它開發一個插件,但它還沒有用

protected void printBill() {
       if(btsocket == null){
          btsocket = DeviceList.getSocket();
          Intent BTIntent = new Intent(getApplicationContext(),        DeviceList.class);
          this.startActivityForResult(BTIntent, DeviceList.REQUEST_CONNECT_BT);
        Toast.makeText(activity,"tes",Toast.LENGTH_LONG).show();
    }
    else{
        OutputStream opstream = null;
        try {
            opstream = btsocket.getOutputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
        outputStream = opstream;

        //print command
        try {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            outputStream = btsocket.getOutputStream();
            byte[] printformat = new byte[]{0x1B,0x21,0x03};
            outputStream.write(printformat);


            printCustom("Fair Group BD",2,1);
            printCustom("Pepperoni Foods Ltd.",0,1);
            printCustom("H-123, R-123, Dhanmondi, Dhaka-1212",0,1);
            printCustom("Hot Line: +88000 000000",0,1);
            printCustom("Vat Reg : 0000000000,Mushak : 11",0,1);
            String dateTime[] = getDateTime();
            printText(leftRightAlign(dateTime[0], dateTime[1]));
            printText(leftRightAlign("Qty: Name" , "Price "));
            printCustom(new String(new char[32]).replace("\0", "."),0,1);
            printText(leftRightAlign("Total" , "2,0000/="));
            printNewLine();
            printCustom("Thank you for coming & we look",0,1);
            printCustom("forward to serve you again",0,1);
            printNewLine();
            printNewLine();

            outputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

源代碼可以在這里找到

請幫我開發這個插件,至少它可以打印文本

我終於創建了自己的插件

https://pub.dev/packages/blue_thermal_printer

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM