I am using the below code to convert the single ppt to png slide. But it is taking around 10 seconds for each slide. which will create a huge performance problem. Here I am giving some background on this issue. I am developing the application which will create a ppt slides to jpg. So here User will upload the ppt. But when ppt contains around 10 slides it is taking around 100 sec which is huge impact on my application response. Please solve this issue. Thanks in advance. Please let me know if you have any other code which will resolve this issue. ******************************************************************************** package com.hsbc.servlet; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.FileInputStream; import java.io.FileOutputStream; import java.util.Date; import javax.imageio.ImageIO; import org.apache.poi.hslf.model.Slide; import org.apache.poi.hslf.usermodel.SlideShow; public class PPT2PNG { public static void main(String args[]) throws Exception { System.out.println("Start time:"+new Date()); int slidenum = 3; float scale = 1; String file = "WebContent/ppts/RIM-94100.ppt"; FileInputStream is = new FileInputStream(file); SlideShow ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); int width = (int)(pgsize.width*scale); int height = (int)(pgsize.height*scale); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { if (slidenum != -1 && slidenum != (i+1)) continue; String title = slide[i].getTitle(); System.out.println("Rendering slide "+slide[i].getSlideNumber() + (title == null ? "" : ": " + title)); BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); 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.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, width, height)); graphics.scale((double)width/pgsize.width, (double)height/pgsize.height); slide[i].draw(graphics); String fname = file.replaceAll("\\.ppt", "-" + (i+1) + ".png"); FileOutputStream out = new FileOutputStream(fname); ImageIO.write(img, "png", out); out.close(); } System.out.println("End Time:"+new Date()); } }
What is your hardware configuration? How much memory do you allocate for JVM? Can you upload a sample ppt that demonstrate the performance issue? Yegor
Created attachment 22918 [details] Sample ppt to convert them into jpeg/png
Here I am sending my Hardware configuration: CPU : Intel core2 duo processor @ 2.33GHz RAM : 2GB Hard Drive has 40GB Free space I am using RAD 7.0.0.2 to run this application. I have allocated the maximum amount of memory to JVM by specifying the max parameters. Thanks in advance.
Is there any update on this issue?
(In reply to comment #4) > Is there any update on this issue? > not yet.
Using the latest version of POI (3.11-beta2) and the current version of PPT2PNG from the examples area, all 4 slides together are converted in less than 3 seconds, so it seems this was improved greatly since the bug was reported. Therefore I am closing this as WORKSFORME for now, please reopen if this still takes a long time for you with the latest version of POI.