From 78e2df602ad6676545e466e1d70b279347d05393 Mon Sep 17 00:00:00 2001 From: chenxudong Date: Tue, 12 Aug 2025 18:27:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E9=80=9A=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electromagnetic-common/pom.xml | 4 ++-- .../industry/software/common/util/OfficeFileUtil.java | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/electromagnetic-common/pom.xml b/electromagnetic-common/pom.xml index 39d1e96..d6d79ca 100644 --- a/electromagnetic-common/pom.xml +++ b/electromagnetic-common/pom.xml @@ -58,12 +58,12 @@ com.documents4j documents4j-local - 1.0.3 + 1.1.3 com.documents4j documents4j-transformer-msoffice-word - 1.0.3 + 1.1.3 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 0cb766a..74fce03 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 @@ -51,11 +51,13 @@ public class OfficeFileUtil { } log.info("Start convert word file to pdf, word path: {}, pdf path: {}", wordPath, pdfPath); if (EleCommonUtil.isWinOs()) { + String tmpPath = FileUtil.getParent(pdfPath, 1); + File workDir = new File(tmpPath); File inputWord = new File(wordPath); File outputFile = new File(pdfPath); try (InputStream docxInputStream = Files.newInputStream(inputWord.toPath()); OutputStream outputStream = Files.newOutputStream(outputFile.toPath())) { - IConverter build = LocalConverter.builder().build(); + IConverter build = LocalConverter.builder().baseFolder(workDir).build(); boolean execute; if (wordPath.endsWith(".docx")) { execute = build.convert(docxInputStream)