List of usage examples for org.apache.poi.xslf.extractor XSLFPowerPointExtractor getExtendedProperties
public ExtendedProperties getExtendedProperties()
From source file:rocky.sizecounter.SizeCounterUtil.java
License:Apache License
/** * @param filePath path of PowerPoint file * @return slide/*ww w . j av a2 s . c om*/ */ public static int countSlide(String filePath) { FileInputStream fis = null; int slide = 0; try { fis = new FileInputStream(filePath); if (CommonUtil.getExtension(filePath).equals("ppt")) { HSLFSlideShow show = new HSLFSlideShow(fis); slide = show.getDocumentSummaryInformation().getSlideCount(); } else if (CommonUtil.getExtension(filePath).equals("pptx")) { XSLFSlideShow show = new XSLFSlideShow(filePath); XSLFPowerPointExtractor ex = new XSLFPowerPointExtractor(show); slide = ex.getExtendedProperties().getUnderlyingProperties().getSlides(); } } catch (FileNotFoundException ex) { LOG.warn("Invalid when reading file.", ex); } catch (IOException ex) { LOG.warn("Invalid when reading file.", ex); } catch (OpenXML4JException ex) { LOG.warn("Invalid when reading file.", ex); } catch (XmlException ex) { LOG.warn("Invalid when reading file.", ex); } catch (Exception e) { LOG.warn("Can not count file " + new File(filePath).getName(), e); } finally { if (fis != null) { try { fis.close(); } catch (IOException ex) { LOG.warn("Close the file input stream", ex); } } } return slide; }