实现原理:OpenOffice4.1.3+jodconverter jar包
OpenOffice4.1.3下载路径:点击打开链接
jodconverter jar包下载路径:点击打开链接
将jodconverter jar包添加到本地maven仓库中参考路径:点击打开链接
启动OpenOffice服务参考:点击打开链接
-------------------------测试连接OpenOffice代码-----------------
private static File sourceFile=new File("F:\\XX\\XXX\\duction.ppt"); //转换源文件 private static File pdfFile=new File("E:\\XX\\Bppt.pdf"); //PDF目标文件 OpenOfficeConnection connection; connection = new SocketOpenOfficeConnection("localhost",8100); try { connection.connect(); DocumentConverter converter = new OpenOfficeDocumentConverter(connection); converter.convert(sourceFile, pdfFile); pdfFile.createNewFile(); connection.disconnect(); System.out.println("第二步:转换为PDF格式文件生成文件路径" + pdfFile.getPath()); } catch (java.net.ConnectException e) { e.printStackTrace(); System.out.println("OpenOffice服务未启动!!"); throw e; } catch (com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException e) { e.printStackTrace(); System.out.println("文件不存在/读取文件失败"); throw e; } catch (Exception e){ e.printStackTrace(); try { throw e; } catch (Exception e1) { e1.printStackTrace(); } } ---------只测了.doc .txt .ppt 转pdf 生成文件如下---