• 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) + "秒
    
    " + "文件保存在:" + 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文档

  • 相关阅读:
    网络爬虫基础练习
    综合练习-词频统计
    组合数据类型
    【Hadoop】Hadoop综合大作业
    理解MapReduce操作
    Hadoop-熟悉常用的HDFS操作
    python-爬取中药信息
    Pytthon-数据结构化与保存
    python-爬取校园新闻首页的新闻
    python-爬虫基础
  • 原文地址:https://www.cnblogs.com/qiwu1314/p/6121649.html
Copyright © 2020-2023  润新知