aspose-slides 主要用来PPT转图片/PPT转PDF 支持.ppt/.pptx格式,功能强大。以下内容仅供学习研究使用切勿商业用途
以下操作仅以19.6版本为参考其他版本可能有所不同
需要注意License加载,如果同时使用多个aspose的组件,请分别引入各自的License,否则水印还在哟
例如:
虽然类名字都一样License,但是两个包的或者还有个cells包的com.aspose.words.License asposeLicense = new com.aspose.words.License(); com.aspose.slides.License asposeLicense = new com.aspose.slides.License();
final static String license =
"<License>\n" +
" <Data>\n" +
" <Products>\n" +
" <Product>Aspose.Total for Java</Product>\n" +
" <Product>Aspose.Words 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>";
private static ByteArrayOutputStream pptToPdfStream(InputStream in) throws Exception {
//注意各个组件必须设置自己的License类
try (InputStream is = new ByteArrayInputStream(license.getBytes("UTF-8"));){
com.aspose.slides.License asposeLicense = new com.aspose.slides.License();
asposeLicense.setLicense(is);
}
Presentation ppt = new Presentation (in);
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
ppt.save(dstStream, SaveFormat.Pdf);
return dstStream;
}
地址:https://www.leftso.com/article/1090.html