Hi All,

I am trying to generate pptx file using 1 pptx file as template. 
For replacing new image with old one in template, I tried to remove image 
from template pptx file. But poi framework throwing an exception. 

java.lang.IllegalArgumentException: Unsupported shape: 
org.apache.poi.xslf.usermodel.XSLFPictureShape 

Code:
 if (shape instanceof XSLFPictureShape){
                        //work with Picture                     
                        XSLFPictureShape picshape = (XSLFPictureShape)
shape;
                        Rectangle2D rectangle = picshape.getAnchor();
                                try{
                                        boolean remove = slide.removeShape
(picshape);
                                        System.out.println("slide 
removed ::"+remove);
                                        File img = new File
("C:/Jayasree", "defualt.png");
                                        byte[] data = IOUtils.toByteArray
(new FileInputStream(img));
                                        int pictureIndex = ppt.addPicture
(data, XSLFPictureData.PICTURE_TYPE_PNG);
                                        XSLFPictureShape newpicshape = 
slide.createPicture(pictureIndex);
                                        newpicshape.setAnchor(rectangle);
                                }catch(Exception e){
                                        e.printStackTrace();
                                }
}


Thanks in advance..


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to