Apache POI XWPFRun无法获取EMF图片

时间:2018-06-06 02:25:41

标签: apache-poi

apache poi 3.17

XWPFDocument document = new XWPFDocument(new FileInputStream("test.docx"));
Iterator<IBodyElement> iterator = document.getBodyElementsIterator();
while (iterator.hasNext()) {
    IBodyElement iBodyElement = iterator.next();
    switch (iBodyElement.getElementType()) {
        case PARAGRAPH:    
            XWPFParagraph paragraph = (XWPFParagraph) iBodyElement;
            for(XWPFRun run :paragraph.getRuns()){
                for(XWPFPicture picture : run.getEmbeddedPictures()){
                    System.out.println(picture.getPictureData().getFileName());
                }
            }
            break;
    }
}

输出

image3.png
image4.png
image5.png
image6.png
image7.png
image8.png
image9.png
image10.png
image11.png
image12.png
image13.png
image14.png

enter image description here

image1.emfimage2.emf已不复存在

document.getAllPictures()可以获取所有图片,但它是XWPFPictureData

我想采取picture.GetCTPicture().getSpPr().getXfrm().getExt().getCx();

document.getAllPictures()可以获得所有图片。

我找到了CTObject,我可以得到宽度和高度。

但我怎么知道哪个CTObject对应XWPFPictureData

0 个答案:

没有答案