适配竖直打印

master
章文轩 2 years ago
parent 5736243738
commit 31b1ccfa65

@ -7,9 +7,7 @@
<list default="true" id="2f8e3712-04e2-429a-bcea-c8db1a54008e" name="默认变更列表" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/AsPrint.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/dj/printer/dj_printer/DjPrinterPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/dj_printer.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/dj_printer.dart" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />

@ -64,106 +64,75 @@ public class AsPrint {
private void PrintPlanNew(String code,String barCode, String channel, String country, String num,String sum,
int offset) throws IOException {
int cx = 0;
int cy = 0;
int cSize = 0;
int cx = 0,cy = 0,cSize = 0;
if(country.length()>5){
cSize = 55;
cx = 55;
cy = 220;
cSize = 55;cx = 55;cy = 220;
country = country.substring(0,4)+"\n"+country.substring(4);
}else if(country.length()==5){
cSize = 50;
cx = 40;
cy = 250;
cSize = 50;cx = 40;cy = 250;
}else {
cSize = 60;
cy = 245;
cx = 85-country.length()*15;
cSize = 60;cy = 245;cx = 170-country.length()*30;
}
int channelY = 440,channelX = 90;
if(channel.length()>11){
channelY = 440;channelX = 90;channel = channel.substring(0,11)+"\n"+channel.substring(11);
}else{
channelY = 460;channelX = 220 - channel.length()*10;
}
cpclPrinter.setForm(0, 203, 203, 800, 575, 0, 1);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
cpclPrinter.printBox(0, 10, 570, 800, 3);
cpclPrinter.printBox(0, 10, 575, 790, 3);
cpclPrinter.printLine(0, 160, 570, 160, 3);
cpclPrinter.printLine(0, 400, 570, 400, 3);
cpclPrinter.printLine(0, 560, 570, 560, 3);
cpclPrinter.printAndroidFont(50, 50, Typeface.DEFAULT_BOLD, true, code, 575, 65);
cpclPrinter.printAndroidFont(40, 50, Typeface.DEFAULT_BOLD, true, code, 575, 65);
cpclPrinter.printAndroidFont(cx, cy, Typeface.DEFAULT_BOLD, true, country,
575, cSize);
cpclPrinter.printAndroidFont(90, 440, Typeface.DEFAULT, false, channel, 575, 40);
cpclPrinter.printAndroidFont(160, 745, Typeface.DEFAULT, false, barCode, 575, 28);
cpclPrinter.printAndroidFont(390, 210, Typeface.DEFAULT_BOLD, true, num,
575, 50);
cpclPrinter.printAndroidFont(490-sum.length()*10, 300, Typeface.DEFAULT_BOLD, true, sum,
575, 50);
cpclPrinter.printLine(380, 360, 520, 210, 4);
cpclPrinter.printAndroidFont(channelX, channelY, Typeface.DEFAULT, false, channel, 575, 40);
cpclPrinter.printAndroidFont(155, 745, Typeface.DEFAULT, false, barCode, 575, 28);
cpclPrinter.printLine(333, 110, 333, 350, 3);
cpclPrinter.setCPCLBarcode(0, 0, 0);
cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION,
CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO,
150, 0, 580, barCode, 0);
// cpclPrinter.printAndroidFont(700, 440, Typeface.DEFAULT, false, barCode, 575, 20);
// cpclPrinter.setCPCLBarcode(0, 0, 0);
// cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION, CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO, 130, 0, 26, code, 0);
// cpclPrinter.printCPCLText(0, 0, 3, 0, 170, code, 0);
// cpclPrinter.printLine(0, 220, 535, 220, 3);
// cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
// cpclPrinter.printAndroidFont(40, 240, Typeface.DEFAULT_BOLD, true, "渠道名称:", 575, 30);
// cpclPrinter.printAndroidFont(170, 240, Typeface.DEFAULT, channel, 575, 30);
// cpclPrinter.printAndroidFont(40, 300, Typeface.DEFAULT, "目的地:" + country, 575, 30);
// cpclPrinter.printAndroidFont(400 - offset, 300, Typeface.DEFAULT_BOLD, true, "件数:", 575, 30);
// cpclPrinter.printAndroidFont(480 - offset, 300, Typeface.DEFAULT, countStr, 575, 30);
150, 0, 585, barCode, 0);
cpclPrinter.printForm();
}
private void PrintNoPlanNew(String code,String barCode, String num,String sum,
int offset) throws IOException {
cpclPrinter.setForm(0, 203, 203, 500, 575, 0, 1);
cpclPrinter.setForm(0, 203, 203, 800, 575, 0, 1);
cpclPrinter.setMedia(CPCLConst.LK_CPCL_LABEL);
cpclPrinter.setJustification(CPCLConst.LK_CPCL_CENTER);
// cpclPrinter.setCPCLBarcode(0, 0, 0);
// cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION, CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO, 130, 0, 26, code, 0);
// cpclPrinter.printCPCLText(0, 0, 3, 0, 170, code, 0);
// cpclPrinter.printLine(0, 220, 535, 220, 3);
// cpclPrinter.setJustification(CPCLConst.LK_CPCL_LEFT);
// cpclPrinter.printAndroidFont(40, 240, Typeface.DEFAULT_BOLD, true, "未建计划", 575, 50);
// cpclPrinter.printAndroidFont(400, 240, Typeface.DEFAULT_BOLD, true, "件数:", 575, 50);
// cpclPrinter.printAndroidFont(400 - offset, 300, Typeface.DEFAULT, countStr, 575, 30);
cpclPrinter.printBox(0, 10, 575, 790, 3);
cpclPrinter.printLine(0, 160, 570, 160, 3);
cpclPrinter.printLine(0, 400, 570, 400, 3);
cpclPrinter.printAndroidFont(40, 50, Typeface.DEFAULT_BOLD, true, code, 575, 65);
cpclPrinter.printAndroidFont(50, 245, Typeface.DEFAULT_BOLD, true, "未建计划",
575, 60);
cpclPrinter.printAndroidFont(390, 210, Typeface.DEFAULT_BOLD, true, num,
575, 50);
cpclPrinter.printAndroidFont(490-sum.length()*10, 300, Typeface.DEFAULT_BOLD, true, sum,
575, 50);
cpclPrinter.printLine(380, 360, 520, 210, 4);
cpclPrinter.printAndroidFont(155, 670, Typeface.DEFAULT, false, barCode, 575, 28);
cpclPrinter.printLine(333, 110, 333, 350, 3);
cpclPrinter.setCPCLBarcode(0, 0, 0);
cpclPrinter.printCPCLBarcode(CPCLConst.LK_CPCL_0_ROTATION,
CPCLConst.LK_CPCL_BCS_128, 1, CPCLConst.LK_CPCL_BCS_4RATIO,
160, 0, 500, barCode, 0);
cpclPrinter.printForm();
}

@ -95,14 +95,14 @@ class _MyAppState extends State<MyApp> {
TextButton(
onPressed: () {
DjPrinter().printNewAScode(
code: 'ASSZ87658907',
barCode: 'ASSZ2010000001111',
channel: '加拿大温哥华海派快线-\n卡派/UPS派送',
country: '伊苏尔',
code: 'ASSZ000000002',
barCode: 'ASSZ0000000020001',
channel: '加拿大温哥华海派快线-卡派 / UPS派送',
country: '美国',
num: '2',
sum:'20',
sum:'9',
offset: 0,
hasPlan: true, );
hasPlan: false, );
},
child: const Text('打印')),

Loading…
Cancel
Save