首页 > 其他 > 详细

word 转 pfd

时间:2019-09-23 18:50:00      阅读:104      评论:0      收藏:0      [点我收藏+]

转自:

https://www.cnblogs.com/qiwu1314/p/6101400.html

 

demo:

技术分享图片

 

 

 

public class Doc2Pdf {
public static boolean getLicense(){
boolean result = false;
try{

InputStream is = Doc2Pdf.class.getClassLoader().getResourceAsStream("license.xml");
License license = new License();
license.setLicense(is);
return true;
}catch (Exception e){
e.printStackTrace();
return false;
}
}

public static void doc2pfd(String address){

if(!getLicense()){
System.out.println("license结果:false" );
return;
}
try{
long old = System.currentTimeMillis();
File file = new File("E:/test/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 相互转换
long now = System.currentTimeMillis();
System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒"); //转化用时
}catch (Exception e){

}
}

public static void main(String[] args) {
Doc2Pdf.doc2pfd("E:/test/test.docx");
}
}

<License>
<Data>
<Products>
<Product>Aspose.Total for Java</Product>
<Product>Aspose.Words for Java</Product>
</Products>
<EditionType>Enterprise</EditionType>
<SubscriptionExpiry>20991231</SubscriptionExpiry>
<LicenseExpiry>20991231</LicenseExpiry>
<SerialNumber>23dcc79f-44ec-4a23-be3a-03c1632404e9</SerialNumber>
</Data>
<Signature>0nRuwNEddXwLfXB7pw66G71MS93gW8mNzJ7vuh3Sf4VAEOBfpxtHLCotymv1PoeukxYe31K441Ivq0Pkvx1yZZG4O1KCv3Omdbs7uqzUB4xXHlOub4VsTODzDJ5MWHqlRCB1HHcGjlyT2sVGiovLt0Grvqw5+QXBuinoBY0suX0=</Signature>
</License>



word 转 pfd

原文:https://www.cnblogs.com/maohuidong/p/11573636.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!