gogs 1 year ago
parent
commit
2f31f31510
1 changed files with 19 additions and 18 deletions
  1. 19 18
      app/src/main/java/com/naz/sdkdemo/MainActivity.java

+ 19 - 18
app/src/main/java/com/naz/sdkdemo/MainActivity.java

@@ -602,9 +602,10 @@ public class MainActivity extends BaseActivity {
     static int mPot = 8;//mm转像素8倍
     static int mWFont = 24;//字体宽度
     static int mHFont = 24;//字体高度
-    static int mPaperWidth = 78;//纸张宽度78mm
-    static int mPaperHeight = 132;//纸张高度132mm
+    static int mPaperWidth = 80;//纸张宽度78mm
+    static int mPaperHeight = 140;//纸张高度132mm
     static int fontSizeMultiple = 2;//字体倍数
+    static int fontSizeMultiple1 = 3;//放大字体倍数
     static int mOffsetY = 5;//打印开始点离左边的距离(Y轴),5mm
     static int mOffsetX = mPaperWidth-5;//打印开始点离上边的距离(X轴),5mm
     static int mFontWidth = mWFont * fontSizeMultiple;//文字的宽度
@@ -631,14 +632,14 @@ public class MainActivity extends BaseActivity {
                 printer.text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[1]);
                 currentHeight = currentHeight-mFontHeight;
             }
-            if (!TextUtils.isEmpty(productName[2])){
-                currentHeight = currentHeight-mTextSpace*mPot;
-                printer.text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[2]);
-                currentHeight = currentHeight-mFontHeight;
-            }
+//            if (!TextUtils.isEmpty(productName[2])){
+//                currentHeight = currentHeight-mTextSpace*mPot;
+//                printer.text(currentHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[2]);
+//                currentHeight = currentHeight-mFontHeight;
+//            }
             currentHeight = currentHeight-mSpace*mPot;
-            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:")
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.exe_sale_order_b.customer_name);
+            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, "经销商:")
+                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.exe_sale_order_b.customer_name);
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
             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.box_no)
@@ -686,27 +687,27 @@ public class MainActivity extends BaseActivity {
                 currentHeight = currentHeight-mFontHeight;
             }
             currentHeight = currentHeight-mSpace*mPot;
-            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:")
-                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.customer_name);
+            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, "经销商:")
+                    .text(currentHeight, mOffsetY*mPot+(4*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.customer_name);
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
             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.no)
-                    .text(currentHeight, mOffsetY*mPot+(5*mFontWidth)+getStrLength(module.no)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "包装数量:")
-                    .text(currentHeight, mOffsetY*mPot+(10*mFontWidth)+getStrLength(module.no)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.box_num);
+                    .text(currentHeight, mOffsetY*mPot+(5*mFontWidth)+getStrLength(module.no)+mSpace*mPot+15, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "包装数量:")
+                    .text(currentHeight, mOffsetY*mPot+(10*mFontWidth)+getStrLength(module.no)+mSpace*mPot+15, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.box_num);
             currentHeight = currentHeight-mFontHeight-mSpace*mPot;
-            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "花色:")
-                    .text(currentHeight, mOffsetY*mPot+(3*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.color);
+            printer.text(currentHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, "花色:")
+                    .text(currentHeight, mOffsetY*mPot+(3*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.color);
             if (module.box_order_product.color_two!=null){
                 printer.text(currentHeight, mOffsetY*mPot+(3*mFontWidth)+getStrLength(module.box_order_product.color)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.color_two);
             }
             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, fontSizeMultiple1,fontSizeMultiple1, "工艺:")
                     .text(currentHeight, mOffsetY*mPot+(3*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.process_title);
             if (module.box_order_product.process_title_two!=null){
                 printer.text(currentHeight, mOffsetY*mPot+(3*mFontWidth)+getStrLength(module.box_order_product.process_title)+mSpace*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.process_title_two);
             }
-            printer.text(currentHeight, (mPaperHeight-5)*mPot-getStrLength(module.now_date), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.now_date);
-            printer.qrcode((mOffsetX-30)*mPot, (mPaperHeight-5-30)*mPot, TSPLConst.EC_LEVEL_H, 10, TSPLConst.QRCODE_MODE_MANUAL, TSPLConst.ROTATION_0, module.no);
+            printer.text(currentHeight, (mPaperHeight-5)*mPot-getStrLength(module.now_date)+15, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.now_date);
+            printer.qrcode((mOffsetX-30)*mPot, (mPaperHeight-5-15)*mPot, TSPLConst.EC_LEVEL_H, 10, TSPLConst.QRCODE_MODE_MANUAL, TSPLConst.ROTATION_0, module.no);
             printer.print();
         }
     }