测试代码变动

This commit is contained in:
2025-11-13 17:20:08 +08:00
parent 04ccffd32d
commit 15e55bd12b
5 changed files with 14 additions and 34 deletions

View File

@@ -19,6 +19,11 @@
<artifactId>document-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.2</version>
</dependency>
<!-- 基础 Spring Boot Starter不包含 Web -->
<dependency>
@@ -38,38 +43,8 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>application.yml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

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

View File

@@ -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";

View File

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

Binary file not shown.