From 97a1c1235038d6f72c5f0873a92e99a038c2cd61 Mon Sep 17 00:00:00 2001 From: 吴祝攀 <2040239371@qq.com> Date: 星期四, 29 二月 2024 15:09:46 +0800 Subject: [PATCH] APIFan变更为API_Fan --- src/main/java/com/ots/project/tool/PdfUtil.java | 34 +++++++++++++++++++++++++++++----- 1 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java index 3c9ac24..5a2b380 100644 --- a/src/main/java/com/ots/project/tool/PdfUtil.java +++ b/src/main/java/com/ots/project/tool/PdfUtil.java @@ -3,10 +3,9 @@ import com.aspose.words.*; import lombok.extern.slf4j.Slf4j; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import java.io.*; import java.lang.reflect.Constructor; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -18,7 +17,7 @@ * 璁剧疆鐢ㄦ埛瀛椾綋浣嶇疆 */ public static void setFont() { - String[] fonts = {"C:\\Users\\澶уご\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "C:\\Users\\datou\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "/usr/share/fonts"}; + String[] fonts = {"C:\\Windows\\Fonts", "C:\\Users\\datou\\AppData\\Local\\Microsoft\\Windows\\Fonts\\", "/usr/share/fonts"}; List<FontSourceBase> fontSources = new ArrayList(Arrays.asList(FontSettings.getDefaultInstance().getFontsSources())); for (int i = 0; i < fonts.length; i++) { FolderFontSource folderFontSource = new FolderFontSource(fonts[i], true); @@ -43,6 +42,31 @@ out.close(); long now = System.currentTimeMillis(); log.info("doc杞琾df鑰楁椂锛歿}绉�", ((now - old) / 1000.0)); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * docker word杞琾df + * @param profile + * @param docx2pdfPath + * @param fileName + */ + public static void dockerConvertPDF(String profile,String docx2pdfPath,String fileName){ + try { + String command = MessageFormat.format(docx2pdfPath,profile,fileName); + // 鎵цdocker 鍛戒护 + Process proc = Runtime.getRuntime().exec(command); + BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream(), "GBK")); + String line = null; + log.info("docker鎵ц鍛戒护:{}", command); + log.info("docker鎵ц杩斿洖"); + while ((line = in.readLine()) != null) { + log.info(line); + } + in.close(); + proc.waitFor(); } catch (Exception e) { e.printStackTrace(); } @@ -82,7 +106,7 @@ public static void main(String[] args) { //convertPDF("D:\\娴嬭瘎绯荤粺\\home\\鏋梍PAQ_GS_TH.docx"); - convertPDF("C:\\Users\\澶уご\\Desktop\\鏋�3_CIAQ_IA_CN.docx"); + convertPDF("C:\\Users\\mac\\Desktop\\API_Fan_IA_CN.docx"); } } -- Gitblit v1.9.1