我正在将PPT和PPTX文件转换为HTML。
我可以获得背景图片,文字,布局等。但我无法获得自定义形状和动画。
我项目的一些代码:
public static void getPic(XMLSlideShow ppts) throws Exception {
for (XSLFPictureData data : ppts.getPictureData()) {
String index = data.getIndex()+1 + "";
String ext = data.getType().extension;
FileOutputStream fileout = new FileOutputStream(path + "imgPPTX\\" + index + ext);
InputStream pIs = data.getInputStream();
if (ext.equals(".wmf")) {
Wmf2Svg.convert(path + index + ext);
ext = ".svg";
}
// System.out.println(pict.getHeader().toString());
img.put(data.getFileName(), index + ext);
fileout.write(data.getData());
fileout.close();
pIs.close();
}
}
public static void getBg(XSLFSlide ppt) throws Exception {
System.out.println(ppt.getSlideNumber() + ": " + ppt.getSlideLayout().getTheme().getName() + " " + ppt.getSlideLayout().getName());
XSLFBackground bg = ppt.getBackground();
CTBackground xmlBg = (CTBackground) bg.getXmlObject();
if (xmlBg.getBgPr().getBlipFill() != null) {
String relId = xmlBg.getBgPr().getBlipFill().getBlip().getEmbed();
XSLFPictureData pic = (XSLFPictureData) ppt.getRelationById(relId);
htmlins.insertImg(img.get(pic.getFileName()), "[x=0,y=0,w="+pageSize.getWidth()+",h="+pageSize.getHeight()+"]");
// System.out.println("backg: " + pic.getFileName());
} else {
// System.out.println("backg: no background");
}
for (XSLFShape shape : ppt.getSlideLayout().getShapes()) {
dealBGShape(shape);
}
}