From a5766b31d3a01bb6d1debfba041613559a704bc7 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Tue, 25 Mar 2025 11:47:05 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=86=99Linux=E4=B8=8Bword=E8=BD=ACpd?= =?UTF-8?q?f?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../industry/software/common/util/OfficeFileUtil.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java index 1850a5b..1bfb054 100644 --- a/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java +++ b/electromagnetic-common/src/main/java/com/electromagnetic/industry/software/common/util/OfficeFileUtil.java @@ -57,14 +57,8 @@ public class OfficeFileUtil { } } else { try { - String pdfParentDir = FileUtil.getParent(pdfPath, 1) + File.separatorChar + IdUtil.fastSimpleUUID() + File.separatorChar; StringBuilder command = new StringBuilder(); - command.append("/usr/bin/libreoffice24.8").append(" ").append("--headless") - .append(" ").append("--convert-to") - .append(" ").append("pdf") - .append(" ").append(wordPath) - .append(" ").append("--outdir") - .append(" ").append(pdfParentDir); + command.append("unoconv -f pdf -o").append(" ").append(pdfPath).append(" ").append(wordPath); log.info("convert word file to pdf, command: {}", command); Process process = RuntimeUtil.exec(command.toString()); process.waitFor(); @@ -72,9 +66,6 @@ public class OfficeFileUtil { String info = StrFormatter.format("word文档{}转换成pdf文档{}失败", wordPath, pdfPath); throw new BizException(info); } - String outPdfPath = FileUtil.loopFiles(pdfParentDir).get(0).getAbsolutePath(); - FileUtil.move(new File(outPdfPath), new File(pdfPath), true); - } catch (Exception e) { log.error(e.getMessage(), e); throw new BizException(e.getMessage(), e);