我正在尝试使用JODConveter将office文件转换为pdf。我已按照[此链接] http://www.artofsolving.com/node/14.html
中的所有步骤进行操作但是显示错误。 enter image description here
答案 0 :(得分:0)
首先需要设置Open office的路径变量,然后打开cmd,打开办公室安装位置然后运行命令
soffice -headless -accept="socket,host=localhost,port=8100;urp;" -nofirststartwizard
在java项目中使用此代码:
OpenOfficeConnection connection = new SocketOpenOfficeConnection("localhost",8100);
try {
connection.connect();
long t1 = System.currentTimeMillis();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFileLoacation);
long t2 = System.currentTimeMillis();
System.out.println(input + " = " + (t2 - t1) + " ms");
} catch (ConnectException e) {
e.printStackTrace();
} finally {
if (connection.isConnected()) {
connection.disconnect();
}