使用APACHE POI将PPT转Image时汉字转为方格 [英] Chinese characters converted to squares when using APACHE POI to convert PPT to Image
本文介绍了使用APACHE POI将PPT转Image时汉字转为方格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用 Apache POI 项目将我的 PPT
转换为图像时遇到问题.我的代码如下:
I got a problem when I try to use Apache POI project to convert my PPT
to Images. My code as follows:
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();
除了所有中文单词都转换为一些方块之外,它工作正常.那么我该如何解决这个问题?
It works fine except that all Chinese words are converted to some squares. Then how can I fix this?
推荐答案
这似乎是 apache POI 的一个错误.我已经在 bugzilla 中添加了它
This seems to be a bug with apache POI. I have added it in bugzilla
https://issues.apache.org/bugzilla/show_bug.cgi?id=54880
这篇关于使用APACHE POI将PPT转Image时汉字转为方格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文