Browse Source

市场管理:签章PDF导出的字体设置

baichengfei 4 years ago
parent
commit
78ce1e80e4
1 changed files with 2 additions and 5 deletions
  1. 2 5
      src/main/java/com/common/workflow/service/util/Word2Pdf.java

+ 2 - 5
src/main/java/com/common/workflow/service/util/Word2Pdf.java

@@ -44,6 +44,7 @@ public class Word2Pdf {
             Document doc = new Document(inputStream);// 原始excel路径
 
             FontSettings font = new FontSettings();
+            // String path = "./";  // 开发环境直接取项目目录下的SIMKAI.TTF 就能跑起来
             String path = "/usr/share/fonts";
             FolderFontSource folderFontSource = new FolderFontSource(path, true);
             // ArrayList fontSources = (ArrayList) Arrays.asList(font.getFontsSources());
@@ -52,11 +53,7 @@ public class Word2Pdf {
             fontSources.add(folderFontSource);
             FontSourceBase[] updatedFontSources = (FontSourceBase[]) fontSources.toArray(new FontSourceBase [fontSources.size()]);
             font.setFontsFolder(path, true);
-            font.setDefaultFontName("");
-            font.setDefaultFontName("SimHei");
-            font.setDefaultFontName("NSimSun");
-            font.setDefaultFontName("STFangsong");
-            font.setDefaultFontName("STZhongsong");
+            font.setDefaultFontName("SimKai");
             font.setFontsSources(updatedFontSources);
             doc.setFontSettings(font);