我尝试使用Apache POI项目将我的PPT
转换为Images时出现问题。我的代码如下:使用APACHE POI将PPT转换为图像时,将中文字符转换为正方形
FileInputStream is = new FileInputStream("test.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();
它工作正常,但所有的中文单词都转换为一些方块。那我该如何解决这个问题?
你确定你正在使用的字体是汉字的字形吗?只有当你使用的字体没有,你会看到类似的东西... – Gagravarr 2011-12-30 10:18:26