將office文件轉化成pdf,nginx代理進行預覽
1.安裝OpenOffice,並打開服務。
windows:進入cmd:
cd C:\Program Files (x86)\OpenOffice 4\program
soffice -headless -accept="socket,host=IP,port=8100;urp;" -nofirststar2.pom中導入jar包<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-local -->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-local</artifactId>
<version>4.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-spring-boot-starter -->
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-spring-boot-starter</artifactId>
<version>4.2.2</version>
</dependency>
3.SpringBoot配置文件
jodconverter.local.enabled=true
jodconverter.local.port-numbers=8100
4.編碼
import org.jodconverter.DocumentConverter;
@Autowired
private DocumentConverter documentConverter;
documentConverter.convert(oldFile).to(pdfFile).execute();