java使用openoffice将word转pdf时,出现could not save output document的问题
ZJJG4 2019-07-25 10:59:22 java使用openoffice将word转pdf时,报 2019-07-25 10:45:52 ERROR com.googosoft.resolver.MyExceptionResolver:33 - com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not save output document; OOo errorCode: 2074问题
下面是方法的代码:public static void WordToPDF(String startFile, String overFile) throws IOException, ConnectException { // 源文件目录
File inputFile = new File(startFile);
if (!inputFile.exists()) {
System.out.println("源文件不存在!");
return;
}
// 输出文件目录
File outputFile = new File(overFile);
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().exists();
}
// 调用openoffice服务线程
/** 我把openOffice下载到了 C:/Program Files (x86)/下 ,下面的写法自己修改编辑就可以**/
String OpenOfficePath =PropertiesUtil.getGlobalValueByKey("OpenOfficePath");
String command=null;
/** windows 服务器调用的地址会带EXE **/
if(OpenOfficePath.indexOf(".exe")>0 || OpenOfficePath.indexOf(".EXE")>0) {
command = OpenOfficePath+" -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\"";
}
/** linux 不会带 **/
else {
command = "nohup "+OpenOfficePath+" -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard & ";
}
System.out.println("----------------------------------"+command+OpenOfficePath);
Process p = Runtime.getRuntime().exec(command);
// 连接openoffice服务
OpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
connection.connect();
// 转换
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
//DocumentConverter converter = new StreamOpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
// 关闭连接
connection.disconnect();
// 关闭进程
p.destroy();
}
一运行到converter.convert(inputFile, outputFile); 就出问题,求大神解惑