gpt4 book ai didi

android - ERROR_WRONG_LABEL 尝试使用用于标签打印机的 Android Brother Sdk 进行无线打印

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:09:01 26 4
gpt4 key购买 nike

我尝试使用 wifi 命令 Brother QL-720NW 标签打印机 从我的 android 应用程序中打印标签。由于我在打印机上执行了出厂重置,所以出现此错误

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();
}
}
  • 我正在使用来自 here 的示例代码
  • 目标 - 我的最终目标是替换模板中的文本并打印,但目前我无法打印任何内容
  • 我正在使用 this兄弟SDK。
  • 我试过Brother android的示例代码,它也给出了同样的错误
  • 但是兄弟i print app和Ptouch软件打印成功,没有任何错误。

请帮忙!

谢谢

最佳答案

我通过创建 LabelInfo 对象解决了这个问题,因为您有一台标签打印机。文档中根本不清楚。您需要在打印机信息之后设置标签信息。

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 表示您在 paperSizelabelNameIndex 中的值有误。我有一台带有 24 英寸纸的 P750W 标签打印机。我发现值 5 适合这种尺寸,但我不知道适合你的打印机。

关于android - ERROR_WRONG_LABEL 尝试使用用于标签打印机的 Android Brother Sdk 进行无线打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22808548/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com