简体   繁体   English

如何使用Java POI读取PPT文件中存在的自动变形

[英]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. 我正在尝试使用poi读取ppt文件,并且我想知道如何读取ppt中插入的自动形状,并根据幻灯片将它们存储到其他文件中。

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 . 用于读取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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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