word 转 pfd
Posted maohuidong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了word 转 pfd相关的知识,希望对你有一定的参考价值。
转自:
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的主要内容,如果未能解决你的问题,请参考以下文章