From 77f6cf1868777a27c033af7d6d4f2fe9d2afc30d Mon Sep 17 00:00:00 2001 From: 林致杰 <1003392067@qq.com> Date: 星期四, 19 十月 2023 18:26:43 +0800 Subject: [PATCH] LAQ支持,新增python转换 --- src/main/java/com/ots/project/tool/PdfUtil.java | 33 ++++++++++++++++++++++++++++++--- 1 files changed, 30 insertions(+), 3 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..1941a78 100644 --- a/src/main/java/com/ots/project/tool/PdfUtil.java +++ b/src/main/java/com/ots/project/tool/PdfUtil.java @@ -3,9 +3,7 @@ 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.util.ArrayList; import java.util.Arrays; @@ -49,6 +47,35 @@ } /** + * 鎵цpython鑴氭湰 docx杞琾df + * @param filePath + */ + public static void convertPythonPDF(String pythonScript,String filePath){ + try { + File file = new File(filePath); + if(!file.exists()){ + file.mkdirs(); + } + //鎵嬪姩鏇挎崲杈撳嚭pdf鍚嶇О + String output = filePath.replaceAll(".docx", ".pdf"); + String[] args1 = new String[] { "python3", pythonScript, filePath, output }; + // 鎵цpy鏂囦欢 + Process proc = Runtime.getRuntime().exec(args1); + BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream(), "GBK")); + String line = null; + log.info("python鎵ц鍛戒护:{}", Arrays.toString(args1)); + log.info("python鎵ц杩斿洖"); + while ((line = in.readLine()) != null) { + log.info(line); + } + in.close(); + proc.waitFor(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** * aspose-words:jdk17:23.4 鐗堟湰 */ public static void registerWord() throws Exception { -- Gitblit v1.9.1