aspose实现word转pdf
压缩包里有三个aspose的jar包和java文件 我的是web项目 里面jar齐全 没发现需要什么 但是如果运行报错,请根据缺包提示加入相应jar包,还有注意license.xml文件路径,亲测可用,有问题可以留言
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-26 13:33 word转pdf
文件 6062936 2018-01-20 16:24 word转pdfaspose-cells-8.5.2.jar
文件 8543532 2018-01-20 16:24 word转pdfaspose-words-14.9.0-jdk16.jar
文件 2998 2018-01-20 16:24 word转pdfaspose_license.jar
文件 584 2018-01-22 10:31 word转pdflicense.xml
文件 1609 2018-01-26 13:32 word转pdfWord2Html.java
package com.jhq.web.util;
import java.io.File;
import java.io.FileOutputStream;
import junit.framework.Test;
import com.aspose.words.Document;
import com.aspose.words.SaveFormat;
public class Word2Html {
public static boolean getLicense() {
boolean result = false;
try {
java.io.InputStream is = Test.class.getClassLoader().getResourceAsStream(“license.xml“); // wordlicense.xml应放在..WebRootWEB-INFclasses路径下
com.aspose.words.License aposeLic = new com.aspose.words.License();
aposeLic.setLicense(is);
result = true;
}
catch (Exception e) {
e.printStackTrace();
}
return result;
}
public static void word2pdf(String Address) {
if (!getLicense()) { // 验证License 若不验证则转化出的PDP文档会有水印产生
return;
}
try {
File file = new File(“D:/pdf1.pdf“); //新建一个空白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 相互转换 os.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
word2pdf(“D:/论文.doc“);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-01-26 13:33 word转pdf
文件 6062936 2018-01-20 16:24 word转pdfaspose-cells-8.5.2.jar
文件 8543532 2018-01-20 16:24 word转pdfaspose-words-14.9.0-jdk16.jar
文件 2998 2018-01-20 16:24 word转pdfaspose_license.jar
文件 584 2018-01-22 10:31 word转pdflicense.xm
文件 1609 2018-01-26 13:32 word转pdfWord2Html.java
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)