[POI] Générer des images à partir d'une présentation PowerPoint
bonjour,
J'ai utilisé l'api POI pour extraire les images d'une présentation PowerPoint :
voici le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| public static void main(String str[]) throws IOException{
test2();
}
public static void test2() throws IOException{
FileInputStream is = new FileInputStream("AAA.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, 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 = new FileOutputStream("slide-" + (i+1) + ".png");
javax.imageio.ImageIO.write(img, "png", out);
out.close();
}
} |
A l'exécution j'ai le message suivant :
Code:
1 2 3 4 5 6 7
|
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.poi.POIDocument: method <init>()V not found
at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:114)
at org.apache.poi.hslf.HSLFSlideShow.<init>(HSLFSlideShow.java:102)
at org.apache.poi.hslf.usermodel.SlideShow.<init>(SlideShow.java:127)
at convert.Testconvert.test2(Testconvert.java:26)
at convert.Testconvert.main(Testconvert.java:21) |
Merci pour votre aide.