日期:2014-05-17 浏览次数:20824 次
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();   
                       [color=#FF0000] app = new IDispatch(rm, "PDFMakerAPI.PDFMakerApp");   [/color]
                 [color=#0000FF]        //这里变态出问题,而且里面参数都可以写什么[/color]
                        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");   
        }   
}  
错误提示:
[color=#FF0000]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)[/color]