0

I need to send PDF label to A TD-2125NWB Brother printer from an Android App which is developped with the another_brother package (https://pub.dev/packages/another_brother)

I have already used this package to print PDF labels on a QL-820NWBc successfully.

My problem is that the package does not know the TD-2125NWB printer.

So i have fork package and add this lines to reference this model:

...
  static final MW_270 = Model._internal2("MW_270", 67, MW_260);
  static final PT_P715eBT = Model._internal2("PT_P715eBT", 69, PT_E550W);
  static final PT_P910BT = Model._internal(
      "PT_P910BT", 68, PT.W36.getId(), PrinterSeries.PT_LABEL_PRINTER);
  static final TD_2125NWB = Model._internal2("TD_2125NWB", 70, RJ_4030); // <== Add this line
  static final UNSUPPORTED = Model._internal("UNSUPPORTED", 255,
      PaperSize.CUSTOM.getPaperId(), PrinterSeries.UNSUPPORTED);
...

And

...
    MW_270,
    PT_P715eBT,
    PT_P910BT,
    TD_2125NWB, // <=== Add this line
    UNSUPPORTED
  ];
...

Code for Printing is:

brother.Printer printer = brother.Printer();
brother.PrinterInfo printInfo = brother.PrinterInfo();

printInfo.printerModel = brother.Model.TD_2125NWB;
printInfo.printMode = brother.PrintMode.FIT_TO_PAGE;
printInfo.isAutoCut = true;
printInfo.orientation = brother.Orientation.PORTRAIT;
printInfo.port = brother.Port.BLUETOOTH;
printInfo.align = brother.Align.CENTER;
printInfo.paperSize = brother.PaperSize.CUSTOM;

CustomPaperInfo customPaperInfo = CustomPaperInfo.newCustomRollPaper(
  printInfo.printerModel,
  Unit.Mm,
  50.0,
  0.0,
  0.0,
  0.0,
);

printInfo.customPaperInfo = customPaperInfo;

await printer.setPrinterInfo(printInfo);

List<brother.BluetoothPrinter> printers =
    await printer.getBluetoothPrinters(
  [
    brother.Model.TD_2125NWB.getName(),
  ],
);

printInfo.macAddress = printers.first.macAddress;

printer.setPrinterInfo(printInfo);

  final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(
    ui.ParagraphStyle(
      textAlign: TextAlign.center,
      fontSize: 12.0,
      fontWeight: FontWeight.w500,
    ),
  )
    ..pushStyle(Theme.of(context).textTheme.headlineMedium!.getTextStyle())
    ..addText(textToPrint);

  final ui.Paragraph paragraph = paragraphBuilder.build()
    ..layout(
      ui.ParagraphConstraints(
        width: MediaQuery.of(context).size.width - 12.0 - 12.0,
      ),
    );

  await printer.printText(paragraph);

When i try to send a printing job to the TD-2125NWB printer, nothing is printed and i get this error: ERROR_NOT_SAME_MODEL

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

Any idea ?

Alaindeseine
  • 3,260
  • 1
  • 11
  • 21

0 Answers0