Browse Source

2.7.7 a4初步打印

xulh 6 months ago
parent
commit
2f5d113901

+ 52 - 23
app/src/main/java/com/hh/arome/bean/ampe/AmpeAppletRequestBean.java

@@ -1,5 +1,7 @@
 package com.hh.arome.bean.ampe;
 
+import com.common.print.bean.PrintBean;
+
 import java.util.List;
 
 public class AmpeAppletRequestBean {
@@ -43,14 +45,8 @@ public class AmpeAppletRequestBean {
 
     public static class ParamsDTO {
 
-
-        // 打印浓度
-        int printPotency;
-        // 打印速度
-        int printSpeed;
-        // 打印纸张大小
-        int printPageType;
-
+        // 打印配置
+        private PrintConfigDTO printConfig;
 
         // 具体打印内容
         private List<PrintListBean> printList;
@@ -73,6 +69,25 @@ public class AmpeAppletRequestBean {
             private int width;
             private String qrCodeText;
 
+            int xPosition;
+            int yPosition;
+
+            public int getxPosition() {
+                return xPosition;
+            }
+
+            public void setxPosition(int xPosition) {
+                this.xPosition = xPosition;
+            }
+
+            public int getyPosition() {
+                return yPosition;
+            }
+
+            public void setyPosition(int yPosition) {
+                this.yPosition = yPosition;
+            }
+
             public String getQrCodeText() {
                 return qrCodeText;
             }
@@ -139,28 +154,42 @@ public class AmpeAppletRequestBean {
         }
 
 
-        public int getPrintPotency() {
-            return printPotency;
+        public PrintConfigDTO getPrintConfig() {
+            return printConfig;
         }
 
-        public void setPrintPotency(int printPotency) {
-            this.printPotency = printPotency;
+        public void setPrintConfig(PrintConfigDTO printConfig) {
+            this.printConfig = printConfig;
         }
 
-        public int getPrintSpeed() {
-            return printSpeed;
-        }
+        public static class PrintConfigDTO {
+            private int printPageType = -1;
+            private int printPotency = 5;
+            private int printSpeed = 3;
 
-        public void setPrintSpeed(int printSpeed) {
-            this.printSpeed = printSpeed;
-        }
+            public int getPrintPageType() {
+                return printPageType;
+            }
 
-        public int getPrintPageType() {
-            return printPageType;
-        }
+            public void setPrintPageType(int printPageType) {
+                this.printPageType = printPageType;
+            }
+
+            public int getPrintPotency() {
+                return printPotency;
+            }
+
+            public void setPrintPotency(int printPotency) {
+                this.printPotency = printPotency;
+            }
 
-        public void setPrintPageType(int printPageType) {
-            this.printPageType = printPageType;
+            public int getPrintSpeed() {
+                return printSpeed;
+            }
+
+            public void setPrintSpeed(int printSpeed) {
+                this.printSpeed = printSpeed;
+            }
         }
 
         // ampe配置

File diff suppressed because it is too large
+ 7 - 0
app/src/main/java/com/hh/arome/common/MockData.java


+ 6 - 2
app/src/main/java/com/hh/arome/services/keeplive/LocalService.kt

@@ -69,7 +69,9 @@ class LocalService:Service() {
         //使Service变成前台服务
         var notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
-            var channel = NotificationChannel(NotificationChannelId, NotificationChannelName, NotificationManager.IMPORTANCE_HIGH);
+            var channel = NotificationChannel(NotificationChannelId, NotificationChannelName,
+                    // 声音
+                    NotificationManager.IMPORTANCE_MIN);
             notificationManager.createNotificationChannel(channel)
         }
         startForeground(1, getNotification());
@@ -113,7 +115,9 @@ class LocalService:Service() {
             super.onCreate()
             var notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
             if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
-                var channel = NotificationChannel(NotificationChannelId, NotificationChannelName, NotificationManager.IMPORTANCE_HIGH);
+                var channel = NotificationChannel(NotificationChannelId, NotificationChannelName,
+                        // 声音
+                        NotificationManager.IMPORTANCE_MIN);
                 notificationManager.createNotificationChannel(channel);
             }
             startForeground(1, getNotification())

+ 6 - 2
app/src/main/java/com/hh/arome/services/keeplive/RemoteService.kt

@@ -62,7 +62,9 @@ class RemoteService: Service() {
         //使Service变成前台服务
         var notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
         if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
-            var channel = NotificationChannel(NotificationChannelId, NotificationChannelName, NotificationManager.IMPORTANCE_HIGH);
+            var channel = NotificationChannel(NotificationChannelId, NotificationChannelName,
+                    // 声音
+                    NotificationManager.IMPORTANCE_MIN);
             notificationManager.createNotificationChannel(channel);
         }
         startForeground(1, getNotification());
@@ -117,7 +119,9 @@ class RemoteService: Service() {
             super.onCreate()
             var notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
             if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){
-                var channel = NotificationChannel(NotificationChannelId,  NotificationChannelName, NotificationManager.IMPORTANCE_HIGH);
+                var channel = NotificationChannel(NotificationChannelId,  NotificationChannelName,
+                        // 声音
+                        NotificationManager.IMPORTANCE_MIN);
                 notificationManager.createNotificationChannel(channel);
             }
             startForeground(1, getNotification())

File diff suppressed because it is too large
+ 4 - 5
app/src/main/java/com/hh/arome/ui/MainActivity.java


+ 2 - 2
app/src/main/res/layout/activity_main.xml

@@ -203,8 +203,8 @@
 
             <ImageView
                 android:id="@+id/iv_test"
-                android:layout_width="40dp"
-                android:layout_height="40dp"/>
+                android:layout_width="300dp"
+                android:layout_height="300dp"/>
 
             <TextView
                 android:id="@+id/tv_idcard_info"

+ 47 - 6
lib_print/src/main/java/com/common/print/BasePrinter.java

@@ -9,6 +9,8 @@ import com.common.arome.DeviceUtils;
 import com.common.lib_base.common.async.ThreadPoolManager;
 import com.common.lib_base.utils.StringUtils;
 import com.common.lib_base.utils.log.CommonLogUtils;
+import com.common.lib_base.utils.ui.ToastUtils;
+import com.common.print.bean.PrintBean;
 import com.common.print.callback.PrintInitResultCallback;
 //import com.common.print.many.KMlaA4Printer;
 //import com.common.print.many.MlaA4Printer;
@@ -16,6 +18,7 @@ import com.common.print.many.MlaFCDD215Printer;
 import com.common.print.many.NullPrinter;
 import com.common.print.many.TbPrinter;
 import com.common.print.bean.PrintContentBean;
+import com.common.print.many.base.IPrinter;
 //import com.telpo.tps550.api.printer.UsbThermalPrinter;
 
 import java.util.ArrayList;
@@ -53,7 +56,7 @@ public class BasePrinter {
 
     public IPrinter getPrinter(Context context) {
         String model = DeviceUtils.getDeviceModel();
-        CommonLogUtils.e(mTag,"model:"+model);
+        CommonLogUtils.e("model:"+model);
 
         if (Constants.DeviceModel.T1YB01.equals(model)) {
             // y9
@@ -103,15 +106,21 @@ public class BasePrinter {
     private static final String ALGIN_CENTER = "center";
 
 
+    PrintBean.PrintConfigDTO printConfigDTO;
+
     // 传入要打印的数据,开始打印
-    public void handleDataAndPrint(List<PrintContentBean> printContentData) {
+    public void handleDataAndPrint(List<PrintContentBean> printContentData, PrintBean.PrintConfigDTO printConfigDTO) {
 
         if(printContentData == null || printContentData.size() == 0){
 
             CommonLogUtils.e("printContentData == null");
+            ToastUtils.showLongToast("打印数据为空");
             return;
         }
 
+        this.printConfigDTO = printConfigDTO;
+
+
         if(iPrinter == null){
             CommonLogUtils.e("iPrinter == null");
             return;
@@ -139,6 +148,40 @@ public class BasePrinter {
 
         iPrinter.startPrint();
 
+
+        int printPageType = printConfigDTO.getPrintPageType();
+
+        if(-1 == printPageType){
+            // 未设置
+            commonPrint();
+        }else{
+            // A4热敏打印
+            A4Print();
+        }
+
+
+        CommonLogUtils.e("cutPaper");
+        // 打印完并切纸
+        iPrinter.cutPaper();
+
+
+    }
+
+    /**
+     * A4热敏打印
+     */
+    private void A4Print() {
+
+        iPrinter.printTextBitmap(printContentList,printConfigDTO);
+
+
+
+    }
+
+    /**
+     * 普通小票打印
+     */
+    private void commonPrint() {
         // 打印时间
         int printTotalTime = 0;
         // 循环打印,并累计打印时间
@@ -190,14 +233,10 @@ public class BasePrinter {
 
                 // 打印时间累计
                 printTotalTime+=2000;
-
             }
 
         }
 
-        CommonLogUtils.e("cutPaper");
-        // 打印完并切纸
-        iPrinter.cutPaper();
 
 
         // 通知打印完成
@@ -209,6 +248,8 @@ public class BasePrinter {
                 }
             }
         },printTotalTime);
+
+
     }
 
 

+ 12 - 57
lib_print/src/main/java/com/common/print/bean/PrintBean.java

@@ -7,8 +7,7 @@ import java.util.List;
 public class PrintBean {
 
 
-    private PrintConfigDTO printConfig;
-    private List<PrintListDTO> printList;
+    public PrintConfigDTO printConfig;
 
     public PrintConfigDTO getPrintConfig() {
         return printConfig;
@@ -18,18 +17,11 @@ public class PrintBean {
         this.printConfig = printConfig;
     }
 
-    public List<PrintListDTO> getPrintList() {
-        return printList;
-    }
-
-    public void setPrintList(List<PrintListDTO> printList) {
-        this.printList = printList;
-    }
 
     public static class PrintConfigDTO {
-        private int printPageType;
-        private int printPotency;
-        private int printSpeed;
+        private int printPageType = -1;
+        private int printPotency = 5;
+        private int printSpeed = 3;
 
         public int getPrintPageType() {
             return printPageType;
@@ -54,53 +46,16 @@ public class PrintBean {
         public void setPrintSpeed(int printSpeed) {
             this.printSpeed = printSpeed;
         }
-    }
-
-    public static class PrintListDTO {
-        private String text;
-        private int textSize;
-        private boolean bold;
-        private int xPosition;
-        private int yPosition;
-
-        public String getText() {
-            return text;
-        }
-
-        public void setText(String text) {
-            this.text = text;
-        }
 
-        public int getTextSize() {
-            return textSize;
-        }
-
-        public void setTextSize(int textSize) {
-            this.textSize = textSize;
-        }
 
-        public boolean isBold() {
-            return bold;
-        }
-
-        public void setBold(boolean bold) {
-            this.bold = bold;
-        }
-
-        public int getXPosition() {
-            return xPosition;
-        }
-
-        public void setXPosition(int xPosition) {
-            this.xPosition = xPosition;
-        }
-
-        public int getYPosition() {
-            return yPosition;
-        }
-
-        public void setYPosition(int yPosition) {
-            this.yPosition = yPosition;
+        @Override
+        public String toString() {
+            return "PrintConfigDTO{" +
+                    "printPageType=" + printPageType +
+                    ", printPotency=" + printPotency +
+                    ", printSpeed=" + printSpeed +
+                    '}';
         }
     }
+
 }

+ 49 - 1
lib_print/src/main/java/com/common/print/bean/PrintContentBean.java

@@ -1,5 +1,7 @@
 package com.common.print.bean;
 
+import android.graphics.Bitmap;
+
 public class PrintContentBean {
     private String text;
     private int textSize;
@@ -10,6 +12,35 @@ public class PrintContentBean {
     private int height;
     private String qrCodeText;
 
+    Bitmap printBitmap;
+
+    int xPosition;
+    int yPosition;
+
+    public Bitmap getPrintBitmap() {
+        return printBitmap;
+    }
+
+    public void setPrintBitmap(Bitmap printBitmap) {
+        this.printBitmap = printBitmap;
+    }
+
+    public int getxPosition() {
+        return xPosition;
+    }
+
+    public void setxPosition(int xPosition) {
+        this.xPosition = xPosition;
+    }
+
+    public int getyPosition() {
+        return yPosition;
+    }
+
+    public void setyPosition(int yPosition) {
+        this.yPosition = yPosition;
+    }
+
     public String getQrCodeText() {
         return qrCodeText;
     }
@@ -38,7 +69,7 @@ public class PrintContentBean {
     }
 
     public void setBold(boolean bold) {
-        bold = bold;
+        this.bold = bold;
     }
 
     public String getAlgin() {
@@ -72,4 +103,21 @@ public class PrintContentBean {
     public void setHeight(int height) {
         this.height = height;
     }
+
+
+    @Override
+    public String toString() {
+        return "PrintContentBean{" +
+                "text='" + text + '\'' +
+                ", textSize=" + textSize +
+                ", bold=" + bold +
+                ", algin='" + algin + '\'' +
+                ", imageBase64='" + imageBase64 + '\'' +
+                ", width=" + width +
+                ", height=" + height +
+                ", qrCodeText='" + qrCodeText + '\'' +
+                ", xPosition=" + xPosition +
+                ", yPosition=" + yPosition +
+                '}';
+    }
 }

+ 9 - 1
lib_print/src/main/java/com/common/print/many/Mla80Printer.java

@@ -6,12 +6,15 @@ import android.hardware.usb.UsbDevice;
 import android.hardware.usb.UsbManager;
 import android.util.Log;
 
-import com.common.print.IPrinter;
+import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
+import com.common.print.many.base.IPrinter;
 import com.common.print.callback.PrintInitResultCallback;
 import com.common.print.utils.BitmapUtils;
 import com.tx.printlib.Const;
 import com.tx.printlib.UsbPrinter;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -216,6 +219,11 @@ public class Mla80Printer implements IPrinter {
 
 
 
+    }
+
+    @Override
+    public void printTextBitmap(List<PrintContentBean> printContentList, PrintBean.PrintConfigDTO printConfigDTO) {
+
     }
 
 

+ 118 - 12
lib_print/src/main/java/com/common/print/many/MlaFCDD215Printer.java

@@ -9,7 +9,9 @@ import android.os.Handler;
 import com.common.lib_base.utils.StringUtils;
 import com.common.lib_base.utils.log.CommonLogUtils;
 import com.common.lib_base.utils.ui.ToastUtils;
-import com.common.print.IPrinter;
+import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
+import com.common.print.many.base.IPrinter;
 import com.common.print.callback.PrintInitResultCallback;
 import com.common.print.utils.BitmapUtils;
 import com.common.print.utils.CodeUtils;
@@ -394,6 +396,109 @@ public class MlaFCDD215Printer implements IPrinter {
 
         ThreadUtils.executeByCpu(pictureThreadTask);
 
+    }
+
+
+    @Override
+    public void printTextBitmap(List<PrintContentBean> printContentList, PrintBean.PrintConfigDTO printConfigDTO) {
+
+
+        CommonLogUtils.e("printContentList--"+printContentList.toString(),
+                "printConfigDTO--"+printConfigDTO.toString());
+
+
+        int printPageType = printConfigDTO.getPrintPageType();
+
+
+        // 得到图片
+        Bitmap textToBimtap = BitmapUtils.createTextBitmap(mContext,printContentList,printPageType);
+
+        PrintDataBean printDataBean = new PrintDataBean();
+
+        // 设定打印浓度,不设置默认为5
+        printDataBean.setPotency(printConfigDTO.getPrintPotency());
+        // 设定打印速度,不设置默认为5
+        printDataBean.setSpeed(printConfigDTO.getPrintSpeed());
+
+        printDataBean.setBitmap(textToBimtap);
+        // 给定想打印的纸张规格
+
+        /**
+         * Page_Type_A4_Normal(0),
+         * Page_Type_A4_Roll(1),
+         * Page_Type_A4_ANSI_A(2),
+         * Page_Type_A5_Normal(3),
+         * Page_Type_200mm(4),
+         * Page_Type_150mm(5),
+         * Page_Type_100mm(6),
+         * Page_Type_Customize(7);
+         */
+        if(0 == printPageType){
+            // A4
+            printDataBean.setPageTypeEnum(PageTypeEnum.Page_Type_A4_Normal);
+        }else if(3 == printPageType){
+            // A5
+            printDataBean.setPageTypeEnum(PageTypeEnum.Page_Type_A5_Normal);
+        }else{
+            // 默认
+            printDataBean.setPageTypeEnum(PageTypeEnum.Page_Type_A4_Normal);
+        }
+
+        // 设定打印居中位置 0左边 1居中 2居右 不设置默认1
+        printDataBean.setHorAlignment(1);
+        //当出现打印过程中缺纸,是否重新打印上一页 默认为false ,不会重新打印该页
+        printDataBean.setReprintLastPage(true);
+
+        picturePrintTask.clear();
+        picturePrintTask.add(printDataBean);
+
+
+        UsbPrintPictureThreadTask pictureThreadTask = new UsbPrintPictureThreadTask(picturePrintTask, new UsbPrintPictureThreadTask.IPrinterListener() {
+            @Override
+            public void onPage(int i, int i1) {
+
+            }
+
+            @Override
+            public void onPrintCopies(int i, int i1) {
+
+            }
+
+            @Override
+            public void onStep(int i, int i1) {
+//                CommonLogUtils.e("i--"+i,
+//                        "i1--"+i1);
+            }
+
+            @Override
+            public void onDeviceStatus(String s) {
+                CommonLogUtils.e("s--"+s);
+            }
+
+            @Override
+            public void onPrintProcessState(PrintingStateEnum printingStateEnum) {
+                CommonLogUtils.e("printingStateEnum:"+printingStateEnum.toString());
+            }
+
+
+            @Override
+            public void onCompleted() {
+                CommonLogUtils.e("onCompleted");
+
+                cutPaper();
+            }
+        });
+
+        // 应该是打印次数
+        pictureThreadTask.setPrintCopies(1);
+
+
+        ThreadUtils.executeByCpu(pictureThreadTask);
+
+
+
+
+
     }
 
 
@@ -515,7 +620,8 @@ public class MlaFCDD215Printer implements IPrinter {
     @Override
     public void startPrint() {
 
-
+        // 有可能上次打印没有切掉
+//        cutPaper();
     }
 
 
@@ -550,16 +656,16 @@ public class MlaFCDD215Printer implements IPrinter {
         }
 
 
-        for (String key : allUseDevice.keySet()) {
-            CommonLogUtils.e("for-map-key:" + key);
-            UsbDevice usbDevice = allUseDevice.get(key);
-            if (PrinterNameUtil.startWithName(usbDevice.getProductName())){
-                CommonLogUtils.e(
-                        "for-deviceName=" + usbDevice.getDeviceName(),
-                        "for-productName =" + usbDevice.getProductName());
-            }
-
-        }
+//        for (String key : allUseDevice.keySet()) {
+//            CommonLogUtils.e("for-map-key:" + key);
+//            UsbDevice usbDevice = allUseDevice.get(key);
+//            if (PrinterNameUtil.startWithName(usbDevice.getProductName())){
+//                CommonLogUtils.e(
+//                        "for-deviceName=" + usbDevice.getDeviceName(),
+//                        "for-productName =" + usbDevice.getProductName());
+//            }
+//
+//        }
 
 
         if (UsbDeviceManager.getInstance().isConnect()) {

+ 10 - 1
lib_print/src/main/java/com/common/print/many/NullPrinter.java

@@ -1,8 +1,12 @@
 package com.common.print.many;
 
-import com.common.print.IPrinter;
+import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
+import com.common.print.many.base.IPrinter;
 import com.common.print.callback.PrintInitResultCallback;
 
+import java.util.List;
+
 /**
  * 空实现
  */
@@ -59,6 +63,11 @@ public class NullPrinter implements IPrinter {
 
     }
 
+    @Override
+    public void printTextBitmap(List<PrintContentBean> printContentList, PrintBean.PrintConfigDTO printConfigDTO) {
+
+    }
+
 
     @Override
     public void feed(int line) {

+ 10 - 1
lib_print/src/main/java/com/common/print/many/TbPrinter.java

@@ -7,7 +7,9 @@ import android.os.Handler;
 import android.util.Log;
 
 import com.common.lib_base.common.async.ThreadPoolManager;
-import com.common.print.IPrinter;
+import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
+import com.common.print.many.base.IPrinter;
 import com.common.print.callback.PrintInitResultCallback;
 import com.common.print.utils.BitmapUtils;
 import com.common.print.utils.CodeUtils;
@@ -15,6 +17,8 @@ import com.telpo.tps550.api.TelpoException;
 import com.telpo.tps550.api.printer.ThermalPrinter;
 import com.telpo.tps550.api.printer.UsbThermalPrinter;
 
+import java.util.List;
+
 /**
  * 天波
  * D2
@@ -270,6 +274,11 @@ public class TbPrinter implements IPrinter {
 
     }
 
+    @Override
+    public void printTextBitmap(List<PrintContentBean> printContentList, PrintBean.PrintConfigDTO printConfigDTO) {
+
+    }
+
     @Override
     public void feed(int line) {
         try {

+ 4 - 3
lib_print/src/main/java/com/common/print/IPrinter.java → lib_print/src/main/java/com/common/print/many/base/IPrinter.java

@@ -1,6 +1,7 @@
-package com.common.print;
+package com.common.print.many.base;
 
 import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
 import com.common.print.callback.PrintInitResultCallback;
 
 import java.util.List;
@@ -42,9 +43,9 @@ public interface IPrinter {
 
     /**
      * 将所有文字和图片转成一个Bitmap去打印
-     * @param printBean
+     * @param printContentList
      */
-//    void printTextBitmap(PrintBean.PrintListDTO printBean);
+    void printTextBitmap(List<PrintContentBean> printContentList,PrintBean.PrintConfigDTO printConfigDTO);
 
     /**
      * 走纸

+ 173 - 13
lib_print/src/main/java/com/common/print/utils/BitmapUtils.java

@@ -8,6 +8,7 @@ import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.Paint;
+import android.graphics.Rect;
 import android.graphics.Typeface;
 import android.graphics.drawable.Drawable;
 import android.os.Build;
@@ -30,7 +31,11 @@ import com.bumptech.glide.Glide;
 import com.bumptech.glide.request.target.CustomTarget;
 import com.bumptech.glide.request.transition.Transition;
 import com.common.lib_base.common.async.ThreadPoolManager;
+import com.common.lib_base.utils.StringUtils;
+import com.common.lib_base.utils.log.CommonLogUtils;
 import com.common.print.R;
+import com.common.print.bean.PrintBean;
+import com.common.print.bean.PrintContentBean;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonElement;
@@ -40,6 +45,7 @@ import com.google.zxing.EncodeHintType;
 import com.google.zxing.WriterException;
 import com.google.zxing.common.BitMatrix;
 import com.google.zxing.qrcode.QRCodeWriter;
+import com.jx800r09.sdk_800r09_library.enumdata.PageTypeEnum;
 
 import java.io.BufferedOutputStream;
 import java.io.File;
@@ -51,8 +57,10 @@ import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Locale;
 import java.util.concurrent.ExecutionException;
 
@@ -199,18 +207,6 @@ public class BitmapUtils {
 
 
 
-    public static Bitmap generateBitmap(String text,int textSizePx){
-        TextPaint textPaint = new TextPaint();
-        textPaint.setTextSize(textSizePx);
-        textPaint.setColor(Color.WHITE);
-        int width = (int) Math.ceil(textPaint.measureText(text));
-        Paint.FontMetrics fontMetrics = textPaint.getFontMetrics();
-        int height = (int) Math.ceil(Math.abs(fontMetrics.bottom) + Math.abs(fontMetrics.top));
-        Bitmap bitmap = Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888);
-        Canvas canvas = new Canvas(bitmap);
-        canvas.drawText(text,0,Math.abs(fontMetrics.ascent),textPaint);
-        return bitmap;
-    }
 
 
 
@@ -241,7 +237,7 @@ public class BitmapUtils {
 
         TextPaint textPaint = new TextPaint();
         // 80
-        textPaint.setTextSize(textSize);
+        textPaint.setTextSize(80);
         textPaint.setColor(Color.BLACK);
 
         Typeface typeface = ResourcesCompat.getFont(context, R.font.songti);
@@ -267,6 +263,170 @@ public class BitmapUtils {
 
 
 
+
+    public static Bitmap createTextBitmap(Context context, List<PrintContentBean> printContentList, int printPageType){
+
+        Bitmap bitmap;
+
+        /**
+         * Page_Type_A4_Normal(0),
+         * Page_Type_A4_Roll(1),
+         * Page_Type_A4_ANSI_A(2),
+         * Page_Type_A5_Normal(3),
+         * Page_Type_200mm(4),
+         * Page_Type_150mm(5),
+         * Page_Type_100mm(6),
+         * Page_Type_Customize(7);
+         */
+        if(0 == printPageType){
+            // A4
+            bitmap = Bitmap.createBitmap(1678,2397, Bitmap.Config.ARGB_8888);
+        }else if(3 == printPageType){
+            // A5
+            bitmap = Bitmap.createBitmap(1678,1198, Bitmap.Config.ARGB_8888);
+        }else{
+            // 默认
+            bitmap = Bitmap.createBitmap(1678,2397, Bitmap.Config.ARGB_8888);
+        }
+
+        Canvas canvas = new Canvas(bitmap);
+
+
+        // 绘制文字
+//        TextPaint textPaint = new TextPaint();
+//        // 80
+//        textPaint.setTextSize(80);
+//        textPaint.setColor(Color.BLACK);
+//        textPaint.setFakeBoldText(true);
+//
+//        // 设置字体
+        Typeface typeface = ResourcesCompat.getFont(context, R.font.songti);
+//        textPaint.setTypeface(typeface);// 采用自定义的字体——宋体
+
+
+        canvas.drawColor(Color.WHITE);
+
+
+
+        // 得到文字画笔
+        List<TextPaint> textPaintList = new ArrayList<>();
+
+        for (PrintContentBean printContentBean : printContentList) {
+
+            String text = printContentBean.getText();
+            if(StringUtils.isNotNull(text)){
+                int textSize = printContentBean.getTextSize();
+                boolean bold = printContentBean.isBold();
+
+                CommonLogUtils.e("text--"+text,
+                        "bold--"+bold);
+
+                TextPaint paint = new TextPaint();
+
+                paint.setTextSize(textSize);
+                paint.setColor(Color.BLACK);
+                paint.setFakeBoldText(bold);
+
+                paint.setTypeface(typeface);
+
+                textPaintList.add(paint);
+            }
+
+        }
+
+
+
+
+        // 循环
+//        for (PrintContentBean printContentBean : printContentList) {
+        for (int i = 0; i < printContentList.size(); i++) {
+            PrintContentBean printContentBean = printContentList.get(i);
+
+            String text = printContentBean.getText();
+            int textSize = printContentBean.getTextSize();
+            boolean bold = printContentBean.isBold();
+
+            int xPosition = printContentBean.getxPosition();
+            int yPosition = printContentBean.getyPosition();
+
+            String imageBase64 = printContentBean.getImageBase64();
+            int width = printContentBean.getWidth();
+            int height = printContentBean.getHeight();
+
+
+            if(StringUtils.isNotNull(text)){
+//                // 绘制文字
+//                TextPaint textPaint = new TextPaint();
+//                // 80
+//                textPaint.setTextSize(textSize);
+//                textPaint.setColor(Color.BLACK);
+//                textPaint.setFakeBoldText(bold);
+//
+//                // 设置字体
+//                Typeface typeface = ResourcesCompat.getFont(context, R.font.songti);
+//                textPaint.setTypeface(typeface);// 采用自定义的字体——宋体
+//
+//
+//                canvas.drawColor(Color.WHITE);
+
+//                canvas.drawText(text,xPosition,yPosition,textPaint);
+                canvas.drawText(text,xPosition,yPosition,textPaintList.get(i));
+
+//                canvas.drawText("测试1",xPosition+10,yPosition+10,textPaint);
+//
+//                canvas.drawText("测试2",xPosition+10,yPosition+10,textPaint);
+
+                CommonLogUtils.e("text--"+text,
+                        "xPosition--"+xPosition,
+                        "yPosition--"+yPosition);
+
+//                canvas.save();
+            }else if(StringUtils.isNotNull(imageBase64)){
+                // 绘制图片
+
+                Paint bitmapPaint = new Paint();
+
+                Bitmap imgBitmap = printContentBean.getPrintBitmap();
+
+//                CommonLogUtils.e("imageBase64--"+imageBase64);
+//
+//                if(imageBase64.contains("http")){
+//                    imgBitmap = BitmapUtils.urlToBitmap(imageBase64);
+//                }else{
+//                    imgBitmap = BitmapUtils.stringToBitmap(imageBase64);
+//                }
+
+
+
+
+                Rect dstRect = new Rect(xPosition, yPosition, width, yPosition + height);
+
+                CommonLogUtils.e("imgBitmap--"+imgBitmap);
+
+
+//                mHandler.postDelayed(new Runnable() {
+//                    @Override
+//                    public void run() {
+//
+//                    }
+//                })
+
+                canvas.drawBitmap(imgBitmap, null, dstRect, bitmapPaint); // srcRect 为 null
+
+//                canvas.save();
+            }
+        }
+
+
+        canvas.save();
+
+
+        return bitmap;
+
+    }
+
+
+
 //    public static Bitmap textPositionToBitmap(String text,int pos1,int pos2){
 //
 //

+ 246 - 246
lib_print/src/main/java/com/telpo/tps508/PrintUtile.java

@@ -1,246 +1,246 @@
-package com.telpo.tps508;
-
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Matrix;
-import android.os.Handler;
-import android.os.Looper;
-import android.util.Base64;
-import android.util.Log;
-
-import androidx.fragment.app.FragmentActivity;
-
-import com.caverock.androidsvg.SVG;
-import com.caverock.androidsvg.SVGParseException;
-import com.common.print.bean.PrintContentBean;
-import com.common.print.utils.CodeUtils;
-import com.telpo.tps550.api.TelpoException;
-import com.telpo.tps550.api.printer.UsbThermalPrinter;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * 小票打印
- */
-public class PrintUtile {
-    private static UsbThermalPrinter tps508Printer;
-    private static List<PrintContentBean> printContentBean=new ArrayList<>();
-    //用volatile关键字确保 instance 在多线程下的可见性
-    private static volatile PrintUtile instance = null;
-    private static OnPrintBaseListener listener;
-    static Activity mActivity;
-    //将构造方法私有化,禁止外部通过构造方法创建实例
-    private PrintUtile() {
-    }
-    //提供一个公共的访问方法,用于获取该类的唯一实例
-    public static PrintUtile getInstance(Context context) {
-        //如果instance为空,就进行实例化
-        if (instance == null) {
-            //保证多线程下只有一个线程进行实例化
-            synchronized (PrintUtile.class) {
-                //第二次判断,避免多线程下创建多个实例
-                if (instance == null) {
-                    instance = new PrintUtile(context);
-                }
-            }
-        }
-        return instance;
-    }
-    //构造函数私有化
-    public PrintUtile(Context context) {
-        if (context instanceof FragmentActivity) {
-            this.mActivity = (Activity) context;
-        }
-        tps508Printer = new UsbThermalPrinter(context);
-    }
-    //设备上电
-    public static void isPowerOn(){
-        if (tps508Printer==null){
-            return;
-        }
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                try {
-                    tps508Printer.start(0);
-                } catch (TelpoException e) {
-                    // TODO Auto-generated catch block
-                    e.printStackTrace();
-                }
-                Log.i("PrintUtile_isPowerOn","小票打印机上电完成");
-
-            }
-        }).start();
-    }
-    //打印
-    public static void startPrint(List<PrintContentBean> printContent) {
-        printContentBean.clear();
-        printContentBean.addAll(printContent);
-        new TPS508PrintThread().start();
-    }
-    private static class TPS508PrintThread extends Thread{
-        @Override
-        public void run() {
-            // TODO Auto-generated method stub
-            super.run();
-            Log.e("HHArome","TPS508PrintThread.run");
-            if (printContentBean.size()<=0){
-                return;
-            }
-            String pversion,gray,sversion = null;
-            try {
-                tps508Printer.reset();
-                tps508Printer.setGray(5);//设置打印灰度值 level:0-7,默认为1
-                gray = "5";
-                pversion = tps508Printer.getVersion();
-                final String tempPversion = pversion;
-                int Algin=0;
-                int textTime=0;
-                int imageTime=0;
-                Log.e("HHArome","TPS508PrintThread");
-                for (int i = 0; i < printContentBean.size(); i++) {
-                    if (printContentBean.get(i).getText()!=null
-                            &&!printContentBean.get(i).getText().equals("")){
-                        textTime+=1000;
-                        if (printContentBean.get(i).getAlgin().equals("right")){
-                            Algin=UsbThermalPrinter.ALGIN_RIGHT;
-                        } else if (printContentBean.get(i).getAlgin().equals("center")) {
-                            Algin=UsbThermalPrinter.ALGIN_MIDDLE;
-                        }else {
-                            Algin=UsbThermalPrinter.ALGIN_LEFT;
-                        }
-                        tps508Printer.setAlgin(Algin);//设置打印对齐方式
-                        tps508Printer.setTextSize(printContentBean.get(i).getTextSize());
-                        tps508Printer.addString(printContentBean.get(i).getText());
-                        tps508Printer.setBold(printContentBean.get(i).isBold());
-                    } else if (printContentBean.get(i).getQrCodeText()!=null
-                            &&!printContentBean.get(i).getQrCodeText().equals("")) {
-                        Bitmap bitmap=CodeUtils.createQRCodeBitmap(printContentBean.get(i).getQrCodeText(), 800, 800, "UTF-8", "M", "1", Color.BLACK, Color.WHITE
-                                , null, 0.2F,null);
-                        if (printContentBean.get(i).getWidth()==0){
-                            printContentBean.get(i).setWidth(376);
-                        }
-                        if (printContentBean.get(i).getHeight()==0){
-                            printContentBean.get(i).setHeight(376);
-                        }
-                        Bitmap bitmap1=zoomImg(bitmap,
-                                printContentBean.get(i).getWidth(),
-                                printContentBean.get(i).getHeight());
-                        tps508Printer.printLogo(bitmap1,true);
-                    } else if (printContentBean.get(i).getImageBase64()!=null
-                            &&!printContentBean.get(i).getImageBase64().equals("")){
-                        imageTime+=2000;
-                        //Bitmap bitmap=svgStringToBitmap(printContentBean.get(i).getImageBase64());
-                        Bitmap bitmap=stringToBitmap(printContentBean.get(i).getImageBase64());
-
-                        if (printContentBean.get(i).getWidth()==0){
-                            printContentBean.get(i).setWidth(376);
-                        }
-                        if (printContentBean.get(i).getHeight()==0){
-                            printContentBean.get(i).setHeight(376);
-                        }
-                        Bitmap bitmap1=zoomImg(bitmap,
-                                printContentBean.get(i).getWidth(),
-                                printContentBean.get(i).getHeight());
-                        tps508Printer.printLogo(bitmap,true);
-                    }
-                }
-                tps508Printer.printString();//启动打印,打印完不走纸
-                tps508Printer.walkPaper(15);
-                Looper.prepare();
-                new Handler().postDelayed(new Runnable() {
-                    @Override
-                    public void run() {
-                        listener.PrintingComplete();
-                    }
-                },textTime+imageTime);
-                Looper.loop();
-                Thread.sleep(30000);
-            }
-            catch (TelpoException e) {
-                // TODO Auto-generated catch block
-                e.printStackTrace();
-                Log.e("HHArome","TelpoException");
-                Log.e("HHArome","TelpoException--e:"+e.toString());
-            }
-            catch (InterruptedException e) {
-                e.printStackTrace();
-                Log.e("HHArome","InterruptedException");
-            }
-            catch (Exception e) {
-                e.printStackTrace();
-                Log.e("HHArome","Exception");
-            }
-        }
-    }
-    //停止打印机服务
-    public static void stopPrint(){
-        tps508Printer.stop();
-    }
-    public static Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) {
-        Bitmap newbm = null;
-        if (bm != null) {
-            // 获得图片的宽高
-            int width = bm.getWidth();
-            int height = bm.getHeight();
-            // 计算缩放比例
-            float scaleWidth = ((float) newWidth) / width;
-            float scaleHeight = ((float) newHeight) / height;
-            // 取得想要缩放的matrix参数
-            Matrix matrix = new Matrix();
-            matrix.postScale(scaleWidth, scaleHeight);
-            // 得到新的图片
-            newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
-        }
-        return newbm;
-    }
-    public static Bitmap stringToBitmap(String string) {
-        // 将字符串转换成Bitmap类型
-        Bitmap bitmap = null;
-        try {
-            byte[] bitmapArray;
-            bitmapArray = Base64.decode(string, Base64.DEFAULT);
-            bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
-                    bitmapArray.length);
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return bitmap;
-    }
-    public static Bitmap svgStringToBitmap(String svgString) throws SVGParseException {
-        // 将Base64解码回字节数组
-        byte[] decodedBytes = Base64.decode(svgString, Base64.DEFAULT);
-
-        // 创建一个输入流用于读取SVG数据
-        InputStream svgStream = new ByteArrayInputStream(decodedBytes);
-
-        // 解析SVG
-        SVG svg = null;
-        svg = SVG.getFromInputStream(svgStream);
-        // 获取SVG的画布尺寸
-        int width = (int) svg.getDocumentWidth();
-        int height = (int) svg.getDocumentHeight();
-
-        // 创建一个Bitmap用于绘制SVG
-        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
-        Canvas canvas = new Canvas(bitmap);
-
-        // 在Canvas上绘制SVG
-        svg.renderToCanvas(canvas);
-
-        return bitmap;
-    }
-    public static void setListener(OnPrintBaseListener lister) {
-        listener = lister;
-    }
-    public interface OnPrintBaseListener {
-        void PrintingComplete();
-    }
-}
+//package com.telpo.tps508;
+//
+//import android.app.Activity;
+//import android.content.Context;
+//import android.graphics.Bitmap;
+//import android.graphics.BitmapFactory;
+//import android.graphics.Canvas;
+//import android.graphics.Color;
+//import android.graphics.Matrix;
+//import android.os.Handler;
+//import android.os.Looper;
+//import android.util.Base64;
+//import android.util.Log;
+//
+//import androidx.fragment.app.FragmentActivity;
+//
+//import com.caverock.androidsvg.SVG;
+//import com.caverock.androidsvg.SVGParseException;
+//import com.common.print.bean.PrintContentBean;
+//import com.common.print.utils.CodeUtils;
+//import com.telpo.tps550.api.TelpoException;
+//import com.telpo.tps550.api.printer.UsbThermalPrinter;
+//
+//import java.io.ByteArrayInputStream;
+//import java.io.InputStream;
+//import java.util.ArrayList;
+//import java.util.List;
+//
+///**
+// * 小票打印
+// */
+//public class PrintUtile {
+//    private static UsbThermalPrinter tps508Printer;
+//    private static List<PrintContentBean> printContentBean=new ArrayList<>();
+//    //用volatile关键字确保 instance 在多线程下的可见性
+//    private static volatile PrintUtile instance = null;
+//    private static OnPrintBaseListener listener;
+//    static Activity mActivity;
+//    //将构造方法私有化,禁止外部通过构造方法创建实例
+//    private PrintUtile() {
+//    }
+//    //提供一个公共的访问方法,用于获取该类的唯一实例
+//    public static PrintUtile getInstance(Context context) {
+//        //如果instance为空,就进行实例化
+//        if (instance == null) {
+//            //保证多线程下只有一个线程进行实例化
+//            synchronized (PrintUtile.class) {
+//                //第二次判断,避免多线程下创建多个实例
+//                if (instance == null) {
+//                    instance = new PrintUtile(context);
+//                }
+//            }
+//        }
+//        return instance;
+//    }
+//    //构造函数私有化
+//    public PrintUtile(Context context) {
+//        if (context instanceof FragmentActivity) {
+//            this.mActivity = (Activity) context;
+//        }
+//        tps508Printer = new UsbThermalPrinter(context);
+//    }
+//    //设备上电
+//    public static void isPowerOn(){
+//        if (tps508Printer==null){
+//            return;
+//        }
+//        new Thread(new Runnable() {
+//            @Override
+//            public void run() {
+//                try {
+//                    tps508Printer.start(0);
+//                } catch (TelpoException e) {
+//                    // TODO Auto-generated catch block
+//                    e.printStackTrace();
+//                }
+//                Log.i("PrintUtile_isPowerOn","小票打印机上电完成");
+//
+//            }
+//        }).start();
+//    }
+//    //打印
+//    public static void startPrint(List<PrintContentBean> printContent) {
+//        printContentBean.clear();
+//        printContentBean.addAll(printContent);
+//        new TPS508PrintThread().start();
+//    }
+//    private static class TPS508PrintThread extends Thread{
+//        @Override
+//        public void run() {
+//            // TODO Auto-generated method stub
+//            super.run();
+//            Log.e("HHArome","TPS508PrintThread.run");
+//            if (printContentBean.size()<=0){
+//                return;
+//            }
+//            String pversion,gray,sversion = null;
+//            try {
+//                tps508Printer.reset();
+//                tps508Printer.setGray(5);//设置打印灰度值 level:0-7,默认为1
+//                gray = "5";
+//                pversion = tps508Printer.getVersion();
+//                final String tempPversion = pversion;
+//                int Algin=0;
+//                int textTime=0;
+//                int imageTime=0;
+//                Log.e("HHArome","TPS508PrintThread");
+//                for (int i = 0; i < printContentBean.size(); i++) {
+//                    if (printContentBean.get(i).getText()!=null
+//                            &&!printContentBean.get(i).getText().equals("")){
+//                        textTime+=1000;
+//                        if (printContentBean.get(i).getAlgin().equals("right")){
+//                            Algin=UsbThermalPrinter.ALGIN_RIGHT;
+//                        } else if (printContentBean.get(i).getAlgin().equals("center")) {
+//                            Algin=UsbThermalPrinter.ALGIN_MIDDLE;
+//                        }else {
+//                            Algin=UsbThermalPrinter.ALGIN_LEFT;
+//                        }
+//                        tps508Printer.setAlgin(Algin);//设置打印对齐方式
+//                        tps508Printer.setTextSize(printContentBean.get(i).getTextSize());
+//                        tps508Printer.addString(printContentBean.get(i).getText());
+//                        tps508Printer.setBold(printContentBean.get(i).isBold());
+//                    } else if (printContentBean.get(i).getQrCodeText()!=null
+//                            &&!printContentBean.get(i).getQrCodeText().equals("")) {
+//                        Bitmap bitmap=CodeUtils.createQRCodeBitmap(printContentBean.get(i).getQrCodeText(), 800, 800, "UTF-8", "M", "1", Color.BLACK, Color.WHITE
+//                                , null, 0.2F,null);
+//                        if (printContentBean.get(i).getWidth()==0){
+//                            printContentBean.get(i).setWidth(376);
+//                        }
+//                        if (printContentBean.get(i).getHeight()==0){
+//                            printContentBean.get(i).setHeight(376);
+//                        }
+//                        Bitmap bitmap1=zoomImg(bitmap,
+//                                printContentBean.get(i).getWidth(),
+//                                printContentBean.get(i).getHeight());
+//                        tps508Printer.printLogo(bitmap1,true);
+//                    } else if (printContentBean.get(i).getImageBase64()!=null
+//                            &&!printContentBean.get(i).getImageBase64().equals("")){
+//                        imageTime+=2000;
+//                        //Bitmap bitmap=svgStringToBitmap(printContentBean.get(i).getImageBase64());
+//                        Bitmap bitmap=stringToBitmap(printContentBean.get(i).getImageBase64());
+//
+//                        if (printContentBean.get(i).getWidth()==0){
+//                            printContentBean.get(i).setWidth(376);
+//                        }
+//                        if (printContentBean.get(i).getHeight()==0){
+//                            printContentBean.get(i).setHeight(376);
+//                        }
+//                        Bitmap bitmap1=zoomImg(bitmap,
+//                                printContentBean.get(i).getWidth(),
+//                                printContentBean.get(i).getHeight());
+//                        tps508Printer.printLogo(bitmap,true);
+//                    }
+//                }
+//                tps508Printer.printString();//启动打印,打印完不走纸
+//                tps508Printer.walkPaper(15);
+//                Looper.prepare();
+//                new Handler().postDelayed(new Runnable() {
+//                    @Override
+//                    public void run() {
+//                        listener.PrintingComplete();
+//                    }
+//                },textTime+imageTime);
+//                Looper.loop();
+//                Thread.sleep(30000);
+//            }
+//            catch (TelpoException e) {
+//                // TODO Auto-generated catch block
+//                e.printStackTrace();
+//                Log.e("HHArome","TelpoException");
+//                Log.e("HHArome","TelpoException--e:"+e.toString());
+//            }
+//            catch (InterruptedException e) {
+//                e.printStackTrace();
+//                Log.e("HHArome","InterruptedException");
+//            }
+//            catch (Exception e) {
+//                e.printStackTrace();
+//                Log.e("HHArome","Exception");
+//            }
+//        }
+//    }
+//    //停止打印机服务
+//    public static void stopPrint(){
+//        tps508Printer.stop();
+//    }
+//    public static Bitmap zoomImg(Bitmap bm, int newWidth, int newHeight) {
+//        Bitmap newbm = null;
+//        if (bm != null) {
+//            // 获得图片的宽高
+//            int width = bm.getWidth();
+//            int height = bm.getHeight();
+//            // 计算缩放比例
+//            float scaleWidth = ((float) newWidth) / width;
+//            float scaleHeight = ((float) newHeight) / height;
+//            // 取得想要缩放的matrix参数
+//            Matrix matrix = new Matrix();
+//            matrix.postScale(scaleWidth, scaleHeight);
+//            // 得到新的图片
+//            newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);
+//        }
+//        return newbm;
+//    }
+//    public static Bitmap stringToBitmap(String string) {
+//        // 将字符串转换成Bitmap类型
+//        Bitmap bitmap = null;
+//        try {
+//            byte[] bitmapArray;
+//            bitmapArray = Base64.decode(string, Base64.DEFAULT);
+//            bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
+//                    bitmapArray.length);
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//        return bitmap;
+//    }
+//    public static Bitmap svgStringToBitmap(String svgString) throws SVGParseException {
+//        // 将Base64解码回字节数组
+//        byte[] decodedBytes = Base64.decode(svgString, Base64.DEFAULT);
+//
+//        // 创建一个输入流用于读取SVG数据
+//        InputStream svgStream = new ByteArrayInputStream(decodedBytes);
+//
+//        // 解析SVG
+//        SVG svg = null;
+//        svg = SVG.getFromInputStream(svgStream);
+//        // 获取SVG的画布尺寸
+//        int width = (int) svg.getDocumentWidth();
+//        int height = (int) svg.getDocumentHeight();
+//
+//        // 创建一个Bitmap用于绘制SVG
+//        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
+//        Canvas canvas = new Canvas(bitmap);
+//
+//        // 在Canvas上绘制SVG
+//        svg.renderToCanvas(canvas);
+//
+//        return bitmap;
+//    }
+//    public static void setListener(OnPrintBaseListener lister) {
+//        listener = lister;
+//    }
+//    public interface OnPrintBaseListener {
+//        void PrintingComplete();
+//    }
+//}

+ 59 - 59
lib_print/src/main/java/com/telpo/tps508/base/IPrintBase.java

@@ -1,59 +1,59 @@
-package com.telpo.tps508.base;
-
-import android.content.Context;
-import android.os.Build;
-import android.util.Log;
-
-import com.common.print.bean.PrintContentBean;
-import com.telpo.tps508.PrintUtile;
-
-import java.util.List;
-
-
-/**
- * Created by L470 on 2020/6/8.
- * 打印机
- */
-
-public class IPrintBase {
-
-    Context mContext;
-    private static volatile IPrintBase instance;
-
-    public static IPrintBase getInstance(Context context) {
-        if (instance == null) {
-            synchronized (IPrintBase.class) {
-                if (instance == null) {
-                    instance = new IPrintBase(context);
-                }
-            }
-        }
-        return instance;
-    }
-
-    public IPrintBase(Context context) {
-        this.mContext = context;
-    }
-
-    public PrintUtile getIDCardScanEngine(Context context) {
-        String model = Build.MODEL;
-        return PrintUtile.getInstance(context);
-    }
-
-    //设备上电
-    public void isPowerOnPrint() {
-        PrintUtile.isPowerOn();
-        Log.e("HHArome","isPowerOnPrint---设备上电");
-    }
-    //设备打印
-    public void startPrint(List<PrintContentBean> printContent) {
-        PrintUtile.startPrint(printContent);
-        Log.e("HHArome","startPrint");
-    }
-
-    public void stop(){
-        PrintUtile.stopPrint();
-    }
-
-
-}
+//package com.telpo.tps508.base;
+//
+//import android.content.Context;
+//import android.os.Build;
+//import android.util.Log;
+//
+//import com.common.print.bean.PrintContentBean;
+//import com.telpo.tps508.PrintUtile;
+//
+//import java.util.List;
+//
+//
+///**
+// * Created by L470 on 2020/6/8.
+// * 打印机
+// */
+//
+//public class IPrintBase {
+//
+//    Context mContext;
+//    private static volatile IPrintBase instance;
+//
+//    public static IPrintBase getInstance(Context context) {
+//        if (instance == null) {
+//            synchronized (IPrintBase.class) {
+//                if (instance == null) {
+//                    instance = new IPrintBase(context);
+//                }
+//            }
+//        }
+//        return instance;
+//    }
+//
+//    public IPrintBase(Context context) {
+//        this.mContext = context;
+//    }
+//
+//    public PrintUtile getIDCardScanEngine(Context context) {
+//        String model = Build.MODEL;
+//        return PrintUtile.getInstance(context);
+//    }
+//
+//    //设备上电
+//    public void isPowerOnPrint() {
+//        PrintUtile.isPowerOn();
+//        Log.e("HHArome","isPowerOnPrint---设备上电");
+//    }
+//    //设备打印
+//    public void startPrint(List<PrintContentBean> printContent) {
+//        PrintUtile.startPrint(printContent);
+//        Log.e("HHArome","startPrint");
+//    }
+//
+//    public void stop(){
+//        PrintUtile.stopPrint();
+//    }
+//
+//
+//}

Some files were not shown because too many files changed in this diff