尝试使用 Android Brother Sdk 进行标签打印机无线打印时出现 ERROR_WRONG_LABEL [英] ERROR_WRONG_LABEL when trying to print wireless using Android Brother Sdk for label printer
问题描述
我尝试使用 Android 应用中的标签进行打印,该应用使用 wifi 命令Brother QL-720NW 标签打印机.由于我对打印机执行了恢复出厂设置,因此出现此错误
I have trying to print using labels from my android app which using wifi commands Brother QL-720NW label printer. Since I performed factory reset on the printer , I'm getting this error
问题: ERROR_WRONG_LABEL(意味着 sdk 指南中指定的错误卷)错误在打印命令中抛出,因为我执行了工厂在打印机上重置.
Problem: ERROR_WRONG_LABEL( means wrong roll specified in the sdk guide) error is thrown on print command, since I performed factory reset on the printer .
代码:
void printTemplateSample()
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
try{
// Retrieve printer informations
myPrinterInfo = myPrinter.getPrinterInfo();
// Set printer informations
myPrinterInfo.printerModel = PrinterInfo.Model.QL_720NW;
myPrinterInfo.port=PrinterInfo.Port.NET;
myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
// :
myPrinterInfo.paperSize = PrinterInfo.PaperSize.A4;
myPrinterInfo.ipAddress="192.168.1.13";
myPrinterInfo.macAddress="00:80:92:BD:35:7D";
myPrinter.setPrinterInfo(myPrinterInfo);
// Start creating P-touch Template command print data
// myPrinter.startPTTPrint(1, null);
Boolean val= myPrinter.startPTTPrint(6, null);
Log.i("print", "startPTTPrint "+val);
// Replace text
myPrinter.replaceText("abcde");
// myPrinter.replaceText("12345");
// Trasmit P-touch Template command print data
PrinterStatus status=myPrinter.flushPTTPrint();//ERROR thrown here
Log.i("print", "PrinterStatus err"+status.errorCode);
}catch(Exception e){
e.printStackTrace();
}
}
- 我正在使用 此处的示例代码
- 目标 - 我的最终目标是替换模板中的文本并打印,但目前我无法打印任何内容
- 我正在使用这个 Brother SDK.莉>
- 我尝试了 android 的 Brother 示例代码,它也给出了同样的错误
- 但是兄弟 i 打印应用程序和 Ptouch 软件打印成功,没有任何错误.
- I'm using there sample code from here
- Objective - my ultimate objective is to replace text in template and print but currently I'm not able to print anything
- I'm using this Brother SDK.
- I tried the Brother sample code for android , it also gives the same error
- BUT brother i print app and Ptouch software are successfully printing without any error.
请帮忙!
谢谢
推荐答案
我通过创建一个 LabelInfo
对象解决了这个问题,因为你有一个标签打印机.文档中根本不清楚.您需要在打印机信息之后设置标签信息.
I resolved this by creating a LabelInfo
object, since you have a Label Printer. It's not clear at all in the documentation. You need to set the label info after the printer info.
PrinterInfo info = myPrinter.getPrinterInfo();
info.paperSize = PrinterInfo.PaperSize.CUSTOM;
LabelInfo mLabelInfo = new LabelInfo();
mLabelInfo.labelNameIndex = 5;
mLabelInfo.isAutoCut = true;
mLabelInfo.isEndCut = true;
mLabelInfo.isHalfCut = false;
mLabelInfo.isSpecialTape = false;
myPrinter.setPrinterInfo(info);
myPrinter.setLabelInfo(mLabelInfo);
ERROR_WRONG_LABEL
表示您在 paperSize
或 labelNameIndex
中有错误的值.我有一台带有 24 英寸纸的 P750W 标签打印机.我发现值 5
适合这种尺寸,但我不知道您的打印机.
The ERROR_WRONG_LABEL
means that you have a wrong value in paperSize
or labelNameIndex
.
I have a P750W label printer with a 24'' paper. I found that value 5
is the good one for this size, but I don't know for your printer.
这篇关于尝试使用 Android Brother Sdk 进行标签打印机无线打印时出现 ERROR_WRONG_LABEL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!