我正在使用apachefoo将ppt转换为图像。但是,表格图像未保存
public static void main(String[] args) throws Exception{
String filePath = "C:\\Users\\SEPOA\\Desktop\\test\\default\\전자계약-이론.pptx";
FileInputStream fis = null;
XMLSlideShow ppt = null;
List<String> imgFilePathList = new ArrayList<>();
try {
fis = new FileInputStream(new File(filePath));
ppt = new XMLSlideShow(fis);
fis.close();
Dimension pgsize = ppt.getPageSize();
XSLFSlide[] slide = ppt.getSlides();
float scale = 1.0f;
int width = (int) (pgsize.width * scale);
int height = (int) (pgsize.height * scale);
System.out.println("final Dimension pgsize : " + pgsize);
System.out.println("final XSLFSlide [] slide : " + slide);
for(int i=0; i<slide.length; i++) {
final BufferedImage img = new BufferedImage(width, height, BufferedImage.SCALE_DEFAULT);
final Graphics2D graphics = img.createGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setPaint(Color.white);
graphics.clearRect(0, 0, width, height);
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
graphics.scale(scale, scale);
slide[i].draw(graphics);
String slideFilePath = "C:\\Users\\SEPOA\\Desktop\\test\\default\\convert\\convert_"+i+".jpg";
imgFilePathList.add(slideFilePath);
File slideFile = new File(slideFilePath);
if (!slideFile.getParentFile().exists()) {
slideFile.getParentFile().mkdirs();
}
ImageIO.write(img, "jpg", slideFile);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (fis != null) {
fis.close();
}
}
}
没有表格图像保存...
我没找到。 api文件中没有任何内容
英文不好。抱歉,我有一个问题。