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
导入依赖
<dependency>
<groupId>aspose</groupId>
<artifactId>aspose-slides</artifactId>
<version>19.3</version>
</dependency>
代码
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);
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();
}
}
效果

仅学习使用,非商业用途