Results 1 to 8 of 8
  1. #1
    aminj2e is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Converter a slide to picture

    To convert a powerpoint to pictures and later display them, I used this java class


    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics2D;
    import java.awt.geom.Rectangle2D;
    import java.awt.image.BufferedImage;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;

    import org.apache.poi.hslf.usermodel.SlideShow;


    public class slidtoppt {

    /**
    * @param args
    * @throws Throwable
    */
    public static void main(String[] args) throws Throwable,IOException, Exception{
    // TODO Auto-generated method stub
    FileInputStream is = new FileInputStream("c:\\file\\slide.ppt");
    System.out.println();
    SlideShow ppt = new SlideShow(is);
    is.close();

    Dimension pgsize = ppt.getPageSize();

    org.apache.poi.hslf.model.Slide[] slide = ppt.getSlides();
    for (int i = 0; i < slide.length; i++) {

    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[i].draw(graphics);

    //save the output
    FileOutputStream out = null;
    try {
    out = new FileOutputStream("slide-" + (i+1) + ".png");
    } catch (FileNotFoundException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    try {
    javax.imageio.ImageIO.write(img, "png", out);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    out.close();
    }

    }

    }

    Knowing that I downloaded all the jars, I still have errors:

    Exception in thread "main" java.lang.NoSuchMethodError:
    org.apache.poi.poifs.filesystem.POIFSFileSystem.ge tRoot()Lorg/apache/poi/poifs/filesystem/DirectoryNode;
    at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlide Show.java:115)
    at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlide Show.java:103)
    at org.apache.poi.hslf.usermodel.SlideShow.<init>(Sli deShow.java:124)
    at slidtoppt.main(slidtoppt.java:23)

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Converter a slide to picture

    Were all the necessary jar files on the classpath when you executed the code?
    Could you have mixed versions of the jar files? See the API doc for the error message.

  3. #3
    aminj2e is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Converter a slide to picture

    Yeah all the jars are in the project classpath :

    aspose.slides-2.6.0.jar
    batik-all-1.8pre-r1084380.jar
    batik-slideshow.jar
    jackrabbit-standalone-1.5.0.jar
    jakarta-poi-2.5.jar
    jakarta-slide-webdavlib-2.1.jar
    jodconverter-2.1.1.jar
    openoffice-juh-2.0.3.jar
    openoffice-ridl-3.1.0.jar
    poi-3.2-FINAL.jar
    poi-3.5-beta1.jar
    poi-scratchpad-3.5-beta5-20090219.jar
    unoil-3.0.0.jar
    ws4d-dpws-stack.presentation.jar

    Where can i find the API doc for the error please ?
    Thank's for the answer.
    Have a nice day.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Converter a slide to picture

    API docs are at this link:
    Java Platform SE 6
    Find the name in lower left and click for doc in main frame.

  5. #5
    aminj2e is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Converter a slide to picture

    Sorry but i didn't find the code of error like "java.lang.NoSuchMethodError"
    i realy wanna the used the right jars
    Thank's again

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Converter a slide to picture

    i didn't find the code of error like "java.lang.NoSuchMethodError"
    Go to the site I gave and Find: NoSuchMethodError in the lower left. Only the class names are there, the package names are not in that list.

  7. #7
    aminj2e is offline Member
    Join Date
    Dec 2011
    Posts
    4
    Rep Power
    0

    Default Re: Converter a slide to picture

    Else can you please show the jars used because I can not resolve its mistakes?

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Converter a slide to picture

    I have none of the jar files and know nothing about any of the jar files you listed in post#3

    The error message sounds like you could have jar files from different/conflicting versions of some of the classes.

    Find the jar file that has the class that showed in the error and then look at the contents of that jar file and see what you can about that class file. What date does it have?

Similar Threads

  1. Selection of PowerPointSlide # NOT create new slide
    By greenhorn in forum New To Java
    Replies: 0
    Last Post: 02-16-2011, 12:49 PM
  2. Transfer Excel Information --> PowerPoint Slide
    By greenhorn in forum Advanced Java
    Replies: 0
    Last Post: 02-10-2011, 10:27 AM
  3. Replies: 0
    Last Post: 08-05-2010, 02:32 PM
  4. Newbie question about slide text
    By sasho23 in forum NetBeans
    Replies: 3
    Last Post: 06-14-2010, 12:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •