81,092
社区成员
发帖
与我相关
我的任务
分享
package com.test.word;
import jp.ne.so_net.ga2.no_ji.jcom.IDispatch;
import jp.ne.so_net.ga2.no_ji.jcom.ReleaseManager;
public class Office2Pdf {
public void createPDF(String officePath,String pdfPath) throws Exception {
ReleaseManager rm = null;
IDispatch app = null;
try {
rm=new ReleaseManager();
app = new IDispatch(rm, "PDFMakerAPI.PDFMakerApp");
//这里变态出问题,而且里面参数都可以写什么
app.method("CreatePDF",new Object[]{officePath,pdfPath});
} catch (Exception e) {
throw e;
} finally {
try {
app=null;
rm.release();
rm = null;
} catch (Exception e) {
throw e;
}
}
}
public static void main(String[] args) throws Exception {
Office2Pdf one=new Office2Pdf();
one.createPDF("E:\\codigg.ppt","E:\\codigg-ppt.pdf");
one.createPDF("E:\\codigg.doc","E:\\codigg-doc.pdf");
one.createPDF("E:\\codigg.xls","E:\\codigg-xls.pdf");
}
}
错误提示:
Exception in thread "main" jp.ne.so_net.ga2.no_ji.jcom.JComException: createInstance() failed HRESULT=0x800401F3L
at jp.ne.so_net.ga2.no_ji.jcom.IDispatch._create(Native Method)
at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.create(IDispatch.java:84)
at jp.ne.so_net.ga2.no_ji.jcom.IDispatch.<init>(IDispatch.java:46)
at com.test.word.Office2Pdf.createPDF(Office2Pdf.java:12)
at com.test.word.Office2Pdf.main(Office2Pdf.java:29)