其实真的很简单,今天突然小伙伴向我抱怨word转pdf超过一页要收费,问我怎么办?收费,不可能的。loading.....OK!
第一步找jar包:words.jar(貌似收费,不过在我TC,收费不存在的!!!)
第二部贴代码:
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\\CHENG\\Desktop\\数学建模定稿.docx");
//pdf路径
File outputFile = new File("C:\\Users\\CHENG\\Desktop\\数学建模定稿.pdf");
//操作文档保存
document.save(outputFile.getAbsolutePath(), com.aspose.words.SaveFormat.PDF);
} catch (Exception e) {
e.printStackTrace();
}
}
}
word转pdf成功!!!
-------------------------------------------------------------------------------------------
鉴于部分网友索取相关的jar包,补充相关的jar包需要自取
链接:https://pan.baidu.com/s/14ALkfES08fU0BQ_Vpl55LA
提取码:fuk8