gbenroscience gbenroscience - 5 months ago 12
Android Question

I KEEP GETTING ERROR_WRONG_LABEL on Brother Printer QL-710W

I have been trying to get my android code to print to a new Brother Printer but

I keep getting ERROR_WRONG_LABEL.

I also get the information:

D/Brother Print SDK: no such enum object for the id: -1


This is my code:

public void printLabel() {


Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();

try {

myPrinterInfo.printerModel = PrinterInfo.Model.QL_710W;
myPrinterInfo.ipAddress = "12.1.3.45";//not real ip
myPrinterInfo.macAddress = "";
myPrinterInfo.port = PrinterInfo.Port.NET;
myPrinterInfo.paperSize = PrinterInfo.PaperSize.A7;
myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
myPrinterInfo.numberOfCopies = 1;

LabelInfo mLabelInfo = new LabelInfo();
mLabelInfo.labelNameIndex = 5;
mLabelInfo.isAutoCut = true;
mLabelInfo.isEndCut = true;
mLabelInfo.isHalfCut = false;
mLabelInfo.isSpecialTape = false;


myPrinter.setPrinterInfo(myPrinterInfo);



myPrinter.setLabelInfo(mLabelInfo);

//File downloadFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);

Log.i("HEYYYY", "startCommunication = " + myPrinter.startCommunication());

Bitmap map = BitmapFactory.decodeResource(getResources(), R.drawable.ic_action_overflow);

PrinterStatus printerStatus = myPrinter.printImage(map);

Log.i("HEYYYY", "errorCode-11 = " + printerStatus.errorCode);
Log.i("HEYYYY", "labelWidth = " + myPrinter.getLabelParam().labelWidth);
Log.i("HEYYYY", "paperWidth = " + myPrinter.getLabelParam().paperWidth);
Log.i("HEYYYY", "labelNameIndex " + mLabelInfo.labelNameIndex);
Log.i("HEYYYY", "printers " + myPrinter.getNetPrinters("QL-710W"));
Log.i("Label-id", myPrinter.getPrinterStatus().labelId + "");
myPrinter.endCommunication();




} catch(Exception e){

e.printStackTrace();

}
}


Whenever I put the mac address which I got from the printer page, the error code changes to

ERROR_NOT_MATCH_ADDRESS.


But without it(setting it to an empty string or commenting it out), it changes to

ERROR_WRONG_LABEL
.

What is wrong with this code, please?

UPDATE:

I inserted the correct mac id and now the error code is

ERROR_WRONG_LABEL


what do I do?

Answer

After reading through the manual that came with it, I discovered that the ERROR_WRONG_LABEL code occurs due to wrong labelNameIndex or wrong paperSize.

I set the labelNameIndex value to 15 and, voila it worked.

I feel anyone facing this problems should try out various values for the labelNameIndex.

Thanks.

Comments