English 中文(简体)
I m 无法使用另一个代兄弟图书馆,使用DL-810W打印机打印62毫米×29毫米标签
原标题:I m unable to print a 62mm x 29mm label using the another_brother library with a Brother QL-810W printer

I m与另一个能够打印产品标签的兄弟一道开发一个仪器。 所需标识尺寸为62毫米×29毫米。 经过一些研究,我认为这个问题与印刷商Info的“labelNameIndex”有关。 当我把NameIndex贴上17个标签时,该标签是用的,但并没有将标签长度固定在29毫米。 时间长短取决于内容。 我还发现,当“NameIndex”被定为8个,相当于62毫米×29毫米的面积时,它回去了以下错误:

{labelType:-1, maxOfBatteryResidual Quantity: -1, 标签Id:-1, ACConnected:{id:-1, 姓名:不明}, 电池Residual Quantity 级别:-1, isBatteryMounted:{id:-1, name:ident}, celllevel: -1, 错误Code:{名称: ERROR_WRONG_LABEL, id: -1, >

void printResult(
 BuildContext context, {
 required PrintModel model,
}) async {
 if (selectedPrinter.value == null) {
   ToastUtils.show(StringStyles.printerNotReady.tr);
 }
 EasyLoading.show(status: StringStyles.printing.tr);
 var printer = Printer();
 var printInfo = PrinterInfo();
 printInfo.printerModel = Model.QL_810W;
 printInfo.printMode = PrintMode.FIT_TO_PAGE;
 printInfo.isAutoCut = false;
 printInfo.port = Port.NET;
 printInfo.paperSize = PaperSize.CUSTOM;
 // printInfo.customPaperLength = 29;
 // printInfo.customPaperWidth = 62;
 printInfo.printQuality = PrintQuality.HIGH_RESOLUTION;
 printInfo.labelNameIndex = 8;


 // 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_810W.getName()]);


 if (printers.indexWhere((element) =>
         element.macAddress == selectedPrinter.value?.macAddress) ==
     -1) {
   EasyLoading.dismiss();
   ToastUtils.show(StringStyles.printerDisconnected.tr);
   getMyNetworkPrinters();


   return;
 }
 // Get the IP Address from the first printer found.
 printInfo.ipAddress = printers.single.ipAddress;


 printer.setPrinterInfo(printInfo);


 var totalNum = 0;
 for (var element in model.products) {
   var num = int.parse(element.num);
   totalNum += num;
 }


 var index = 1;


 for (var element in model.products) {
   var num = int.parse(element.num);
   for (int i = 0; i < num; i++) {
     final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(
       ui.ParagraphStyle(
         textAlign: TextAlign.left,
         fontSize: 20,
         textDirection: TextDirection.ltr,
       ),
     )
       ..pushStyle(ui.TextStyle(color: Colors.black, fontSize: 16))
       ..addText( James ${model.phoneNumber}
 )
       ..pushStyle(ui.TextStyle(color: Colors.black, fontSize: 16))
       ..addText( App Order
 )
       ..pushStyle(ui.TextStyle(color: Colors.black, fontSize: 20))
       ..addText( To-Go #${model.orderNumber} ($index of $totalNum)
 )
       ..pushStyle(ui.TextStyle(color: Colors.black, fontSize: 20))
       ..addText( ${element.title}
 )
       ..pushStyle(ui.TextStyle(color: Colors.black, fontSize: 16))
       ..addText(element.tag);


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


     await printer.printText(paragraph);
     index++;
   }
 }
 EasyLoading.dismiss();
}

Here, I show the labelNameIndex and the corresponding size.

class QL700 implements ALabelName {
 final int _id;
 final String _name;
 static const String _model = "QL700";


 const QL700._internal(this._id, this._name);


 static const W17H54 = const QL700._internal(1, "W17H54");
 static const W17H87 = const QL700._internal(2, "W17H87");
 static const W23H23 = const QL700._internal(3, "W23H23");
 static const W29H42 = const QL700._internal(4, "W29H42");
 static const W29H90 = const QL700._internal(5, "W29H90");
 static const W38H90 = const QL700._internal(6, "W38H90");
 static const W39H48 = const QL700._internal(7, "W39H48");
 static const W52H29 = const QL700._internal(8, "W52H29");
 static const W62H29 = const QL700._internal(9, "W62H29");
 static const W62H100 = const QL700._internal(10, "W62H100");
 static const W12 = const QL700._internal(11, "W12");
 static const W29 = const QL700._internal(12, "W29");
 static const W38 = const QL700._internal(13, "W38");
 static const W50 = const QL700._internal(14, "W50");
 static const W54 = const QL700._internal(15, "W54");
 static const W62 = const QL700._internal(16, "W62");
 static const W60H86 = const QL700._internal(17, "W60H86");
 static const W62RB = const QL700._internal(38, "W62RB");
 static const W54H29 = const QL700._internal(39, "W54H29");
 static const UNSUPPORT = const QL700._internal(255, "UNSUPPORT");


 static final _values = [
   W17H54,
   W17H87,
   W23H23,
   W29H42,
   W29H90,
   W38H90,
   W39H48,
   W52H29,
   W62H29,
   W62H100,
   W12,
   W29,
   W38,
   W50,
   W54,
   W62,
   W60H86,
   W62RB,
   W54H29,
   UNSUPPORT,
 ];


 int getId() {
   return _id;
 }


 @override
 String getName() {
   return _name;
 }


 static int getItemId(index) {
   if (index < 0 || index > _values.length) {
     return UNSUPPORT.getId();
   }


   return _values[index].getId();
 }


 static QL700 valueFromID(int id) {
   for (int i = 0; i < _values.length; ++i) {
     QL700 num = _values[i];
     if (num.getId() == id) {
       return num;
     }
   }
   return UNSUPPORT;
 }


 static List<QL700> getValues() => List.from(_values);


 static int ordinalFromID(int id) {
   for (int i = 0; i < _values.length; ++i) {
     QL700 num = _values[i];
     if (num.getId() == id) {
       return i;
     }
   }
   return -1;
 }


 static QL700 fromMap(Map<dynamic, dynamic> map) {
   int id = map["id"];
   return QL700.valueFromID(id);
 }


 static QL700 fromIndex (int index) {
   if (index < 0 ||index >= _values.length ) {
     return UNSUPPORT;
   }
   return _values[index];
 }


 Map<String, dynamic> toMap() {
   return {"id": _id,
     "name": _name,
     "model": _model
   };
 }
}
最佳回答

在进行研究和进行各种测试之后,我发现,“labelNameIndex”的设定取决于所使用的特定标签类型。 此前,我错误地将“labelNameIndex”定为8,当时使用的标签是62毫米x5m,这不是正确的组合。 这一标签正确的“labelNameIndex”实际上是17个。

目前,我使用的标签是62毫米x29毫米,这要求将“labelNameIndex”定在8个。 通过这一调整,一切工作都是完美的。 因此,我认为不存在任何问题;这只是使用正确的“labelNameIndex”来形容你正在从事的具体工作。

问题回答

暂无回答




相关问题
Unable to Compile Hplip-3.10.9

I have all the required dependencies for the compile. Running ./configure finishes without errors. But after running make, it says: "In file included from prnt/hpcups/HPCupsFilter.h:34, ...

How can I use c# to set printersettings?

EDIT I have tried to reconstruct code I no longer have to show. I think it is just a klimitation of the printersetting class not exposing functionality that can be selected by using a dialog. It ...

PageSettings keep getting modifed unexpectedly

It seems that you can persist in a settings file PrinterSettings and also PageSettings, they are Serializable etc. Great! Everything was going OK until I tried to persist my PageSettings and the ...

DevMode Structure

I have files I need to drive thru a print driver and save then as files. Can I programactly use the DevMode Structure to drive these files without openning the application it was created in? Also can ...

How to get status from POS Printer

I m trying to find a way to get paper status from a POS printer; I think I would use GS a, GS r sequence but I cannot understand how to return info from the printer; I m under Linux, where does the ...

How can I locate all the network printers in the enterprise?

When I go to Printers and Faxes dialog, I can click the Add a printer link, select Network Printer, then Find a printer in the directory. From there I get a dialog box which lets me find ALL printers ...

热门标签