資源簡介
全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
EPUB, XPS, SWF 相互轉(zhuǎn)換 ,word轉(zhuǎn)pdf已做測試很好用!

代碼片段和文件信息
package?cpcns.utils;
import?java.io.File;
import?java.io.FileInputStream;
import?java.io.FileOutputStream;
import?java.io.InputStream;
import?com.aspose.words.Document;
import?com.aspose.words.License;
import?com.aspose.words.SaveFormat;
public?class?Word2Pdf?{
?public?static?void?doc2pdf(String?inPath?String?outPath)?{??
????????try?{??
????????????long?old?=?System.currentTimeMillis();
????????????//注冊
????????????String?path?=?new?Word2Pdf().getClass().getResource(“/“).getPath();
path?=?path.substring(1);
path?=?path.replace(“/WEB-INF/classes/“?“/WEB-INF/license.xml“);
????????????InputStream?is?=?new?FileInputStream(path);??
????????License?aposeLic?=?new?License();
????????aposeLic.setLicense(is);
????????
????????????File?file?=?new?File(outPath);?//?新建一個(gè)空白pdf文檔??
????????????FileOutputStream?os?=?new?FileOutputStream(file);??
????????????Document?doc?=?new?Document(inPath);?//?Address是將要被轉(zhuǎn)化的word文檔??
????????????doc.save(os?SaveFormat.PDF);//?全面支持DOC?DOCX?OOxml?RTF?HTML?OpenDocument?PDF??
?????????????????????????????????????????//?EPUB?XPS?SWF?相互轉(zhuǎn)換??
????????????long?now?=?System.currentTimeMillis();??
????????????System.out.println(“共耗時(shí):“?+?((now?-?old)?/?1000.0)?+?“秒“);?//?轉(zhuǎn)化用時(shí)??
????????}?catch?(Exception?e)?{??
????????????e.printStackTrace();??
????????}??
????}??
/**
?*?測試
?*?@param?args
?*/
public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub
String?filepath?=?“D:/word2pdf/1111.doc“;??
String?outpath?=?“D:/word2pdf/1111.pdf“;???
?????
doc2pdf(filepath?outpath);
}
}
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????1720??2018-04-18?11:37??word2pdf\Word2Pdf.java
?????文件????10269481??2018-04-17?18:13??word2pdf\aspose-words-15.8.0-jdk16.jar
?????文件?????????587??2018-04-18?11:37??word2pdf\license.xm
?????目錄???????????0??2018-04-18?16:09??word2pdf\
評論
共有 條評論