Rui Rebelo Brito
Rui Rebelo Brito

Reputation: 163

JAVA Replace image/picture in Presentation (PPTX) with Apache POI

Just want to know how to draw an Image I have in a buffered image into a PictureShape using POI. I wrote the code below to do what I ask but with no success.

Thanks for reading and luckily helping out.

           for (int i = 0; i < listNewImage.size(); i++) {
                try {
                    Icon icon = listNewImage.get(i).getIcon();
                    BufferedImage im = (BufferedImage) iconToImage(icon);

                    Graphics2D g = im.createGraphics();

                    listImageShape.get(i).drawContent(g);

                } catch (IOException ex) {
                    Logger.getLogger(EditorMenuWindows.class.getName()).log(Level.SEVERE, null, ex);
                }

Upvotes: 0

Views: 1127

Answers (1)

JasonPlutext
JasonPlutext

Reputation: 15878

Here is a pptx4j sample I wrote which you may be able to adapt. POI works along broadly similar lines (it uses XML Beans, not JAXB).

Upvotes: 1

Related Questions