首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何打印到热敏蓝牙打印机?

如何打印到热敏蓝牙打印机?
EN

Stack Overflow用户
提问于 2019-04-05 17:50:49
回答 1查看 1.6K关注 0票数 0

我用flutter开发了一个移动销售点,但我不知道如何在蓝牙热敏打印机上打印收据

我目前为它开发了一个插件,但它还不能工作

代码语言:javascript
复制
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();
        }
    }
}

源代码可以在here上找到

请帮我开发这个插件,至少它可以打印文本

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-22 14:35:21

我终于创建了我自己的插件

https://pub.dev/packages/blue_thermal_printer

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55532669

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档