Spire.Presentation for Java 专业的 PowerPoint API,它允许开发人员在 Java 应用程序中创建、读取、写入、转换和保存 PowerPoint 文档,而无需安装 Microsoft PowerPoint。
这么优秀的国产工具怎能错过呢!想要获取更多福利的朋友咨询在线客服哦~
下面是示例PowerPoint文档的屏幕截图。
 
import com.spire.presentation.ISlide;import com.spire.presentation.Presentation;import javax.imageio.ImageIO;import java.awt.*;import java.awt.image.BufferedImage;import java.io.File;public class SaveShapeAsImage {    public static void main(String[] args) throws Exception {        //Create a Presentation object        Presentation presentation = new Presentation();        //Load the sample PowerPoint file        presentation.loadFromFile("C:\Users\Administrator\Desktop\chart and table.pptx");        //Get the first slide        ISlide slide = presentation.getSlides().get(0);        //Declare a BufferedImage variable        BufferedImage image;        //Loop through the shapes in the slide        for (int i = 0; i < slide.getShapes().getCount(); i++) { //Save the specific shape as image data image = slide.getShapes().saveAsImage(i); //Write data to png file File file = new File(String.format("ToImage-%d.png", i)); ImageIO.write(image, "PNG", file); } } }
输出结果
 
 还想要更多吗可以点击阅读【2020 · E-iceblue最新资源整合】,查找需要的教程资源。是E-iceblue官方友好合作伙伴,如果您对spire.Presentation感兴趣,可以联系在线客服了解具体授权价格和使用机制。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!