开发者社区> 问答> 正文

jacob ppt转换成图片报错?报错

错误: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");
    }



展开
收起
爱吃鱼的程序员 2020-06-15 19:32:29 1126 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    已找到原因:我用的office2013,换成office2010就行了

    2020-06-15 19:32:45
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
成功案例-Par...[幸运杰哥].1512720360.pdf 立即下载
阿里市调.pdf[入林龙].1479382903.pdf 立即下载
原文.pdf[【方向】].1492242596.pdf 立即下载