List of usage examples for org.apache.poi.hslf.usermodel HSLFSlide getTitle
@Override
public String getTitle()
The title is a run of text of type TextHeaderAtom.CENTER_TITLE_TYPE or TextHeaderAtom.TITLE_TYPE
From source file:com.github.codeurjc.slidesconverter.PowerPointToHTML.java
License:Apache License
private String calculateTitle(XSLFSlide slideX, HSLFSlide slide) { String title = slide.getTitle(); if (title != null) { return title; }/*from w w w . jav a2 s . c o m*/ title = slideX.getTitle(); if (title != null) { return title; } boolean titleSlide = ArrayUtils.contains(titleSlides, slideX.getSlideNumber()); for (XSLFShape shape : slideX.getShapes()) { if (shape instanceof XSLFTextShape) { XSLFTextShape tsh = (XSLFTextShape) shape; Rectangle2D figure = getRelativeFigure(tsh); if (titleSlide || figure.getY() < 0.1) { StringBuilder titleSB = new StringBuilder(); for (XSLFTextParagraph p : tsh) { for (XSLFTextRun r : p) { titleSB.append(r.getRawText()); } } title = titleSB.toString(); if (!title.trim().isEmpty()) { return title; } } } } return null; }
From source file:com.github.codeurjc.slidesconverter.PowerPointToHTML.java
License:Apache License
public void generateSlideImage(HSLFSlide slide) throws IOException { float scale = 0.5f; int sWidth = (int) (width * scale); int sHeight = (int) (height * scale); String title = slide.getTitle(); System.out.println("Rendering slide " + slide.getSlideNumber() + (title == null ? "" : ": " + title)); BufferedImage img = new BufferedImage(sWidth, sHeight, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = img.createGraphics(); graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); graphics.setPaint(Color.white); graphics.fill(new Rectangle2D.Float(0, 0, sWidth, sHeight)); graphics.scale((double) sWidth / width, (double) sHeight / height); try {/* www .ja va 2 s . c o m*/ slide.draw(graphics); Path imagePath = htmlFile.getParent().resolve(Paths.get(getImageFileName(slide.getSlideNumber()))); OutputStream out = Files.newOutputStream(imagePath); ImageIO.write(img, "png", out); out.close(); } catch (Exception e) { System.err.println("Exception rendering slide " + slide.getSlideNumber() + ": " + title); } }