https://issues.apache.org/bugzilla/show_bug.cgi?id=46159
Summary: Using the "Shapes How to" Sample to export the slide
into images, NullPointException
Product: POI
Version: 3.5-dev
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: HSLF
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
CC: [EMAIL PROTECTED]
When I feed the ppt file (as attached file) to the example in the POI home page
-> HSLF -> Shapes How to -> Export PowerPoint slides into java.awt.Graphics2D
Exception in thread "main" java.lang.NullPointerException
at org.apache.poi.hslf.model.Picture.draw(Picture.java:266)
at org.apache.poi.hslf.model.ShapeGroup.draw(ShapeGroup.java:280)
at org.apache.poi.hslf.model.Slide.draw(Slide.java:431)
at test.TestShape.exportToImage(TestShape.java:135)
at test.TestShape.main(TestShape.java:112)
I know the problem is the in Picture's draw function the getPictureData is
null. But why?
HSLF provides a way to export slides into images. You can capture slides into
java.awt.Graphics2D object (or any other) and serialize it into a PNG or JPEG
format. Please note, although HSLF attempts to render slides as close to
PowerPoint as possible, the output may look differently from PowerPoint due to
the following reasons:
* Java2D renders fonts differently vs PowerPoint. There are always some
differences in the way the font glyphs are painted
* HSLF uses java.awt.font.LineBreakMeasurer to break text into lines.
PowerPoint may do it in a different way.
* If a font from the presentation is not avaiable, then the JDK default
font will be used.
Current Limitations:
* Some types of shapes are not yet supported (WordArt, complex auto-shapes)
* Only Bitmap images (PNG, JPEG, DIB) can be rendered in Java
FileInputStream is = new FileInputStream("slideshow.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();
}
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]