Переглянути джерело

3.4.5 update-20250514 内嵌字体

xiaofei 1 місяць тому
батько
коміт
1918b98785

+ 4 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/util/PdfFillUtils.java

@@ -42,6 +42,7 @@ public class PdfFillUtils {
     public static Font textFont10;
     public static Font textFont9;
     public static Font textFont8;
+    public static BaseFont bfChinese;
 
     // 静态代码块
     static {
@@ -51,7 +52,7 @@ public class PdfFillUtils {
             InputStream fontStream = FileUtil.getStream("fonts/SimSun.ttf");
             // 将InputStream转换为byte数组
             byte[] fontData = StreamUtil.inputStreamToArray(fontStream);
-            BaseFont bfChinese = BaseFont.createFont("SimSun.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, BaseFont.CACHED, fontData, null);
+            bfChinese = BaseFont.createFont("SimSun.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, BaseFont.CACHED, fontData, null);
             textFont28 = new Font(bfChinese, 28);
             textFont24 = new Font(bfChinese, 24);
             textFont22 = new Font(bfChinese, 22);
@@ -484,6 +485,8 @@ public class PdfFillUtils {
         //设置字体
         if (hideCode) {
             barcode128.setFont(null);
+        } else {
+            barcode128.setFont(bfChinese);
         }
         return barcode128.createImageWithBarcode(writer.getDirectContent(), barColor, textColor);
     }