https://issues.apache.org/bugzilla/show_bug.cgi?id=46196

           Summary: Performance problem while converting the ppt slide to
                    png/jpg
           Product: POI
           Version: 3.5-dev
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSLF
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


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());
    }
}


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to