Hello, I’m testing the lib to check if my company is going to go for this or not and currently I’ve been having some serious issues with the feature of rendering slides to graphics.
When trying to do this with the attached pptx, it takes more than one minute to render all slides to graphics. Sometimes it takes even longer and end up using all memory and throwing a GC Overhead exception.
This is my code:
public void testMethod(){
for (int i = 0, len = slide.size(); i < len; i++) {
File image = new File(getPathToSave(version.getId(), item.getId(), i));
Dimension2D pgsize = pres.getSlideSize().getSize();
long millis = System.currentTimeMillis();
writeSlideToFile(image, pres.getSlides().get_Item(i), (int) pgsize.getWidth(), (int) pgsize.getHeight());
System.out.println(System.currentTimeMillis() - millis);
}
}
private void writeSlideToFile(Object out, ISlide slide, int pageWidth, int pageHeight) throws IOException {
BufferedImage img = new BufferedImage(pageWidth, pageHeight, 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.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.fill(new Rectangle2D.Float(0, 0, pageWidth, pageHeight));
slide.renderToGraphics(false, graphics, img.getWidth(), img.getHeight());
if (out instanceof File)
javax.imageio.ImageIO.write(img, “png”, (File) out);
if (out instanceof ByteArrayOutputStream)
javax.imageio.ImageIO.write(img, “png”, (ByteArrayOutputStream) out);
}
The execution takes too long to go through the line "slide.renderToGraphics(false, graphics, img.getWidth(), img.getHeight()); ". Am I doing this wrong or is this an Aspose issue?
I’m using Windows 7-64bits, Java 7, Aspose 16.2(trial version), Intel i5-2400 3.1ghz