wd hace 4 años
padre
commit
5fbad19dea
Se han modificado 1 ficheros con 8 adiciones y 2 borrados
  1. 8 2
      src/main/java/com/common/workflow/service/util/Word2Pdf.java

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

@@ -44,8 +44,14 @@ public class Word2Pdf {
             Document doc = new Document(inputStream);// 原始excel路径
 
             FontSettings font = new FontSettings();
-            font.setFontsFolder(File.separator + "usr" + File.separator + "share" + File.separator + "fonts", true);
-            font.setDefaultFontName("KaiTi");
+            String path = "/usr/share/fonts";
+            FolderFontSource folderFontSource = new FolderFontSource(path, true);
+            ArrayList fontSources = (ArrayList) Arrays.asList(font.getFontsSources());
+            fontSources.add(folderFontSource);
+            FontSourceBase[] updatedFontSources = (FontSourceBase[]) fontSources.toArray(new FontSourceBase [fontSources.size()]);
+//            font.setFontsFolder(path, true);
+//            font.setDefaultFontName("KaiTi");
+            font.setFontsSources(updatedFontSources);
             doc.setFontSettings(font);
 
             /*PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(SaveFormat.PDF);