java利用Aspose.slides.jar將本地ppt文檔轉化成pdf(完美破解版 無水印 無中文亂碼)


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

JAVA代碼

 1 package webViewer;
 2 
 3 import java.io.*;  
 4 import com.aspose.slides.*;         //引入aspose.slides-15.9.0.jar包
 5 
 6 public class Ppt2Pdf {
 7      private static InputStream license;
 8 
 9         /**
10          * 獲取license
11          * 
12          * @return
13          */
14         public static boolean getLicense() {
15             boolean result = false;
16             try {
17                 license = Test.class.getClassLoader().getResourceAsStream("license.xml");// license路徑
18                 License aposeLic = new License();
19                 aposeLic.setLicense(license);
20                 result = true;
21             } catch (Exception e) {
22                 e.printStackTrace();
23             }
24             return result;
25         }
26 
27         /**
28          * 
29          * @param args
30          */
31         public static void ppt2pdf(String Address) {
32             // 驗證License
33             if (!getLicense()) {
34                 return;
35             }
36 
37             try {
38            //   long old = System.currentTimeMillis();
39                 File file = new File("C:/Program Files (x86)/Apache Software Foundation/Tomcat 7.0/webapps/generic/web/file/pdf1.pdf");// 輸出pdf路徑
40                 Presentation pres = new Presentation(Address);//輸入pdf路徑         
41                 FileOutputStream fileOS = new FileOutputStream(file);
42                 pres.save(fileOS, SaveFormat.Pdf);
43                 fileOS.close();
44 
45           //    long now = System.currentTimeMillis();
46           //    System.out.println("共耗時:" + ((now - old) / 1000.0) + "秒\n\n" + "文件保存在:" + file.getPath()); //轉化過程耗時
47             } catch (Exception e) {
48                 e.printStackTrace();
49             }
50         }
51 }

調用代碼

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

即可生成pdf文檔

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM