>> 3.  I would like to know what pictures belong to what slide. Is it 
>> possible? (I didn't find a way to do it) if not, when will this be 
>> possible?

NB> I don't believe it is currently possible. It should be fairly easy to 
NB> implement, once we know how powerpoint matches pictures to slides. Until 
NB> we know that, we can't code the functionality!

NB> Nick

Hi

Nick, it is possible! This functionality new. I added it just a couple of weeks
ago. Below is an example how to know what pictures belong to what
slide:

        SlideShow ppt = new SlideShow(new HSLFSlideShow(filename));    //source 
ppt

        //array of picture data contained in the presentation.
        //it has global scope since the same picture can be included in 
multiple slides

        PictureData[] pict = ppt.getPictures();
        
        Slide[] slide = ppt.getSlides();
        for (int i = 0; i < slide.length; i++) {
            Slide sl = slide[i];
            Shape[] sh = sl.getShapes();  //get all shapes for this slide
            for (int j = 0; j < sh.length; j++) {
                Shape shape = sh[j];
                if (shape instanceof Picture){
                    Picture picture = (Picture)shape;
                    
                    //i-based index of the actual picture data
                    int idx = picture.getPictureIndex();
                    PictureData pictdata = pict[idx-1];
                    
                    //raw data.
                    byte[] data = pictdata.getData();
                    BufferedImage img = ImageIO.read(new 
ByteArrayInputStream(data));
                    //draw image of save it to a file or do whatever  you want.
                }
            }
            
        }
    }

Note, current implementation supports only JPEG and PNG formats.
WMF and Macintosh PICT are not yet supported.
    
Regards, Yegor Kozlov


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/

Reply via email to