pom依赖仓库地址
https://central.sonatype.com/artifact/com.luhuiguo/aspose-words/overview
<dependency>
<groupId>com.luhuiguo</groupId>
<artifactId>aspose-words</artifactId>
<version>23.1</version>
</dependency>
转化代码如下:
String from = "/tmp/test.docx";
String to = "/tmp/test.docx.pdf";
FileOutputStream os = null;
try {
long old = System.currentTimeMillis();
File file = new File(to);
os = new FileOutputStream(file);
Document doc = new Document(from);
doc.save(os, com.aspose.words.SaveFormat.PDF);
long now = System.currentTimeMillis();
System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
} finally {
if (os != null) {
os.close();
}
}