You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: