java调用jacob将word转pdf文档,弹出窗口问题
我在用jacob调用office的save as pdf插件的时候,如果碰到加密的文件会要我输入密码,否则会一直停在那个地方不动,导致线程阻塞,请大神们指点一二!!我的代码:
Dispatch docs=null;
Dispatch doc =null;
ActiveXComponent app=null;
try{
app = new ActiveXComponent("Word.Application");
app.setProperty("Visible", false);
docs = app.getProperty("Documents").toDispatch();
logger.debug("打开文档:" + inputFile);
doc = Dispatch.call(docs,"Open",inputFile,false,true).toDispatch();
logger.debug("转换文档到PDF:" + pdfFile);
File tofile = new File(pdfFile);
if (tofile.exists()){
tofile.delete();}
Dispatch.call(doc,"SaveAs",pdfFile,wdFormatPDF);
Dispatch.call(doc, "Close", false);
logger.info("转换成功!word2PDF,inputFile:"+inputFile+",outputFile:"+pdfFile);
doc.safeRelease();
}catch (Exception e) {
logger.info("转换失败!word2PDF,inputFile:"+inputFile+",outputFile:"+pdfFile);
logger.error(e);
return false;
}finally
{
docs.safeRelease();
app.invoke("Quit", new Variant[]{} );
app.safeRelease();
}
return true;
图片如下:
java jacob 弹窗 word jacob java 加密文件 弹窗 --------------------编程问答-------------------- 自己先顶!! --------------------编程问答-------------------- 千万别沉了,期待大神给答案 --------------------编程问答-------------------- 有人来瞧瞧吗?
补充:Java , Java EE