java利用Aspose.slides.jar将本地ppt文档转化成pdf(完美破解版 无水印 无中文乱码)

下载aspose.slides-15.9.0.jar包 http://pan.baidu.com/s/1jH3ZNbK

JAVA代码

 package webViewer;

 import java.io.*;
import com.aspose.slides.*; //引入aspose.slides-15.9.0.jar包 public class Ppt2Pdf {
private static InputStream license; /**
* 获取license
*
* @return
*/
public static boolean getLicense() {
boolean result = false;
try {
license = Test.class.getClassLoader().getResourceAsStream("license.xml");// license路径
License aposeLic = new License();
aposeLic.setLicense(license);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
} /**
*
* @param args
*/
public static void ppt2pdf(String Address) {
// 验证License
if (!getLicense()) {
return;
} try {
// long old = System.currentTimeMillis();
File file = new File("C:/Program Files (x86)/Apache Software Foundation/Tomcat 7.0/webapps/generic/web/file/pdf1.pdf");// 输出pdf路径
Presentation pres = new Presentation(Address);//输入pdf路径
FileOutputStream fileOS = new FileOutputStream(file);
pres.save(fileOS, SaveFormat.Pdf);
fileOS.close(); // long now = System.currentTimeMillis();
// System.out.println("共耗时:" + ((now - old) / 1000.0) + "秒\n\n" + "文件保存在:" + file.getPath()); //转化过程耗时
} catch (Exception e) {
e.printStackTrace();
}
}
}

调用代码

 package webViewer;

 public class Test {
public static void main(String[] args){
Ppt2Pdf.ppt2pdf("C:/Program Files (x86)/Apache Software Foundation/Tomcat 7.0/webapps/generic/web/file/6.ppt");
}
}

即可生成pdf文档

上一篇:Java自学教程!dockerlogin失败


下一篇:ping:unknown host www.baidu.com