From 99f7f9adac08f3a3fa3211f7a6062c26d62fa224 Mon Sep 17 00:00:00 2001
From: 林致杰 <1003392067@qq.com>
Date: 星期日, 26 六月 2022 18:35:15 +0800
Subject: [PATCH] 组别报告解析生成

---
 src/main/java/com/ots/project/tool/PdfUtil.java |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java
index 7745ebd..5bd4622 100644
--- a/src/main/java/com/ots/project/tool/PdfUtil.java
+++ b/src/main/java/com/ots/project/tool/PdfUtil.java
@@ -13,21 +13,24 @@
 @Slf4j
 public class PdfUtil {
 
+    /**
+     * 璁剧疆鐢ㄦ埛瀛椾綋浣嶇疆
+     */
     public static void setFont(){
-        String userfontsfoloder = "C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts\\";
-        log.info("font璺緞:{}",userfontsfoloder);
+        String[] fonts = {"C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts\\","C:\\Users\\datou\\AppData\\Local\\Microsoft\\Windows\\Fonts\\","/usr/share/fonts"};
         List<FontSourceBase> fontSources = new ArrayList(Arrays.asList(FontSettings.getDefaultInstance().getFontsSources()));
-        FolderFontSource folderFontSource = new FolderFontSource(userfontsfoloder,true);
-        fontSources.add(folderFontSource);
+        for (int i = 0; i < fonts.length; i++) {
+            FolderFontSource folderFontSource = new FolderFontSource(fonts[i],true);
+            fontSources.add(folderFontSource);
+        }
         FontSourceBase[] fontSourceBases = fontSources.toArray(new FontSourceBase[fontSources.size()]);
         FontSettings.getDefaultInstance().setFontsSources(fontSourceBases);
     }
 
     public static void convertPDF(String input){
         try {
-            //setFont();
+            setFont();
             Document pres = null;
-            FontSettings.getDefaultInstance().setFontsFolder("C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts", true);
             //鎵嬪姩鏇挎崲杈撳嚭pdf鍚嶇О
             String output = input.replaceAll(".docx", ".pdf");
             long old = System.currentTimeMillis();
@@ -45,7 +48,7 @@
 
     public static void main(String[] args) {
         //convertPDF("D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_GS_TH.docx");
-        convertPDF("D:\\home\\PAQ绠�鏄撶増銆愭嘲鏂囥��.docx");
+        convertPDF("C:\\Users\\澶уご\\Desktop\\MAQ缁勫埆鎶ュ憡\\娴嬭瘯_MAQTR_IA_EN.docx");
     }
 
 }

--
Gitblit v1.9.1