简体   繁体   中英

How read autoshapes present in a ppt File using java poi

I am trying to read a ppt file using the poi, and I would like to know how to read the autoshapes which are inserted in the ppt and store them into a different file according to the slide.

I am using the code below:

public void getAutoShapes()
    {
        for (int i = 0; i < _slides.length; i++) 
        {
            Slide slide = _slides[i];
            Shape[] autoshape = slide.getShapes();
            for (int j = 0; j < autoshape.length; j++)
            {
                if(autoshape[j].getShapeName()=="NotPrimitive")
                {
                    autoshape[j].typeName(autoshape[j].getShapeId());
                }
          }
        }
    }

For reading all types of shapes in pptx / XSLF . ..

BufferedImage img = new BufferedImage((int)width, (int)height, BufferedImage.TYPE_4BYTE_ABGR);
                       Graphics2D graphics = img.createGraphics();
                       graphics.translate(-aShape.getAnchor().getX(), -aShape.getAnchor().getY());
                       aShape.draw(graphics);
                       graphics.dispose();
                       //clear the drawing area
                       graphics.setPaint(Color.white);
                       graphics.fill(new Rectangle2D.Float((float)left,(float)top,(float)width,(float)height));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM