- 博客(0)
- 资源 (1)
- 收藏
- 关注
aspose-words-19.6-jdk17.jar word转pdf工具,亲测可用
/**
* TODO(用一句话描述该文件的作用)
*
* @title: AsposeToPDF.java
* @author Administrator
* @date 2019年6月27日 下午5:02:42
*/
package com.lease.api.finance.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
/**
* TODO(这里用一句话描述这个类的作用)
*
* @className AsposeToPDF
* @author Administrator
* @version V1.0 2019年6月27日 下午5:02:42 TODO(如果是修改版本,描述修改内容)
*/
public class AsposeToPDF {
public static void main(String[] args) {
officeToPDF("D:\\print\\abc.doc",
"D:\\print\\abc.pdf");
}
public static void officeToPDF(String inPath, String outPath) {
FileOutputStream os = null;
try {
File file = new File(outPath); // 新建一个空白pdf文档
os = new FileOutputStream(file);
Document doc = new Document(inPath); // Address是将要被转化的word文档
doc.save(os, SaveFormat.PDF);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
2019-06-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅