List of usage examples for org.apache.poi.hslf.usermodel HSLFSlideShow getPageSize
@Override
public Dimension getPageSize()
From source file:testppttopdf.TestPptToPdf.java
/** * @param args the command line arguments *//*from w ww .j a va 2s . c o m*/ public static void main(String[] args) throws FileNotFoundException, IOException, COSVisitorException { // TODO code application logic here FileInputStream is = new FileInputStream("/home/sagar/Desktop/Shareback/test.ppt"); HSLFSlideShow ppt = new HSLFSlideShow(is); is.close(); Dimension pgsize = ppt.getPageSize(); int idx = 1; for (HSLFSlide slide : ppt.getSlides()) { 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 slide.draw(graphics); // save the output FileOutputStream out = new FileOutputStream("/home/sagar/Desktop/Shareback/img/slide-" + idx + ".jpg"); javax.imageio.ImageIO.write(img, "jpg", out); out.close(); idx++; } String someimg = "/home/sagar/Desktop/Shareback/img/"; PDDocument document = new PDDocument(); File file = new File(someimg); if (file.isDirectory()) { for (File f : file.listFiles()) { InputStream in = new FileInputStream(f); BufferedImage bimg = ImageIO.read(in); float width = bimg.getWidth(); float height = bimg.getHeight(); PDPage page = new PDPage(new PDRectangle(width + 10, height + 10)); document.addPage(page); PDXObjectImage img = new PDJpeg(document, new FileInputStream(f)); PDPageContentStream contentStream = new PDPageContentStream(document, page); contentStream.drawImage(img, 0, 0); contentStream.close(); in.close(); } document.save("/home/sagar/Desktop/Shareback/test-generated.pdf"); document.close(); } else { System.out.println(someimg + "is not a Directory"); } }