I use windows11 ,start LibreOffice use cmd order,
soffice --headless --accept=“socket,host=0.0.0.0,port=8100;urp;” --nofirststartwizard
actually start successful,and I can listener port and service.
I use java code try to connect libreoffice
@Test
public void testConnectionToLibreOffice() throws OfficeException {
// 请替换下面的IP地址和端口为实际可用的服务地址和端口
String officeUrl = “http://192.168.2.7:8100”; // 示例IP,请替换为实际IP和端口
// 创建远程Office管理器
OfficeManager officeManager = RemoteOfficeManager.builder()
.urlConnection(officeUrl)
.build();
try {
System.err.println("开始连接 " + officeUrl);
officeManager.start();
// 进行一个简单的文档转换测试
File file = new File("D:\\ideaProjects\\LibreOfficeRemoteDemo\\test.doc"); // 替换为实际文件路径
File outputFile = new File("D:\\ideaProjects\\LibreOfficeRemoteDemo\\output.pdf"); // 输出文件路径
RemoteConverter converter = RemoteConverter.make(officeManager);
converter.convert(file).to(outputFile).execute();
System.err.println("连接成功");
// 这里可以添加你的文档转换逻辑
} catch (OfficeException e) {
System.err.println("连接失败: " + e.getMessage());
e.printStackTrace();
} finally {
// 确保最后关闭office管理器
if (officeManager.isRunning()) {
officeManager.stop();
System.err.println("关闭office管理器");
}
}
}
always Read timed out ,I sure the post request start, but libreoffice service do not response me,how can i get response??? local is successful,i want remote