diff --git a/document-test/pom.xml b/document-test/pom.xml index 9e21255..898bb9e 100644 --- a/document-test/pom.xml +++ b/document-test/pom.xml @@ -19,6 +19,11 @@ document-api 2.0.0 + + com.deepoove + poi-tl + 1.12.2 + @@ -38,38 +43,8 @@ org.projectlombok lombok - 1.16.20 + 1.18.38 provided - - - - - org.apache.maven.plugins - maven-resources-plugin - 3.3.1 - - - copy-resources - process-resources - - copy-resources - - - ${project.build.directory} - - - src/main/resources - - application.yml - - - - - - - - - diff --git a/document-test/src/main/java/com/optima/document/test/bean/DocumentConverter.java b/document-test/src/main/java/com/optima/document/test/bean/DocumentConverter.java index 933412f..7fe254d 100644 --- a/document-test/src/main/java/com/optima/document/test/bean/DocumentConverter.java +++ b/document-test/src/main/java/com/optima/document/test/bean/DocumentConverter.java @@ -1,5 +1,6 @@ package com.optima.document.test.bean; +import com.deepoove.poi.data.Pictures; import com.optima.document.api.DocumentService; import com.optima.document.test.config.DocumentServiceConfig; import org.springframework.stereotype.Component; @@ -10,6 +11,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -42,6 +44,9 @@ public class DocumentConverter { departmentList.add("处置部门2"); params.put("departmentList", departmentList); + byte[] bytes = Files.readAllBytes(Paths.get("/Users/yanghuanglin/Downloads/02.png")); + params.put("img", Pictures.ofBytes(bytes).size(48, 27).create()); + // 生成word,并转为pdf byte[] generatedWord = documentService.generateWord(Files.readAllBytes(sourceFile.toPath()), params); byte[] wordedToPdf = documentService.wordToPdf(generatedWord, true); diff --git a/document-test/src/main/java/com/optima/document/test/config/DocumentServiceConfig.java b/document-test/src/main/java/com/optima/document/test/config/DocumentServiceConfig.java index b793210..dd456c7 100644 --- a/document-test/src/main/java/com/optima/document/test/config/DocumentServiceConfig.java +++ b/document-test/src/main/java/com/optima/document/test/config/DocumentServiceConfig.java @@ -8,7 +8,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean; - @Getter @Setter @Configuration @@ -23,6 +22,7 @@ public class DocumentServiceConfig { public DocumentService documentService() { // 创建客户端代理 HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean(); + String serviceUrl; if (server.endsWith("/")) { serviceUrl = server + "document-service"; diff --git a/document-test/src/main/resources/application.yml b/document-test/src/main/resources/application.yml index 231e1b9..e1c9e8d 100644 --- a/document-test/src/main/resources/application.yml +++ b/document-test/src/main/resources/application.yml @@ -1,4 +1,4 @@ document: server: http://127.0.0.1:9004 - source-file: /Users/yanghuanglin/Downloads/test.docx - target-file: /Users/yanghuanglin/Downloads/test.pdf + source-file: "/Volumes/Working/Works/Git Sources/document/document-test/src/main/resources/test.docx" + target-file: "/Users/yanghuanglin/Downloads/test.pdf" diff --git a/document-test/src/main/resources/test.docx b/document-test/src/main/resources/test.docx new file mode 100644 index 0000000..aa68d62 Binary files /dev/null and b/document-test/src/main/resources/test.docx differ