JAVA------WORD转PDF,aspose-words-18.6-jdk16
下边是实现代码,JAR已经破解过
jar和代码 链接: https://pan.baidu.com/s/1DoBs90_QB_IZoxMCIpxSMg 提取码: agpj
import java.io.*;
import com.aspose.words.*;
public class DocToPdf {
public static boolean getLicense() {
boolean result = false;
try {
InputStream is = DocToPdf.class.getClassLoader()
.getResourceAsStream("license.xml"); // license.xml应放在src路径下
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void doc2pdf(String Address, String outPath) {
if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
return;
}
try {
long old = System.currentTimeMillis();
File file = new File(outPath); // 新建一个空白pdf文档
FileOutputStream os = new FileOutputStream(file);
Document doc = new Document(Address); // Address是将要被转化的word文档
doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML,
// OpenDocument, PDF, EPUB, XPS, SWF
// 相互转换
long now = System.currentTimeMillis();
System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
doc2pdf("C:/NoaWords/TaoHong/2019/3/22/3506572428761447.doc", "D:/pdf1.pdf");
}
}