恢复到以前

This commit is contained in:
chenxudong 2025-08-13 09:36:13 +08:00
parent 78e2df602a
commit bad2cbc494
2 changed files with 3 additions and 5 deletions

View File

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

View File

@ -51,13 +51,11 @@ public class OfficeFileUtil {
} }
log.info("Start convert word file to pdf, word path: {}, pdf path: {}", wordPath, pdfPath); log.info("Start convert word file to pdf, word path: {}, pdf path: {}", wordPath, pdfPath);
if (EleCommonUtil.isWinOs()) { if (EleCommonUtil.isWinOs()) {
String tmpPath = FileUtil.getParent(pdfPath, 1);
File workDir = new File(tmpPath);
File inputWord = new File(wordPath); File inputWord = new File(wordPath);
File outputFile = new File(pdfPath); File outputFile = new File(pdfPath);
try (InputStream docxInputStream = Files.newInputStream(inputWord.toPath()); try (InputStream docxInputStream = Files.newInputStream(inputWord.toPath());
OutputStream outputStream = Files.newOutputStream(outputFile.toPath())) { OutputStream outputStream = Files.newOutputStream(outputFile.toPath())) {
IConverter build = LocalConverter.builder().baseFolder(workDir).build(); IConverter build = LocalConverter.builder().build();
boolean execute; boolean execute;
if (wordPath.endsWith(".docx")) { if (wordPath.endsWith(".docx")) {
execute = build.convert(docxInputStream) execute = build.convert(docxInputStream)