From 765d9a3de208ba1ea9a10f9b1bd6fba08afd2079 Mon Sep 17 00:00:00 2001 From: 林致杰 <1003392067@qq.com> Date: 星期四, 26 十月 2023 16:02:44 +0800 Subject: [PATCH] 新增LAQ图表替换 --- src/main/java/com/ots/project/tool/PdfUtil.java | 32 +++++++++++--------------------- 1 files changed, 11 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/ots/project/tool/PdfUtil.java b/src/main/java/com/ots/project/tool/PdfUtil.java index e7d60a2..20b8711 100644 --- a/src/main/java/com/ots/project/tool/PdfUtil.java +++ b/src/main/java/com/ots/project/tool/PdfUtil.java @@ -5,6 +5,7 @@ import java.io.*; import java.lang.reflect.Constructor; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -47,31 +48,20 @@ } /** - * 鎵цpython鑴氭湰 docx杞琾df - * @param filePath + * docker word杞琾df + * @param profile + * @param docx2pdfPath + * @param fileName */ - public static void convertPythonPDF(String pythonScript,String filePath){ + public static void dockerConvertPDF(String profile,String docx2pdfPath,String fileName){ try { - File file = new File(filePath); - if(!file.exists()){ - file.mkdirs(); - } - //鎵嬪姩鏇挎崲杈撳嚭pdf鍚嶇О - String output = filePath.replaceAll(".docx", ".pdf"); - - String os = System.getProperty("os.name"); - String[] args1; - if (os.contains("Windows")){ - args1 = new String[] { "python", pythonScript, filePath, output }; - } else { - args1 = new String[] { "python3", pythonScript, filePath, output }; - } - // 鎵цpy鏂囦欢 - Process proc = Runtime.getRuntime().exec(args1); + 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("python鎵ц鍛戒护:{}", Arrays.toString(args1)); - log.info("python鎵ц杩斿洖"); + log.info("docker鎵ц鍛戒护:{}", command); + log.info("docker鎵ц杩斿洖"); while ((line = in.readLine()) != null) { log.info(line); } -- Gitblit v1.9.1