簡體   English   中英

如何使用Java POI讀取PPT文件中存在的自動變形

[英]How read autoshapes present in a ppt File using java poi

我正在嘗試使用poi讀取ppt文件,並且我想知道如何讀取ppt中插入的自動形狀,並根據幻燈片將它們存儲到其他文件中。

我正在使用以下代碼:

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());
                }
          }
        }
    }

用於讀取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