|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.dj.printer.dj_printer;
|
|
|
|
|
|
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
|
import android.graphics.BitmapFactory;
|
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
|
|
|
|
|
|
import com.sewoo.jpos.command.CPCLConst;
|
|
|
|
@ -7,6 +9,8 @@ import com.sewoo.jpos.printer.CPCLPrinter;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class AsPrint {
|
|
|
|
|
|
|
|
|
@ -20,23 +24,98 @@ public class AsPrint {
|
|
|
|
|
cpclPrinter.setMeasure(CPCLConst.LK_CPCL_MILLI);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void printAsCode(String code, String channel, String country, String countStr, int offset, boolean hasPlan) throws IOException {
|
|
|
|
|
printTest();
|
|
|
|
|
// if (hasPlan) {
|
|
|
|
|
// PrintPlan(code, channel, country, countStr, offset);
|
|
|
|
|
// } else {
|
|
|
|
|
// PrintNoPlan(code, countStr, offset);
|
|
|
|
|
// }
|
|
|
|
|
public void printAsCode(String code, String channel, String country, String countStr,
|
|
|
|
|
int offset, boolean hasPlan, byte[] bytesCode, byte[] bytesChannel,
|
|
|
|
|
byte[] bytesCountry ,byte[] bytesBarCode,byte[] bytesNum ,byte[] bytesSum) throws IOException {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bitmap imgCode = BitmapFactory.decodeByteArray(bytesCode, 0, bytesCode.length);
|
|
|
|
|
|
|
|
|
|
Bitmap imgChannel = BitmapFactory.decodeByteArray(bytesChannel, 0, bytesChannel.length);
|
|
|
|
|
|
|
|
|
|
Bitmap imgCountry = BitmapFactory.decodeByteArray(bytesCountry, 0, bytesCountry.length);
|
|
|
|
|
|
|
|
|
|
Bitmap imgBarCode = BitmapFactory.decodeByteArray(bytesBarCode, 0, bytesBarCode.length);
|
|
|
|
|
|
|
|
|
|
Bitmap imgNum = BitmapFactory.decodeByteArray(bytesNum, 0, bytesNum.length);
|
|
|
|
|
|
|
|
|
|
Bitmap imgSum = BitmapFactory.decodeByteArray(bytesSum, 0, bytesSum.length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hasPlan) {
|
|
|
|
|
printNewPlan(code, channel, country, countStr, offset, imgCode, imgChannel, imgCountry,imgBarCode,imgNum,imgSum);
|
|
|
|
|
} else {
|
|
|
|
|
printNewNoPlan(code, channel, country, countStr, offset, imgCode, imgCountry,imgBarCode,imgNum,imgSum);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void printTest() throws UnsupportedEncodingException {
|
|
|
|
|
cpclPrinter.setForm(0, 203, 203, 500, 575, 0, 1);
|
|
|
|
|
private void printNewPlan(String code, String channel, String country, String countStr, int offset,
|
|
|
|
|
Bitmap imgCode, Bitmap imgChannel, Bitmap imgCountry,
|
|
|
|
|
Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException {
|
|
|
|
|
|
|
|
|
|
cpclPrinter.setForm(3, 203, 203, 800, 575, 0, 1);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
|
|
|
|
|
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBox(5,5,500,300,3);
|
|
|
|
|
cpclPrinter.printLine(5,50,500,50,3);
|
|
|
|
|
cpclPrinter.printLine(430,300,480,250,3);
|
|
|
|
|
cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBox(0, 7, 570, 800, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(265, 7, 265, 800, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(424, 7, 424, 800, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(0, 526, 424, 526, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(70, 590, 200, 730, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgCode, 460, 50);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgChannel, 295, 60);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgCountry, 320, country.length()>3?570:580);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgBarCode, 40, 80);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgNum, 150, 600);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgSum, 70, 690);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void printNewNoPlan(String code, String channel, String country, String countStr, int offset,
|
|
|
|
|
Bitmap imgCode, Bitmap imgCountry,
|
|
|
|
|
Bitmap imgBarCode,Bitmap imgNum,Bitmap imgSum) throws IOException {
|
|
|
|
|
|
|
|
|
|
cpclPrinter.setForm(3, 203, 203, 800, 575, 0, 1);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBox(0, 10, 570, 795, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(265, 10, 265, 795, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(424, 10, 424, 795, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(0, 526, 265, 526, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printLine(70, 590, 200, 730, 3);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgCode, 460, 50);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgCountry, 320,270);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgBarCode, 40, 80);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgNum, 150, 600);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printBitmap(imgSum, 70, 690);
|
|
|
|
|
|
|
|
|
|
cpclPrinter.printForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -78,3 +157,4 @@ public class AsPrint {
|
|
|
|
|
return cpclPrinter.status();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|