SpringBoot+OpenOffice Office文檔在線預覽


將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();
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM