Example usage for org.apache.poi.xslf.usermodel XMLSlideShow getAllEmbedds

List of usage examples for org.apache.poi.xslf.usermodel XMLSlideShow getAllEmbedds

Introduction

In this page you can find the example usage for org.apache.poi.xslf.usermodel XMLSlideShow getAllEmbedds.

Prototype

@Deprecated
@Removal(version = "4.2")
public List<PackagePart> getAllEmbedds() throws OpenXML4JException 

Source Link

Document

Get the document's embedded files.

Usage

From source file:poi.xslf.usermodel.DataExtraction.java

License:Apache License

public static void main(String args[]) throws Exception {

    if (args.length == 0) {
        System.out.println("Input file is required");
        return;//www.  j a  v  a 2 s. c  o m
    }

    FileInputStream is = new FileInputStream(args[0]);
    XMLSlideShow ppt = new XMLSlideShow(is);
    is.close();

    // Get the document's embedded files.
    List<PackagePart> embeds = ppt.getAllEmbedds();
    for (PackagePart p : embeds) {
        String type = p.getContentType();
        String name = p.getPartName().getName(); //typically file name

        InputStream pIs = p.getInputStream();
        // make sense of the part data
        pIs.close();

    }

    // Get the document's embedded files.
    List<XSLFPictureData> images = ppt.getAllPictures();
    for (XSLFPictureData data : images) {
        PackagePart p = data.getPackagePart();

        String type = p.getContentType();
        String name = data.getFileName();

        InputStream pIs = p.getInputStream();
        // make sense of the image data
        pIs.close();

    }

    Dimension pageSize = ppt.getPageSize(); // size of the canvas in points
    for (XSLFSlide slide : ppt.getSlides()) {
        for (XSLFShape shape : slide) {
            Rectangle2D anchor = shape.getAnchor(); // position on the canvas
            if (shape instanceof XSLFTextShape) {
                XSLFTextShape txShape = (XSLFTextShape) shape;
                System.out.println(txShape.getText());
            } else if (shape instanceof XSLFPictureShape) {
                XSLFPictureShape pShape = (XSLFPictureShape) shape;
                XSLFPictureData pData = pShape.getPictureData();
                System.out.println(pData.getFileName());
            } else {
                System.out.println("Process me: " + shape.getClass());
            }
        }
    }
}