Pārlūkot izejas kodu

update: 散标打印格式调整

huwanxiao 1 gadu atpakaļ
vecāks
revīzija
5ae047ae8f
1 mainītis faili ar 15 papildinājumiem un 4 dzēšanām
  1. 15 4
      app/src/main/java/com/naz/sdkdemo/MainActivity.java

+ 15 - 4
app/src/main/java/com/naz/sdkdemo/MainActivity.java

@@ -1208,7 +1208,7 @@ public class MainActivity extends BaseActivity {
     private void startPrint3(List<PrintModule3> data) {
         for (PrintModule3 module:data) {
             printer.sizeMm(mPaperWidth, mPaperHeight)
-                    .density(10)
+                    .density(15)
                     .reference(mPaperWidth*mPot, 0)
                     .direction(TSPLConst.DIRECTION_FORWARD)
                     .cls()
@@ -1228,11 +1228,22 @@ public class MainActivity extends BaseActivity {
             printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "商标编码:")
                     .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.material_code);
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "余标:")
+            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "余    标:")
                     .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.qty);
-            printer.text(currentHeight, (mPaperHeight-5)*mPot-getStrLength(module.roll_qr_code), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.roll_qr_code);
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight - 2, (mPaperHeight-5)*mPot-getStrLength(module.now_date), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.now_date);
+            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "卷    码:")
+                    .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.roll_qr_code);
+            currentHeight = currentHeight-mFontHeight-mSpace*mPot;
+            String[] no;
+            try {
+                no = module.now_date.split(":");
+                printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, no[0] + ":")
+                        .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, no[1]);
+            }catch (Exception e) {
+                printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "包装日期:")
+                        .text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.now_date);
+            }
+
             int qrX = (mOffsetX - 30) * mPot;
             int qrY = (mPaperHeight - 5 - 30) * mPot;
             printer.qrcode(qrX, qrY, TSPLConst.EC_LEVEL_H, 10, TSPLConst.QRCODE_MODE_MANUAL, TSPLConst.ROTATION_0, module.roll_qr_code);