Retrieve The Size of Slide Using Java

In this example we are going to find height and width of the slide.

Retrieve The Size of Slide Using Java

Retrieve The Size of Slide Using Java

     


In this example we are going to find height and width of the slide.

In this example we create an object of dimension in which we are assigning the size of page. From this object we get the width and height We are using getPageSize() method to get the dimension of page , height and width  property to get the height and width of the page respectively. 

 

  
  
 The code of the program is given below:

import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.model.Slide;
import org.apache.poi.hslf.usermodel.SlideShow;
import java.io.*;
class retrieveSlideSize{
  public static void main(String a[])
  {
  try
  {  SlideShow slideShow = new SlideShow(new 
HSLFSlideShow
("slideshow.ppt"));
 java.awt.Dimension pgsize = slideShow.getPageSize();
  int pgx = pgsize.width; 
  int pgy = pgsize.height; 
  System.out.println("Width:"+pgx);
  System.out.println("Height:"+pgy);  
  FileOutputStream out = new FileOutputStream
(
"retrieveSlideSize.ppt");
  slideShow.write(out);
  out.close();
  }catch(Exception e){}
  }}

The output of the program is given below:

C:\POI3.0\exmples\PowerPoint>javac retrieveSlideSize.jav
C:\POI3.0\exmples\PowerPoint>java retrieveSlideSize
Width:792
Height:612

Download this example.