当前位置:网站首页>Use aspese slides to convert PPT to PDF

Use aspese slides to convert PPT to PDF

2022-06-27 09:34:00 Sparkle_ wsl

PPT turn PDF

download jar package

 link :https://pan.baidu.com/s/1a-9zm9aaiEcemXD5jaLXRw 
 Extraction code :cu57 

Add to MVN Warehouse

mvn install:install-file -Dfile="jar Bag location " -DgroupId="groupId" -DartifactId="artifactId" -Dversion=" edition " -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

Import dependence

		<!-- take ppt turn pdf  This is my own packaging -->
        <dependency>
            <groupId>aspose</groupId>
            <artifactId>aspose-slides</artifactId>
            <version>19.3</version>
        </dependency>

Code

/** * ppt Turn into pdf * @param sourcePath ppt File path  * @param savePath pdf Saved path  */
    public static void pptToPdf(String sourcePath,String savePath){
    
        FileOutputStream outputStream = null;
        // Watermark processing 
        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 {
    
            // Get watermark 
            InputStream is = new ByteArrayInputStream(license.getBytes());
            com.aspose.slides.License aposeLic = new com.aspose.slides.License();
            aposeLic.setLicense(is);
            // Read ppt file 
            FileInputStream fileInput = new FileInputStream(sourcePath);
            Presentation pres = new Presentation(fileInput);
            // Specify the output path 
            outputStream = new FileOutputStream(new File(savePath));
            // Output 
            pres.save(outputStream, SaveFormat.Pdf);
            outputStream.close();
        }catch (Exception e){
    
            e.printStackTrace();
        }
    }

effect

 Insert picture description here

Only learn to use , Non commercial use

原网站

版权声明
本文为[Sparkle_ wsl]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270924081257.html