List<? extends Slide<?, ?>> slides = ss.getSlides(); Dimension pgsize = ss.getPageSize(); int width = (int) (pgsize.width * scale); int height = (int) (pgsize.height * scale);
@Override public POITextExtractor getMetadataTextExtractor() { return slideshow.getMetadataTextExtractor(); }
/** * Returns opened document * * @return the opened document */ @Override public final Object getDocument() { return slideshow.getPersistDocument(); }
FileInputStream is = new FileInputStream("PPT file"); SlideShow ppt = new SlideShow(is); is.close(); final Dimension pgsize = ppt.getPageSize(); final Slide[] slide = ppt.getSlides(); int i = 1;// Slide number String title = slide[i].getTitle(); Bitmap bmp = Bitmap.createBitmap((int) pgsize.getWidth(), (int) pgsize.getHeight(), Config.RGB_565); Canvas canvas = new Canvas(bmp); Paint paint = new Paint(); paint.setColor(android.graphics.Color.WHITE); paint.setFlags(Paint.ANTI_ALIAS_FLAG); canvas.drawPaint(paint); Graphics2D graphics2d = new Graphics2D(canvas); // render slide[i].draw(graphics2d); bmp.compress(CompressFormat.JPEG, 80, new FileOutputStream("Path to your file"));
@Override public void draw(Graphics2D graphics) { Dimension dim = sheet.getSlideShow().getPageSize(); Color whiteTrans = new Color(1f,1f,1f,0f); graphics.setColor(whiteTrans);
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("hiddenslide.ppt"); SlideShow ppt = new SlideShow(fis); fis.close(); for (Slide slide : ppt.getSlides()) { for (Record record : slide.getSlideRecord().getChildRecords()) { if (record instanceof UnknownRecordPlaceholder ppt.write(fos); fos.close();
public List<? extends ObjectShape<S,P>> getOLEShapes() { final List<ObjectShape<S,P>> oleShapes = new ArrayList<>(); for (final Slide<S,P> slide : slideshow.getSlides()) { addOLEShapes(oleShapes, slide); } return oleShapes; }
public static void slide4(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); table1.setRowHeight(1, 80); Dimension dim = ppt.getPageSize(); Rectangle2D oldAnchor = table1.getAnchor(); table1.setAnchor(new Rectangle2D.Double((dim.width-450)/2d, 100, oldAnchor.getWidth(), oldAnchor.getHeight()));
SlideShow slideShow = new SlideShow(); Slide slide = slideShow.createSlide(); int index = slideShow.addPicture(new File("IMG_8499.jpg"), Picture.JPEG); Picture picture = new Picture(index); picture.setAnchor(new Rectangle( 50, 50, 300, 200 )); slideShow.write( out ); out.close(); } catch ( FileNotFoundException e ) {
import java.awt.geom.Rectangle2D; import java.io.FileOutputStream; import org.apache.poi.hslf.model.*; import org.apache.poi.hslf.usermodel.*; public class HslfTextBox { public static void main(String[] args) throws Exception { SlideShow ppt = new SlideShow(); Slide s = ppt.createSlide(); TextBox txt = new TextBox(); txt.setAnchor(new Rectangle2D.Double(100,100,100,100)); TextRun run = txt.createTextRun(); RichTextRun rtr1 = run.getRichTextRuns()[0]; rtr1.setText("small text\n"); rtr1.setFontSize(10); RichTextRun rtr2 = run.appendText("big text\n"); rtr2.setBold(true); rtr2.setFontSize(14); s.addShape(txt); FileOutputStream fos = new FileOutputStream("hssftext.ppt"); ppt.write(fos); fos.close(); } }
}; Slide<?,?> slide = ppt.createSlide();
HSLFSlideShow ss = HSLFSlideShow.create(); SlideShow ppt = new SlideShow(ss); Slide slide = ppt.createSlide(); ppt.write(bos);
public static void main(String[] args) throws IOException { try (SlideShow<?,?> ppt = new HSLFSlideShow()) { // SlideShow<?,?> ppt = new XMLSlideShow(); ppt.setPageSize(new Dimension(720, 540)); slide1(ppt); slide2(ppt); slide3(ppt); slide4(ppt); slide5(ppt); slide6(ppt); slide7(ppt); slide8(ppt); slide9(ppt); slide10(ppt); slide11(ppt); slide12(ppt); String ext = ppt.getClass().getName().contains("HSLF") ? "ppt" : "pptx"; try (FileOutputStream out = new FileOutputStream("apachecon_eu_08." + ext)) { ppt.write(out); } } }
FileInputStream is = new FileInputStream("path_to_your.ppt"); SlideShow ppt = new SlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); Slide[] slide = ppt.getSlides(); for (int i = 0; i < slide.length; i++) { BufferedImage img = new BufferedImage(pgsize.width, pgsize.height, 1); 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.setColor(Color.white); graphics.clearRect(0, 0, pgsize.width, pgsize.height); graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height)); // render slide[i].draw(graphics); // save the output FileOutputStream out = new FileOutputStream("slide-" + (i + 1) + ".png"); javax.imageio.ImageIO.write(img, "png", out); out.close(); }
@SuppressWarnings("rawtypes") public void draw(Graphics2D graphics) { Dimension pg = shape.getSheet().getSlideShow().getPageSize(); final Rectangle2D anchor = new Rectangle2D.Double(0, 0, pg.getWidth(), pg.getHeight()); PlaceableShape<?,?> ps = new PlaceableShape(){ public ShapeContainer<?,?> getParent() { return null; } public Rectangle2D getAnchor() { return anchor; } public void setAnchor(Rectangle2D newAnchor) {} public double getRotation() { return 0; } public void setRotation(double theta) {} public void setFlipHorizontal(boolean flip) {} public void setFlipVertical(boolean flip) {} public boolean getFlipHorizontal() { return false; } public boolean getFlipVertical() { return false; } public Sheet<?,?> getSheet() { return shape.getSheet(); } }; DrawFactory drawFact = DrawFactory.getInstance(graphics); DrawPaint dp = drawFact.getPaint(ps); Paint fill = dp.getPaint(graphics, getShape().getFillStyle().getPaint()); Rectangle2D anchor2 = getAnchor(graphics, anchor); if(fill != null) { graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, anchor); graphics.setPaint(fill); graphics.fill(anchor2); } }
/** * Fetches all the slide text from the slideshow, but not the notes, unless * you've called setSlidesByDefault() and setNotesByDefault() to change this */ @Override public String getText() { final StringBuilder sb = new StringBuilder(); for (final Slide<S, P> slide : slideshow.getSlides()) { sb.append(getText(slide)); } return sb.toString(); }
public static void slide2(SlideShow<?,?> ppt) throws IOException { Slide<?,?> slide = ppt.createSlide(); TextBox<?,?> box1 = slide.createTextBox(); box1.setTextPlaceholder(TextPlaceholder.TITLE); box1.setText("What is HSLF?"); box1.setAnchor(new Rectangle(36, 21, 648, 90)); TextBox<?,?> box2 = slide.createTextBox(); box2.setTextPlaceholder(TextPlaceholder.BODY); box2.setText("HorribleSLideshowFormat is the POI Project's pure Java implementation " + "of the Powerpoint binary file format. \r" + "POI sub-project since 2005\r" + "Started by Nick Burch, Yegor Kozlov joined soon after"); box2.setAnchor(new Rectangle(36, 126, 648, 356)); }
List<? extends Slide<?, ?>> slides = ss.getSlides(); Dimension pgsize = ss.getPageSize(); int width = (int) (pgsize.width * scale); int height = (int) (pgsize.height * scale);
double width; if (!ts.getWordWrap()) { Dimension pageDim = ts.getSheet().getSlideShow().getPageSize();
/** * Fetches all the slide text from the slideshow, but not the notes, unless * you've called setSlidesByDefault() and setNotesByDefault() to change this */ @Override public String getText() { final StringBuilder sb = new StringBuilder(); for (final Slide<S, P> slide : slideshow.getSlides()) { sb.append(getText(slide)); } return sb.toString(); }