如何用POI将PPT的内容转换为图片
我用POI提供的方法去转换ppt内容为图片时,出错了,具体代码如下:

这是ppt内容的截图,下面这张是转换后的图片

转换过程中,ppt里面的图表内容丢失了,大神能否帮忙看一下,指导一下?
public static void main(String[] args) throws FileNotFoundException,
IOException {
final String PPT_TEMPLATE = "data/test.pptx";
float scale = 1;
XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(PPT_TEMPLATE));
Dimension pgsize = ppt.getPageSize();
int width = (int) (pgsize.width * scale);
int height = (int) (pgsize.height * scale);
XSLFSlide slide = ppt.getSlides()[5];
BufferedImage img = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = img.createGraphics();
// default rendering options
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setColor(Color.white);
graphics.clearRect(0, 0, width, height);
graphics.scale(scale, scale);
// draw stuff
slide.draw(graphics);
// save the result
FileOutputStream out = new FileOutputStream(new File("D:/test.png"));
try {
ImageIO.write(img, "png", out);
} finally {
out.close();
}
System.out.println("Job Done");
}

这是ppt内容的截图,下面这张是转换后的图片

转换过程中,ppt里面的图表内容丢失了,大神能否帮忙看一下,指导一下?
...全文
相关推荐
使用POI将office(doc/docx/ppt/pptx/xls/xlsx)文件转html格式
使用POI将office(doc/docx/ppt/pptx/xls/xlsx)文件转html格式
java实现在线预览--poi实现word、excel、ppt转html的方法
主要介绍了java实现在线预览--poi实现word、excel、ppt转html的方法,本文需要引入poi的jar包给大家介绍的非常详细,需要的朋友可以参考下
poi操作ppt完整示例程序
poi操作ppt完整示例程序,包括java实现的demo+POI-3.15的所有jar文件。poi操作ppt完整示例程序,包括java实现的demo+POI-3.15的所有jar文件。
利用java poi操作ppt
Java poi ppt ①创建新的PPT文档 ②设置母版 ③创建幻灯片并插入文本 ④插入图片,支持多种格式 ⑤插入表格 ......
POI将文件转为html
使用POI将excel03-07,word03-07,txt文件转为html文件,ppt03-07先转换为图片,再将图片转换为pdf实现在线预览


