使用aspose-slides将ppt转pdf

PPT转PDF

下载jar包

链接:https://pan.baidu.com/s/1a-9zm9aaiEcemXD5jaLXRw 
提取码:cu57 

添加到MVN仓库中

mvn install:install-file -Dfile="jar包位置" -DgroupId="groupId" -DartifactId="artifactId" -Dversion="版本" -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

导入依赖

		<!--将ppt转pdf 这是我自己的打包方式-->
        <dependency>
            <groupId>aspose</groupId>
            <artifactId>aspose-slides</artifactId>
            <version>19.3</version>
        </dependency>

代码

/**
     * ppt转成pdf
     * @param sourcePath ppt的文件路径
     * @param savePath pdf保存的路径
     */
    public static void pptToPdf(String sourcePath,String savePath){
        FileOutputStream outputStream = null;
        //水印处理
        final String license ="<License>\n" +
                "  <Data>\n" +
                "    <Products>\n" +
                "      <Product>Aspose.Total for Java</Product>      \n" +
                "    </Products>\n" +
                "    <EditionType>Enterprise</EditionType>\n" +
                "    <SubscriptionExpiry>20991231</SubscriptionExpiry>\n" +
                "    <LicenseExpiry>20991231</LicenseExpiry>\n" +
                "    <SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber>\n" +
                "  </Data>\n" +
                "  <Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>\n" +
                "</License>";
        try {
            //获取水印
            InputStream is = new ByteArrayInputStream(license.getBytes());
            com.aspose.slides.License aposeLic = new com.aspose.slides.License();
            aposeLic.setLicense(is);
            //读取ppt文件
            FileInputStream fileInput = new FileInputStream(sourcePath);
            Presentation pres = new Presentation(fileInput);
            //指定输出路径
            outputStream = new FileOutputStream(new File(savePath));
            //输出
            pres.save(outputStream, SaveFormat.Pdf);
            outputStream.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }

效果

在这里插入图片描述

仅学习使用,非商业用途

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值