标签:程序 stat 情况下 open ooxml catch -o getc move
一、概述:Aspose.Words是一个商业.NET类库,可以使得应用程序处理大量的文件任务。 public static void word2pdf(String Address) {
getLicense();
try {
File file = new File("D:\\red_ant_file\\20180919\\20180919.pdf"); // 新建一个空白pdf文档
FileOutputStream os = new FileOutputStream(file);
com.aspose.words.Document doc = new com.aspose.words.Document(Address); // Address是将要被转化的word文档
for (Section sect : doc.getSections()) {
removeWatermarkFromHeader(sect, HeaderFooterType.HEADER_PRIMARY);
removeWatermarkFromHeader(sect, HeaderFooterType.HEADER_FIRST);
removeWatermarkFromHeader(sect, HeaderFooterType.HEADER_EVEN);
}
doc.save(os, SaveFormat.PDF); // 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
os.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**word转pdf
*/
public static boolean getLicense() {
boolean result = false;
try {
// wordlicense.xml应放在..\WebContent\WEB-INF\classes路径下
InputStream is = Test.class.getClassLoader().getResourceAsStream("wordlicense.xml");
com.aspose.words.License aposeLic = new com.aspose.words.License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
调用:
String aposeword_Source_path = "D:\\red_ant_file\\20180919\\Extjs4.0_教程.doc";
AllServiceIsHere.word2pdf(aposeword_Source_path);
运行之后:
利用Aspose.Words处理Word文档之间的转换和内容操作
标签:程序 stat 情况下 open ooxml catch -o getc move
原文地址:http://blog.51cto.com/13479739/2177410