Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.jacob.com.ComFailException: Invoke of: Open Source: Description #46

Open
yujunchengg opened this issue Nov 6, 2023 · 1 comment

Comments

@yujunchengg
Copy link

My program runs in the following environmen
windows server 2016 Standard 64 bit
Microsoft Office Professional 2016
jdk version: 1.8.0 (build 1.8.0_221-b11)
jacob version: 1.20
The program code is as follows
public static FileConvertResult ppt2PDF(String pptfile, String pdffile){
if(Files.exists(Paths.get(pdffile))){
return new FileConvertResult(true,false);
}
synchronized (pptfile.intern()){
FileConvertResult result = new FileConvertResult(true,false);
if(Files.exists(Paths.get(pdffile))){
log.info("current thread: {} do not need to execute ppt2PDF method, because other thread has execute ppt2PDF method",Thread.currentThread().getName());
return result;
}
ActiveXComponent ppt = null;
Dispatch presentations = null;
try {
ComThread.InitMTA(true);
ppt = new ActiveXComponent("PowerPoint.application");
Dispatch.put(ppt.getObject(), "DisplayAlerts", new Variant(false));
presentations = ppt.invokeGetComponent("Presentations").invokeGetComponent("Open", new Variant(pptfile));
Dispatch.invoke(presentations, "SaveAs", Dispatch.Method, new Object[] {pdffile , new Variant(32) }, new int[1]);
} catch (Exception e) {
log.error("-------------ppt2PDF occurred exception----------");
String message = e.getMessage();
result.setSuccess(false);
result.setNeedReconvert(true);
result.setDescription(message);
/if(null!=message){
if(message.contains("Description: ")){
result.setNeedReconvert(false);
}
}
/
log.error(result.getDescription(), e);
} finally {
try {
if (ppt != null) {
ppt.invoke("Quit");
}
} catch (Exception e1) {
log.error(e1.getMessage(),e1);
} finally {
if (presentations != null){
presentations.safeRelease();
}
if (ppt != null){
ppt.safeRelease();
}
ComThread.Release();
}
}
return result;
}
}

Strangely enough it can work well on Windows server 2012,but on Windows server 2016,it occurred exception,exception detail message is that:
com.jacob.com.ComFailException: Invoke of: Open
Source:
Description:

at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:625)
at com.jacob.com.Dispatch.callN(Dispatch.java:453)
at com.jacob.activeX.ActiveXComponent.invoke(ActiveXComponent.java:476)
at com.jacob.activeX.ActiveXComponent.invokeGetComponent(ActiveXComponent.java:391)
@EJP286CRSKW
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants