package michael.vegs;
import com.brother.ptouch.sdk.*;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
@Version(3.0f)
@ShortName("BrotherPrintSDK")
@DependsOn(values={"BrotherPrintLibrary"})
public class BrotherPrintSDK {
public void print(final BA ba, final String filePath,final String printerIP,final String LblSize,final String PModel){
Thread trd = new Thread(new Runnable(){
@Override
public void run() {
String x;
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
PrinterStatus printResult = new PrinterStatus();
LabelInfo mLabelInfo=new LabelInfo();
x="1";
myPrinterInfo = myPrinter.getPrinterInfo();
//myPrinterInfo.printerModel=PrinterInfo.Model.QL_720NW;
// myPrinterInfo.printerModel=PModel;
if (PModel=="QL_720NW") {
myPrinterInfo.printerModel=PrinterInfo.Model.QL_720NW;
} else {
myPrinterInfo.printerModel=PrinterInfo.Model.QL_820NWB;
}
x="2";
myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
myPrinterInfo.port=PrinterInfo.Port.NET;
myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;
myPrinterInfo.orientation = PrinterInfo.Orientation.PORTRAIT;
myPrinterInfo.numberOfCopies = 1;
myPrinterInfo.ipAddress=printerIP;
//myPrinter.skipStatusCheck=true;
mLabelInfo.labelNameIndex=LabelInfo.QL700.valueOf(LblSize).ordinal();
//mLabelInfo.labelNameIndex=5; W29H90 W38H90
x="3";
mLabelInfo.isAutoCut = true;
mLabelInfo.isEndCut =true;
myPrinter.setPrinterInfo(myPrinterInfo);
myPrinter.setLabelInfo(mLabelInfo);
x="4";
printResult=myPrinter.printFile(filePath);
ba.raiseEventFromDifferentThread(this , null, 0, "myevent_metadata", true, new Object[] {printResult.errorCode.toString() + x});
// }
}
});
trd.start();
}
}