online
pom
<dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-core</artifactId><version>4.2.2</version></dependency><!--springboot支持包,里面包括了自动配置类 --><dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-spring-boot-starter</artifactId><version>4.2.2</version></dependency><!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-online --><dependency><groupId>org.jodconverter</groupId><artifactId>jodconverter-online</artifactId><version>4.2.2</version></dependency>
yml
jodconverter:online:enabled: trueurl: http://10.1.20.58:9980
代码
@Autowiredprivate DocumentConverter documentConverter;@GetMapping("test")public void test(HttpServletResponse response) throws Exception {File file = new File("D:\\Download/123.docx");File outputFile = new File("D:\\Download/document.pdf");documentConverter.convert(file).to(outputFile).execute();}
local
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>4.2.2</version>
</dependency>
<!--springboot支持包,里面包括了自动配置类 -->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-spring-boot-starter</artifactId>
<version>4.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-online -->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-local</artifactId>
<version>4.2.2</version>
</dependency>
nacos
jodconverter:
local:
enabled: true
max-tasks-per-process: 10
port-numbers: 8110
office-home: C:\Program Files (x86)\OpenOffice 4
#office-home: /opt/openoffice4
使用同上
@Autowired
private DocumentConverter documentConverter;
@GetMapping("test")
public void test(HttpServletResponse response) throws Exception {
File file = new File("D:\\Download/123.docx");
File outputFile = new File("D:\\Download/document.pdf");
documentConverter.convert(file).to(outputFile).execute();
}
