这是官方文档代码
FileInputStream is = new FileInputStream("e:/test/35.2014年全行网点零售业务效能评估报告.pptx");
XMLSlideShow ppt = new XMLSlideShow(is);
is.close();
Dimension pgsize = ppt.getPageSize();
int idx = 1;
for (XSLFSlide slide : ppt.getSlides()) {//XSLFSheet
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
// clear the drawing area
graphics.setPaint(Color.WHITE);
// graphics.setPaint();
graphics.setBackground(slide.getBackground().getFillColor());
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
// render
slide.draw(graphics);
// save the output
FileOutputStream out = new FileOutputStream("e:/test/ppt-image/slide-" + idx + ".png");
javax.imageio.ImageIO.write(img, "png", out);
out.close();
idx++;
}
这是ppt中内容,手动截出的图:
这是通过POI,程序截出的图: