Java Code Examples for org.apache.poi.hslf.usermodel.HSLFSlideShow#getSlides()
The following examples show how to use
org.apache.poi.hslf.usermodel.HSLFSlideShow#getSlides() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PPTUtil.java From SpringMVC-Project with MIT License | 6 votes |
/** * 转换2003版(.ppt)格式的PPT文件为图片 */ private static List<String> convertPPT2003ToImages(String pptFilePath, String imageFolderPath) throws IOException { List<String> imagePathList = Lists.newArrayList(); FileInputStream fis = new FileInputStream(pptFilePath); HSLFSlideShow ppt = new HSLFSlideShow(fis); fis.close(); Dimension dimension = ppt.getPageSize(); List<HSLFSlide> slideList = ppt.getSlides(); int index = 0; for (HSLFSlide slide : slideList) { logger.info("正在转换PPT第" + (++index) + "页"); File imageFile = new File(imageFolderPath + "/" + (index) + ".png"); convertSlideToImage(slide, dimension, imageFile); imagePathList.add(imageFile.getAbsolutePath()); } return imagePathList; }
Example 2
Source File: ConvertPPT2PNG.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws IOException { FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt"); // FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/Presentation5.ppt"); HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); java.util.List<HSLFSlide> slides = ppt.getSlides(); for (int i = 0; i < slides.size(); i++) { BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); //clear the drawing area graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); //render HSLFSlide slide1 = slides.get(i); slide1.draw(graphics); //save the output FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + slide1.getTitle() + ".png"); javax.imageio.ImageIO.write(img, "png", out); out.close(); } }
Example 3
Source File: ExtractSlidesFromPPTX.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws IOException { // XMLSlideShow ppt = new XMLSlideShow(); FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt"); HSLFSlideShow ppt = new HSLFSlideShow(is); for (HSLFSlide xslfSlide : ppt.getSlides()) { System.out.println(xslfSlide.getTitle()); } // XSLFSlide slide getTitle= ppt.getSlides()[0];0 // new org.apache.poi.hslf.extractor.PowerPointExtractor("xslf-demo.pptx").getSlides }
Example 4
Source File: ExtractSlidesFromPPT.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws IOException { // XMLSlideShow ppt = new XMLSlideShow(); // FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.ppt"); FileInputStream is = new FileInputStream("testdata/testdata 1 reordered slides.ppt"); HSLFSlideShow ppt = new HSLFSlideShow(is); for (HSLFSlide slide : ppt.getSlides()) { String slideTitle = slide.getTitle(); System.err.println("-----------"); System.err.println(slideTitle); // System.err.println("sheetid : "+slide.getSlideRecord().getSheetId()); // // does just reflect the slide number // // System.err.println("refsheetid: "+ slide._getSheetRefId()); // // System.err.println("atomhah: "+ slide.getSlideRecord().getSlideAtom().toString()); // // System.err.println("ppdrawing: "+ slide.getSlideRecord().toString()); System.err.println(slide.getSlideRecord().getPPDrawing()); slide.getSlideRecord().getPPDrawing().toString(); slide.getSlideRecord().getSlideAtom().hashCode(); // XSLFSlide slide getTitle= ppt.getSlides()[0];0 // new org.apache.poi.hslf.extractor.PowerPointExtractor("xslf-demo.pptx").getSlides } }
Example 5
Source File: ConvertPPTX2PNG.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public static void main(String[] args) throws IOException, InvalidFormatException { FileInputStream is = new FileInputStream("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx"); XMLSlideShow ppt2 = new XMLSlideShow(OPCPackage.open("/Users/brandl/Dropbox/private/oc2/testdata/experimental design.pptx")); XSLFSlide slide1 = ppt2.getSlides().get(0); // slide1.get HSLFSlideShow ppt = new HSLFSlideShow(is); // HSLFSlide slide2 = ppt.getSlides().get(1); is.close(); Dimension pgsize = ppt.getPageSize(); java.util.List<HSLFSlide> slides = ppt.getSlides(); for (int i = 0; i < slides.size(); i++) { BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); //clear the drawing area graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); //render slides.get(i).draw(graphics); //save the output FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + ".png"); javax.imageio.ImageIO.write(img, "png", out); out.close(); } }
Example 6
Source File: PPTSerializer.java From opencards with BSD 2-Clause "Simplified" License | 4 votes |
public FlashCardCollection readFlashcardsFromFile(CardFile cardFile) { Utils.log("extracting flashcards from file '" + cardFile + "'..."); FlashCardCollection fc = new FlashCardCollection(); try { if (cardFile.getFileLocation().getName().endsWith(".ppt")) { FileInputStream is = new FileInputStream(cardFile.getFileLocation()); HSLFSlideShow ppt = new HSLFSlideShow(is); for (HSLFSlide xslfSlide : ppt.getSlides()) { String slideTitle = xslfSlide.getTitle(); if (slideTitle == null) continue; // old OC1.x approach to create a unique card-id // int cardID = Utils.getRandGen().nextInt(Integer.MAX_VALUE); fc.add(new FlashCard(slideTitle.hashCode(), slideTitle, xslfSlide.getSlideNumber())); } } else if (cardFile.getFileLocation().getName().endsWith(".md")) { boolean useSelector = cardFile.getProperties().useMarkdownSelector(); List<MarkdownFlashcard> flashcards = MarkdownParserKt.parseMD(cardFile.getFileLocation(), useSelector); for (int i = 0; i < flashcards.size(); i++) { MarkdownFlashcard card = flashcards.get(i); String question = card.getQuestion(); if (question.trim().isEmpty()) { continue; } fc.add(new FlashCard(question.hashCode(), question, i + 1)); } } else { throw new InvalidCardFileFormatException(); } } catch (IOException e) { // rephrase IO problem into something more specific throw new InvalidCardFileFormatException(); } return fc; }