从PPTX格式与Apache POI提取图像 [英] Extracting images from pptx with apache poi
本文介绍了从PPTX格式与Apache POI提取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从百分点
与Apache POI文件,存在没有问题的幻灯片中提取,但现在我打算开 PPTX
文件和做的一样,没有人知道如何??
这是code提取百分点
文件图片:
公共ImageIcon的显示()抛出Ĵ$ P $ {psentationException 背景背景;
背景=幻灯片[电流] .getBackground();
填写F = background.getFill();
色色= f.getForegroundColor();
维维= ppt.getPageSize();
形状=幻灯片[现行] .getShapes();
IMG的BufferedImage =新的BufferedImage(dimension.width,dimension.height,BufferedImage.TYPE_INT_RGB);
Graphics2D的图形= img.createGraphics();
graphics.setPaint(颜色);
graphics.fill(新Rectangle2D.Float(0,0,dimension.width,dimension.height));
幻灯片[现行] .draw(图形);
ImageIcon的图标=新的ImageIcon(IMG); 返回图标;
}
解决方案
下面是做到这一点在VBS的方式,也许你可以转换:
子SaveAllPictures()
昏暗AP作为presentation:设置AP =活动presentation
昏暗savePath作为字符串
savePath =C:\\用户\\我\\桌面\\文件\\
昏暗我作为整数
昏暗的SL作为幻灯片
昏暗的SH作为形状
对于每个SL在ap.Slides
对于每个SH在sl.Shapes
如果sh.Type = msoPicture然后
sh.Export路径名称:= savePath&安培; sh.Name&安培; CStr的(ⅰ)及png格式,过滤器:= ppShapeFormatPNG
I = I + 1
万一
下一个
下一个
结束小组
I'm trying to extract slides from a ppt
file with Apache POI, there is no problem in that, but now I intend to open pptx
files and do the same, does anyone knows how to??
this is the code to extract images from ppt
files:
public ImageIcon display() throws JPresentationException {
Background background;
background = slides[current].getBackground();
Fill f = background.getFill();
Color color = f.getForegroundColor();
Dimension dimension = ppt.getPageSize();
shapes = slides[current].getShapes();
BufferedImage img = new BufferedImage(dimension.width, dimension.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
graphics.setPaint(color);
graphics.fill(new Rectangle2D.Float(0, 0, dimension.width, dimension.height));
slides[current].draw(graphics);
ImageIcon icon = new ImageIcon(img);
return icon;
}
解决方案
Here's the way to do it in VBS, Maybe you can convert :
Sub SaveAllPictures()
Dim ap As Presentation: Set ap = ActivePresentation
Dim savePath As String
savePath = "C:\Users\me\Desktop\files\"
Dim i As Integer
Dim sl As Slide
Dim sh As Shape
For Each sl In ap.Slides
For Each sh In sl.Shapes
If sh.Type = msoPicture Then
sh.Export PathName:=savePath & sh.Name & CStr(i) & ".png", Filter:=ppShapeFormatPNG
i = i + 1
End If
Next
Next
End Sub
这篇关于从PPTX格式与Apache POI提取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文