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(); }
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"));
public static void main(String[] args) throws Exception { FileInputStream fis = new FileInputStream("hiddenslide.ppt"); SlideShow ppt = new SlideShow(fis); fis.close();
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(); } }
SlideShow slideShow = new SlideShow(); Slide slide = slideShow.createSlide();