jacob ppt转换成图片报错
错误:Exception in thread "main" com.jacob.com.ComFailException: Invoke of: SaveCopyAs
Source: Microsoft PowerPoint 2013
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"); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已找到原因:我用的office2013,换成office2010就行了