使用poi将ppt转成图像文件
下载POI:http://poi.apache.org/download.html
导入poi.jar与poi-scratchpad.jar(后边的这个必须导,不然没有HSLF这个包)
HSLFSlideShow hslfSlideShow = new HSLFSlideShow("D:/p1.ppt");
SlideShow slideShow = new SlideShow(hslfSlideShow);
if(slideShow.getSlides()!=null&&slideShow.getSlides().length>0){
Slide slide = slideShow.getSlides()[0];//读取第一页
TextRun[] textRuns = slide.getTextRuns();
for (TextRun textRun : textRuns) {
for (RichTextRun richTextRun : textRun.getRichTextRuns()) {
richTextRun.setFontName("宋体");//防止中文乱码
}
}
BufferedImage img = new BufferedImage(
slideShow.getPageSize().width,
slideShow.getPageSize().height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
slide.draw(graphics);
FileOutputStream fos = new FileOutputStream("d:/p1.png");
ImageIO.write(img, "png", fos);
fos.close();
}