POM引入Jar(本人把jar放在项目的src/main/resources/lib目录下):
<dependencies> <dependency> <groupId>e-iceblue</groupId> <artifactId>spire.doc</artifactId> <version>2.2.0</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/spire.doc-2.2.0.jar</systemPath> </dependency> </dependencies>
World转PDF实现代码:
import com.spire.doc.Document; import com.spire.doc.FileFormat; public class ToPDF { public static void main(String[] args) { //加载word示例文档 Document document = new Document(); document.loadFromFile("D:\test.docx"); //保存结果文档 document.saveToFile("toPDF.pdf",FileFormat.PDF); } }