是否有人在flutter中使用blue_thermal_printer成功将图像打印到zebra蓝牙打印机?

时间:2019-12-31 02:55:04

标签: android flutter dart bluetooth thermal-printer

我想将条形码打印到我的zebra蓝牙打印机上,但是我唯一的建议是使用图像打印条形码,但是打印机发出哔哔声无法打印任何内容。

  String pathImage;

  initSavetoPath()async{
    //read and write
    //image max 300px X 300px
    final filename = 'yourlogo.png';
    var bytes = await rootBundle.load("assets/images/yourlogo.png");
    String dir = (await getApplicationDocumentsDirectory()).path;
    writeToFile(bytes,'$dir/$filename');
    setState(() {
      pathImage='$dir/$filename';
      sample(pathImage);
    });
  }


//triggerd on button pressed
sample(String pathImage) async {
    bluetooth.isConnected.then((isConnected) {
      if (isConnected) {
        bluetooth.printNewLine();
        bluetooth.printCustom("barcode Sample",3,0);
        bluetooth.printNewLine();
        bluetooth.printImage(pathImage);

    });
  }

0 个答案:

没有答案