List of usage examples for org.apache.poi.xslf.usermodel XMLSlideShow XMLSlideShow
public XMLSlideShow(InputStream is) throws IOException
From source file:com.docdoku.server.esindexer.ESTools.java
License:Open Source License
private static String microsoftPowerPointDocumentToString(InputStream inputStream) throws IOException { String strRet;/*from www .j a v a 2 s . c om*/ try (InputStream pptStream = new BufferedInputStream(inputStream)) { if (POIFSFileSystem.hasPOIFSHeader(pptStream)) { PowerPointExtractor pptExtractor = new PowerPointExtractor(pptStream); strRet = pptExtractor.getText(true, true); } else { XSLFPowerPointExtractor pptExtractor = new XSLFPowerPointExtractor(new XMLSlideShow(pptStream)); strRet = pptExtractor.getText(true, true, true); } } return strRet; }
From source file:com.frameworkset.platform.cms.searchmanager.extractors.CmsExtractorMsPowerPoint.java
License:Open Source License
/** * ?ppt // w w w . j a v a 2 s . c o m * @param path * @return */ public String readPowerPoint2007(InputStream in) { String content = null; try { XMLSlideShow xmlslideshow = new XMLSlideShow(in); org.apache.poi.xslf.extractor.XSLFPowerPointExtractor extractor = new XSLFPowerPointExtractor( xmlslideshow); this.cp = extractor.getCoreProperties(); content = extractor.getText(); // SlideShow ss = new SlideShow(new HSLFSlideShow(in));// is // // InputStreamSlideShow // Slide[] slides = ss.getSlides();// ?? // for (int i = 0; i < slides.length; i++) { // TextRun[] t = slides[i].getTextRuns();// ??TextRun // for (int j = 0; j < t.length; j++) { // content.append(t[j].getText());// content // } // } } catch (Exception ex) { System.out.println(ex.toString()); } return content; }
From source file:com.github.codeurjc.slidesconverter.PowerPointToHTML.java
License:Apache License
public void convert() throws IOException { InputStream fis = Files.newInputStream(pptxFile); XMLSlideShow pptx = new XMLSlideShow(fis); fis.close();//from w w w . j a va 2 s . co m InputStream is = Files.newInputStream(pptFile); HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); width = pptx.getPageSize().getWidth(); height = pptx.getPageSize().getHeight(); out = new PrintWriter(Files.newOutputStream(htmlFile)); out.println("<!DOCTYPE html>"); out.println("<html><body>"); out.println("<h1>" + this.mainTitleNumber + " " + mainTitle + "</h1>"); out.println("<h2>" + this.slidesContext + "</h2>"); List<Section> sections = calculateSections(pptx, ppt); generateTOC(sections); generateSlidesContent(pptx, ppt); pptx.close(); ppt.close(); out.close(); }
From source file:com.hp.autonomy.frontend.reports.powerpoint.SlideShowTemplate.java
License:MIT License
SlideShowTemplate(final InputStream inputStream) throws TemplateLoadException { try {/*from w ww . j av a2 s .com*/ // There should be a doughnut chart in slide 1 and a scatterplot chart in slide 2 pptx = new XMLSlideShow(inputStream); final List<XSLFSlide> slides = pptx.getSlides(); if (slides.size() != 2) { throw new TemplateLoadException( "Template powerpoint should have two slides, doughnut chart on slide 1 and time-axis xy scatterplot chart on slide 2"); } XSLFSlide slide = slides.get(0); doughnutChart = getChart(slide, "First slide should have a doughnut chart"); if (ArrayUtils.isEmpty(doughnutChart.getLeft().getCTChart().getPlotArea().getDoughnutChartArray())) { throw new TemplateLoadException( "First slide has the wrong chart type, should have a doughnut chart"); } graphChart = getChart(slides.get(1), "Second slide should have a time-axis xy scatterplot chart"); if (ArrayUtils.isEmpty(graphChart.getLeft().getCTChart().getPlotArea().getScatterChartArray())) { throw new TemplateLoadException( "Second slide has the wrong chart type, should have a time-axis xy scatterplot chart"); } // Remove the slides afterwards pptx.removeSlide(1); pptx.removeSlide(0); } catch (IOException e) { throw new TemplateLoadException("Error while loading slide show", e); } }
From source file:com.krawler.esp.fileparser.ppt.MsPPTParser.java
License:Open Source License
public String extractText(String filepath) throws Exception { String resultText = ""; try {/* w w w. ja v a 2 s. c om*/ InputStream input = new BufferedInputStream(new FileInputStream(filepath)); XSLFSlideShow xsslsh = new XSLFSlideShow(filepath); XMLSlideShow xslsh = new XMLSlideShow(xsslsh); XSLFPowerPointExtractor ppt = new XSLFPowerPointExtractor(xslsh); resultText = ppt.getText(); if (input != null) { input.close(); } } catch (XmlException e) { System.out.print(e.getMessage()); } return resultText; }
From source file:com.linksinnovation.elearning.utils.ppt2pdf.Ppt2Pdf.java
public static void convert(FileInputStream inputStream, FileOutputStream out) throws IOException, DocumentException { XMLSlideShow ppt = new XMLSlideShow(inputStream); inputStream.close();//from w w w. j ava 2 s .c o m Dimension pgsize = ppt.getPageSize(); Document document = new Document(); PdfWriter pdfWriter = PdfWriter.getInstance(document, out); document.setPageSize(new Rectangle((float) pgsize.getWidth(), (float) pgsize.getHeight())); document.open(); for (XSLFSlide slide : ppt.getSlides()) { System.out.println(pgsize.getWidth() + " " + pgsize.getHeight()); PdfGraphics2D graphics = (PdfGraphics2D) pdfWriter.getDirectContent() .createGraphics((float) pgsize.getWidth(), (float) pgsize.getHeight()); slide.draw(graphics); graphics.dispose(); document.newPage(); } document.close(); }
From source file:com.opensearchserver.extractor.parser.Pptx.java
License:Apache License
@Override protected void parseContent(File file, String extension, String mimeType) throws Exception { XSLFSlideShow pptSlideShow = new XSLFSlideShow(file.getAbsolutePath()); XMLSlideShow slideshow = new XMLSlideShow(pptSlideShow.getPackage()); // Extract metadata XSLFPowerPointExtractor poiExtractor = null; try {//w ww .ja v a2 s .com poiExtractor = new XSLFPowerPointExtractor(slideshow); CoreProperties info = poiExtractor.getCoreProperties(); if (info != null) { metas.add(TITLE, info.getTitle()); metas.add(CREATOR, info.getCreator()); metas.add(SUBJECT, info.getSubject()); metas.add(DESCRIPTION, info.getDescription()); metas.add(KEYWORDS, info.getKeywords()); metas.add(CREATION_DATE, info.getCreated()); metas.add(MODIFICATION_DATE, info.getModified()); } } finally { poiExtractor.close(); } extractSides(slideshow); }
From source file:com.opensearchserver.textextractor.parser.Pptx.java
License:Open Source License
@Override protected void parseContent(File file) throws Exception { XSLFSlideShow pptSlideShow = new XSLFSlideShow(file.getAbsolutePath()); XMLSlideShow slideshow = new XMLSlideShow(pptSlideShow.getPackage()); // Extract metadata XSLFPowerPointExtractor poiExtractor = null; try {/*ww w.j av a 2s. c o m*/ poiExtractor = new XSLFPowerPointExtractor(slideshow); CoreProperties info = poiExtractor.getCoreProperties(); if (info != null) { metas.add(TITLE, info.getTitle()); metas.add(CREATOR, info.getCreator()); metas.add(SUBJECT, info.getSubject()); metas.add(DESCRIPTION, info.getDescription()); metas.add(KEYWORDS, info.getKeywords()); metas.add(CREATION_DATE, info.getCreated()); metas.add(MODIFICATION_DATE, info.getModified()); } } finally { poiExtractor.close(); } extractSides(slideshow); }
From source file:com.qwazr.library.poi.PptxParser.java
License:Apache License
@Override public void parseContent(final MultivaluedMap<String, String> parameters, final Path filePath, final String extension, final String mimeType, final ParserResultBuilder resultBuilder) throws Exception { final XSLFSlideShow pptSlideShow = new XSLFSlideShow(filePath.toAbsolutePath().toString()); final XMLSlideShow slideshow = new XMLSlideShow(pptSlideShow.getPackage()); final ParserFieldsBuilder metas = resultBuilder.metas(); metas.set(MIME_TYPE, findMimeType(extension, mimeType, this::findMimeTypeUsingDefault)); // Extract metadata try (XSLFPowerPointExtractor poiExtractor = new XSLFPowerPointExtractor(slideshow)) { final CoreProperties info = poiExtractor.getCoreProperties(); if (info != null) { metas.add(TITLE, info.getTitle()); metas.add(CREATOR, info.getCreator()); metas.add(SUBJECT, info.getSubject()); metas.add(DESCRIPTION, info.getDescription()); metas.add(KEYWORDS, info.getKeywords()); metas.add(CREATION_DATE, info.getCreated()); metas.add(MODIFICATION_DATE, info.getModified()); }/* ww w.j a v a2 s .co m*/ } extractSides(slideshow, resultBuilder); }
From source file:easyoffice.powerpoint.PPTMaker.java
private static XMLSlideShow openPpt() { XMLSlideShow ppt = null;//from w w w. ja v a 2 s. com try { File file = new File(INPUT_PPT_NAME); FileInputStream inputstream = new FileInputStream(file); ppt = new XMLSlideShow(inputstream); } catch (IOException ex) { System.err.println(Strings.PPT_NOT_FOUND(INPUT_PPT_NAME)); System.exit(-1); } return ppt; }