Results 1 to 8 of 8
Thread: Converter a slide to picture
- 12-31-2011, 08:02 PM #1
Member
- Join Date
- Dec 2011
- Posts
- 4
- Rep Power
- 0
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)
- 01-01-2012, 01:11 PM #2
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.
- 01-01-2012, 04:06 PM #3
Member
- Join Date
- Dec 2011
- Posts
- 4
- Rep Power
- 0
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.
- 01-01-2012, 04:11 PM #4
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.
- 01-01-2012, 04:33 PM #5
Member
- Join Date
- Dec 2011
- Posts
- 4
- Rep Power
- 0
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
- 01-01-2012, 04:36 PM #6
Re: Converter a slide to picture
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.i didn't find the code of error like "java.lang.NoSuchMethodError"
- 01-01-2012, 08:02 PM #7
Member
- Join Date
- Dec 2011
- Posts
- 4
- Rep Power
- 0
Re: Converter a slide to picture
Else can you please show the jars used because I can not resolve its mistakes?
- 01-01-2012, 08:23 PM #8
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
-
Selection of PowerPointSlide # NOT create new slide
By greenhorn in forum New To JavaReplies: 0Last Post: 02-16-2011, 12:49 PM -
Transfer Excel Information --> PowerPoint Slide
By greenhorn in forum Advanced JavaReplies: 0Last Post: 02-10-2011, 10:27 AM -
Enhanced Slide Rendering, Slide Cloning & Presentation Access
By sherazam in forum Java SoftwareReplies: 0Last Post: 08-05-2010, 02:32 PM -
Newbie question about slide text
By sasho23 in forum NetBeansReplies: 3Last Post: 06-14-2010, 12:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks