CodeMinion / another_brother

Another Brother Flutter SDK
BSD 3-Clause "New" or "Revised" License
21 stars 22 forks source link

Issue : ERROR_PRINTER_SETTING_NOT_SUPPORTED #55

Closed anchals333 closed 1 year ago

anchals333 commented 1 year ago

Hi, I'm using another_brother: ^0.0.34. My printer is QL-820NWB. I'm getting an error that printer settings not supported. Can you let me know what I'm doing wrong. Here is my code :

void printVisitor() async {
    try {
      var printer = Printer();
      var printInfo = PrinterInfo();
      printInfo.printerModel = Model.QL_820NWB;
      printInfo.printMode = PrintMode.ORIGINAL;
      printInfo.isAutoCut = true;
      printInfo.port = Port.NET;
      printInfo.paperSize = PaperSize.CUSTOM;
      printInfo.customPaperWidth = 60;
       printInfo.customPaperLength = 100;
      // printInfo.binCustomPaper = BinPaper_RJ2050.RD_W58mm;
      printInfo.customPaperInfo = CustomPaperInfo.newCustomDiaCutPaper(Model.QL_820NWB, Unit.Mm,
          60, 90, 0, 0, 0, 0, 0);
      // printInfo.pap
      // Set the label type.
      printInfo.labelNameIndex = 15;
      // Set the printer info so we can use the SDK to get the printers.
      await printer.setPrinterInfo(printInfo);
      // Get a list of printers with my model available in the network.
      List<NetPrinter> printers = await printer.getNetPrinters([Model.QL_820NWB.getName()]);
      if (printers.isEmpty) {
        // Show a message if no printers are found.
        ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
          content: Padding(
            padding: EdgeInsets.all(8.0),
            child: Text("No printers found on your network."),
          ),
        ));
       return;
      }
      // Get the IP Address from the first printer found.
      printInfo.ipAddress = printers.first.ipAddress;
      Utils.printLog(message: "Printer found : ${printers.first.ipAddress}");
      printer.setPrinterInfo(printInfo);
      PrinterStatus status = await printer.printImage(await loadImage());
      Utils.printLog(message: "Printer status : ${status.toMap()}");
      Utils.printLog(message: "Printer info : ${printInfo.toMap()}");
    } catch (e) {
      Utils.printLog(message: "Printer Error : ${e.toString()}");
    }
  }

My printer result :

{
  labelType: -1,
  maxOfBatteryResidualQuantityLevel: -1,
  labelId: -1,
  isACConnected: {
    id: -1,
    name: Unknown
  },
  batteryResidualQuantityLevel: -1,
  isBatteryMounted: {
    id: -1,
    name: Unknown
  },
  batteryLevel: -1,
  errorCode: {
    name: ERROR_PRINTER_SETTING_NOT_SUPPORTED,
    id: -1
  }
}

My printer info :

{
  printerModel: {
    id: 53,
    name: QL_820NWB
  },
  port: {
    id: 4,
    name: NET
  },
  ipAddress: 10.101.11.22,
  macAddress: ,
  localName: ,
  lastConnectedAddress: ,
  paperSize: {
    id: 254,
    name: CUSTOM
  },
  orientation: {
    id: 1,
    name: PORTRAIT
  },
  numberOfCopies: 1,
  halftone: {
    id: 2,
    name: PATTERNDITHER
  },
  printMode: {
    id: 1,
    name: ORIGINAL
  },
  align: {
    id: 1,
    name: LEFT
  },
  valign: {
    id: 1,
    name: TOP
  },
  margin: {
    top: 0,
    left: 0
  },
  pjCarbon: false,
  pjDensity: 5,
  pjFeedMode: {
    id: 2,
    name: PJ_FEED_MODE_FIXEDPAGE
  },
  customPaperWidth: 60,
  customPaperLength: 100,
  customFeed: 0,
  rjDensity: 0,
  rotate180: false,
  peelMode: false,
  mirrorPrint: false,
  paperPosition: {
    id: 2,
    name: CENTER
  },
  isAutoCut: true,
  isCutAtEnd: true,
  mode9: true,
  skipStatusCheck: false,
  checkPrintEnd: {
    id: 3,
    name: CPE_CHECK
  },
  rollPrinterCase: {
    id: 1,
    name: PJ_ROLLCASE_OFF
  },
  pjSpeed: 2,
  thresholdingValue: 127,
  timeout: {
    processTimeoutSec: -1,
    sendTimeoutSec: 90,
    receiveTimeoutSec: 180,
    closeWaitMSec: 500,
    connectionWaitMSec: 500,
    closeWaitDisusingStatusCheckSec: 3
  },
  dashLine: false,
  savePrnPath: ,
  overwrite: true,
  isHalfCut: false,
  isSpecialTape: false,
  labelNameIndex: 15,
  customPaper: ,
  binCustomPaper: null,
  customPaperInfo: {
    printerModel: {
      id: 53,
      name: QL_820NWB
    },
    paperKind: {
      name: DIE_CUT
    },
    unit: {
      name: Mm
    },
    tapeWidth: 60.0,
    tapeLength: 90.0,
    rightMargin: 0.0,
    leftMargin: 0.0,
    topMargin: 0.0,
    bottomMargin: 0.0,
    labelPitch: 0.0,
    markPosition: 0.0,
    markHeight: 0.0
  },
  isLabelEndCut: false,
  printQuality: {
    id: 2,
    name: NORMAL
  },
  labelMargin: 0,
  scaleValue: 1.0,
  isCutMark: false,
  softFocusing: false,
  trimTapeAfterData: false,
  enabledTethering: false,
  rawMode: false,
  workPath: ,
  pjPaperKind: {
    id: 2,
    name: PJ_CUT_PAPER
  },
  useLegacyHalftoneEngine: false,
  banishMargin: false,
  useCopyCommandInTemplatePrint: false,
  labelName: {
    id: 16,
    name: W62,
    model: QL700
  }
}
anchals333 commented 1 year ago

This has been resolved, it was the issue of size of image.

CodeMinion commented 1 year ago

Thanks for sharing this @anchals333 !