错误:Exception in thread "main" com.jacob.com.ComFailException: Invoke of: SaveCopyAs
Source: Microsoft PowerPoint 2013
Description: Presentation.SaveCopyAs : Invalid request. Saving as an HTML presentation is not supported in this version of PowerPoint.
public static synchronized void ppt2Img(String inputFile,String pdfFile){
System.out.println("ppt2PDF==========进入");
ActiveXComponent app = null;
try {
app = new ActiveXComponent("PowerPoint.Application");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("--------------------");
app.setProperty("Visible", true);
Dispatch ppts = app.getProperty("Presentations").toDispatch();
System.out.println("ppt2PDF==========准备打开ppt文档");
System.out.println(new File(inputFile).exists());
Dispatch ppt = Dispatch.call(ppts,
"Open",
inputFile,
true,//ReadOnly
true,//Untitled指定文件是否有标题
true//WithWindow指定文件是否可见
).toDispatch();
System.out.println("ppt2PDF==========准备转换ppt文档");
Dispatch.call(ppt,
"SaveCopyAs",
pdfFile,
17//转换成jpg
);
System.out.println("ppt2PDF==========准备关闭ppt文档");
Dispatch.call(ppt, "Close");
app.invoke("Quit");
}
public static void main(String[] args) {
//word2PDF("D://aaa.docx","D://aaa.pdf");
ppt2Img("D://t.pptx","D://ppt_img/a.jpg");
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
已找到原因:我用的office2013,换成office2010就行了