先导入words的jar包
需要jar包的私聊我发你
代码如下:
import com.aspose.words.Document;
import java.io.File; public class WordToPdf {
public static void main(String[] args) {
try {
//doc路径
Document document = new Document("C:\\Users\\pc\\Desktop\\1335924693531.doc");
//pdf路径
File outputFile = new File("C:\\Users\\pc\\Desktop\\结果.pdf");
//操作文档保存
document.save(outputFile.getAbsolutePath(), com.aspose.words.SaveFormat.PDF);
} catch (Exception e) {
e.printStackTrace();
}
}
}