3
你好我試圖使用Apache POI框架,以一個百分點的每一張幻燈片轉換爲個人PNG。問題是有些幻燈片變形了。例如,有一張幻燈片背景的彩虹色。這是對一些幻燈片圖像不顯示在所有的.png文件轉換的PPT PNG的Apache POI
這裏是代碼:
FileInputStream is = new FileInputStream(args[0]);
SlideShow ppt = new SlideShow(is);
is.close();
Dimension pgsize = ppt.getPageSize();
Slide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
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.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
//render
slide[i].draw(graphics);
//save the output
FileOutputStream out = new FileOutputStream("C:\\Users\\Farzad\\Desktop\\slide-" + (i+1) + ".png");
javax.imageio.ImageIO.write(img, "png", out);
out.close();
}
難道是改變'BufferedImage.TYPE_INT_RGB'提高質量? – Wivani 2011-05-27 08:26:49
您嘗試使用哪種版本的POI? PPT渲染的那種得到隨着時間的推移改善的事情,所以如果你還沒有嘗試最新版本,那麼它的價值升級 – Gagravarr 2011-09-02 17:33:51
將任何身體告訴我哪個罐子被包括到運行上面的代碼。因爲我沒有獲得Dimension,Graphics2D類.. – Panache 2012-07-10 11:53:14