JACOB:Presentation.Export:PowerPoint无法将^ 0保存到^ 1

时间:2016-05-27 09:06:05

标签: java jacob

public boolean PptExport2Png(String filePath,String exportPath){
    Boolean flag = false;
    ActiveXComponent component = new ActiveXComponent("PowerPoint.Application");
    try{
        Dispatch presentations = component.getProperty("Presentations").toDispatch();

        Dispatch presentation = Dispatch.call(presentations, "Open", new Variant(filePath),
                new Variant(-1), new Variant(-1), new Variant(0))
                .toDispatch();
        Dispatch.call(presentation,"Export",new Variant(exportPath),new Variant(720),new Variant(540));

    }catch (Exception e){
        System.out.println("|||" + e.toString());
    }finally {

    }
    return false;
}

public static void main(String[] strs)throws Exception{
    String filePath="D://ppttest.ppt";
    String pngPath="D://folder22";
    JacobPptUtils jac = new JacobPptUtils(filePath,true);
    jac.PptExport2Png(filePath,pngPath);
}

我发现当我使用JACOB导出ppt时,现在,我没有任何想法。请给我一些建议来处理它。

以下是我尝试的方式: 1.修改文件路径表达式

1 个答案:

答案 0 :(得分:0)

 public static void main(String args[]) throws Exception{
   source = "D:/test.ppt" ;
    dest = "D:/xxx.pdf" ;
    File file = new File(source);

    if(!file.exists()){
        throw new Exception("error");
    }
    ppt2Pdf(source,dest);

   }
}