调通了。

This commit is contained in:
chenxudong 2025-08-12 18:27:43 +08:00
parent 5bf8e615e0
commit 78e2df602a
2 changed files with 5 additions and 3 deletions

View File

@ -58,12 +58,12 @@
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>1.0.3</version>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>1.0.3</version>
<version>1.1.3</version>
</dependency>
<!--处理word文档需要的额外的jar包-->
<dependency>

View File

@ -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)