一、需要安装soffice.exe服务,将office转化成PDF
二、代码如下:
package com.converter;
import java.io.File;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
public class Office2PDF {
public void converter(String fileName) {
// 使用java启动OpenOffice的服务
String command = "C:\\Program Files\\OpenOffice.org 3\\"+ "program\\soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";
try {
Process pro = Runtime.getRuntime().exec(command);
} catch (Exception e1) {
e1.printStackTrace();
}
String fullPath = "D:/test/" + fileName;
File sourceFile = new File(fullPath);
String name = fileName.substring(0,fileName.lastIndexOf("."));
File pdfFile = new File("D:/test/" + name + ".pdf");
if (!pdfFile.exists()) {
// 获取连接对象
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
try {
// 取得连接
connection.connect();
// 创建文件格式转换对象
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
// 实现文件格式转换
converter.convert(sourceFile, pdfFile);
// 生成已转换的PDF文件
pdfFile.createNewFile();
} catch (Exception e) {
e.printStackTrace();
}
// 释放连接
connection.disconnect();
}
}
}
分享到:
相关推荐
将Office转成PDF文件,word转PDF,pdf转换工具,office转换工具
Office2007转pdf的插件,安装成功此插件后,在word或者ppt文件里面“另存为”就有 PDF 或 XPS 选项了。老规矩,无积分的发送邮件到:1052206223@qq.com
NULL 博文链接:https://royal2xiaose.iteye.com/blog/1460626
office 2007 PDF补丁 ,OFFICE2007另存为PDF或XPS格式补丁
易语言OFFICE文档转换成PDF源码,OFFICE文档转换成PDF,拖放对象注册,拖放对象撤销,WindowProc,拖放对象得到文件,转换到HTML,转换到HTML路径,取文件类型_程序,SetWindowLongA,CallWindowProcA,DragAcceptFiles,...
office转换pdf类库,添加word,excel,ppt的dll引用,就可以直接调用本类库,得方法,转换office文档为pdf的文档,批量转换,同时,可以再转换成swf的格式,在线查看文档,类似于百度文库!
易语言OFFICE文档转换成PDF源码。@资源源码站。
基于Java,利用OpenOffice转换office为PDF, 内附有jar包,java实现,OpenOffice下载地址,及OpenOffice在Linux下的安装实现。
office文档转化为pdf文件 c++代码-office to pdf (包含WORD EXCEL POWPOINT) (office document into a pdf file c ++ code -office to pdf (containing WORD EXCEL POWPOINT))
自己给公司内部编写使用的一个小工具,支持office系列文档批量转换成PDF格式的小工具,用C#编写有用的下载用吧。
文件转换合并工具使用 需安装....8. 合并完成后,会有完成用时提示,可以去查看合并后的文件,合并后的pdf是按承包方为单位,以一定顺序转换合并的。 7.如果软件发生崩溃,请联系技术支持。
将OFFICE文件转换成PDF档的办法 我现在天天都在制作PDF的演讲材料,其实正确的方法有三种,但无论哪种都最好安装了 Adobe Acrobat ,建议安装 Adobe Acrobat Professional 7.0 简体版,在这基础上才能进行PDF文档的...
OFFICE完美转换成PDF文档
将office2007word文档转换PDF的插件,不用上密码,从别人也无法修改!还可以插入标签等!
用于将office文档转换为pdf格式文档,进行在线预览操作
office文件可以直接转换成PDF文件,很方便的工具!
通过Office2003就可以轻松实现这个过程,可将大部分PDF直接转化为可编辑的Word文档。
OFFICE文档转换成PDF.rar
已流文件的方式显示PDF,ajax获取刘文建数据 aspose 转换office文档 PDF添加水印功能
PDF打印机,安装后可以把office文档转换成PDF文件,实用工具。