= apachePOI = Create, modify, and display MS-Office files using Java programs * https://www.tutorialspoint.com/apache_poi_ppt/index.htm * https://www.tutorialspoint.com/apache_poi_word/index.htm * https://poi.apache.org/apidocs/dev/overview-summary.html == Example Powerpoint == == structure == {{{ |-- pom.xml |-- src | `-- main | `-- java | `-- org | `-- allowed | `-- bitarus | `-- apache | `-- poi | `-- test | `-- Main.java | }}} == pom.xml == {{{#!highlight xml 4.0.0 apache-poi-test apache-poi-test 0.0.1-SNAPSHOT src maven-compiler-plugin 1.8 1.8 maven-assembly-plugin 2.4 jar-with-dependencies org.allowed.bitarus.apache.poi.test.Main make-assembly package single org.apache.poi poi 4.0.1 org.apache.poi poi-ooxml 4.0.1 }}} == Main.java == {{{ #!highlight java package org.allowed.bitarus.apache.poi.test; import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.IOException; import java.io.File; import org.apache.poi.xslf.usermodel.XMLSlideShow; import org.apache.poi.xslf.usermodel.XSLFSlide; import org.apache.poi.xslf.usermodel.XSLFShape; import java.util.List; import org.apache.poi.xslf.usermodel.XSLFTextShape; import org.apache.poi.xslf.usermodel.XSLFPictureShape; import org.apache.poi.xslf.usermodel.XSLFPictureData; import org.apache.poi.xslf.usermodel.XSLFTextParagraph; public class Main { public static void main(String args[]) { try{ File file = new File(args[0]); XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(file)); List slides = ppt.getSlides(); for ( XSLFSlide slide : slides ){ System.out.println(String.format("%s %d", slide.getSlideName() , slide.getSlideNumber() )); List shapes = slide.getShapes(); for (XSLFShape shape: shapes ){ System.out.println(String.format("Shape name: %s",shape.getShapeName() ) ); if( shape instanceof XSLFTextShape){ System.out.println(String.format("Shape text: %s", ((XSLFTextShape) shape).getText() ) ); for(XSLFTextParagraph para: ( (XSLFTextShape) shape).getTextParagraphs() ){ System.out.println(String.format("Paragraph text: %s bullet: %b indentLevel: %d", para.getText(), para.isBullet(), para.getIndentLevel() ) ); } } if( shape instanceof XSLFPictureShape ){ XSLFPictureData pd = (( XSLFPictureShape ) shape).getPictureData(); System.out.println(String.format("Filename: %s", pd.getFileName() ) ); System.out.println(String.format("Content type: %s", pd.getContentType() ) ); System.out.println(String.format("Image dimension (points): %s", pd.getImageDimension().toString() ) ); System.out.println(String.format("Image dimension (pixels): %s", pd.getImageDimensionInPixels().toString() ) ); } } } ppt.close(); } catch(Exception ex){ ex.printStackTrace(); } } } }}}