把word、ppt、excel转为pdf

把word、ppt、excel转为pdf

2.主要代码

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; } } System.out.println("转换完成"); } public static void main(String[] args) throws Exception { Office2Pdf one = new Office2Pdf(); one.createPDF("E:\\a.doc", "E:\\a.pdf"); one.createPDF("E:\\a.ppt", "E:\\a.pdf"); one.createPDF("E:\\a.xls", "E:\\a.pdf"); } }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zgfgsd.html