瀏覽代碼

update: 更换更大尺寸的打印纸

huwanxiao 1 年之前
父節點
當前提交
46388f0ec7
共有 1 個文件被更改,包括 10 次插入9 次删除
  1. 10 9
      app/src/main/java/com/naz/sdkdemo/MainActivity.java

+ 10 - 9
app/src/main/java/com/naz/sdkdemo/MainActivity.java

@@ -958,9 +958,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 = 150;//纸张高度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;//文字的宽度
@@ -1028,7 +1029,7 @@ public class MainActivity extends BaseActivity {
                     .direction(TSPLConst.DIRECTION_FORWARD)
                     .cls()
                     .text(mOffsetX*mPot, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "销售订单号:")
-                    .text(mOffsetX*mPot, mOffsetY*mPot+(6*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.order_no)
+                    .text(mOffsetX*mPot, mOffsetY*mPot+(6*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, module.box_order_product.order_no)
                     .text((mOffsetX-mSpace)*mPot-mFontHeight, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "产品名称:");
             String[] productName = getStrs(module.box_order_product.material_title, (mPaperHeight-2*mOffsetY-mSpace-mCodeSize)*mPot-5*mFontWidth);
             printer.text((mOffsetX-mSpace)*mPot-mFontHeight, mOffsetY*mPot+(5*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, productName[0]);
@@ -1043,9 +1044,9 @@ public class MainActivity extends BaseActivity {
                 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.box_order_product.customer_name);
+            currentHeight = currentHeight-mSpace*mPot-55;
+            printer.text(currentHeight+65, mOffsetY*mPot, FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, "经销商:")
+                    .text(currentHeight, mOffsetY*mPot, 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)
@@ -1053,18 +1054,18 @@ public class MainActivity extends BaseActivity {
                     .text(currentHeight, mOffsetY*mPot+(10*mFontWidth)+getStrLength(module.no)+mSpace*mPot, 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);
+                    .text(currentHeight+3, 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, "工艺:")
-                    .text(currentHeight, mOffsetY*mPot+(3*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.box_order_product.process_title);
+                    .text(currentHeight+3, mOffsetY*mPot+(3*mFontWidth), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple1,fontSizeMultiple1, 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 - 2, (mPaperHeight-5)*mPot-getStrLength(module.now_date), FNT_SIMPLIFIED_CHINESE, ROTATION_90, fontSizeMultiple,fontSizeMultiple, module.now_date);
-            int qrX = (mOffsetX - 37) * mPot;
+            int qrX = (mOffsetX - 34) * mPot;
             int qrY = (mPaperHeight - 5 - 30) * mPot;
             printer.qrcode(qrX, qrY, TSPLConst.EC_LEVEL_H, 10, TSPLConst.QRCODE_MODE_MANUAL, TSPLConst.ROTATION_0, module.no);
             printer.print();