/**
* 连接LibreOffice.org 并且启动LibreOffice.org
*
* @return
* @throws Exception
*/
public static OfficeManager getOfficeManager() throws Exception {
String osName = System.getProperty("os.name");
if (Pattern.matches("Linux.*", osName)) {//如果是Linux系统则尝试先结束上次启动的Libreoffice
String pid = LinuxProcessUtil.getPID("libreoffice");
logger.info("找到pid="+pid);
if (StringUtils.isNotEmpty(pid)) {
LinuxProcessUtil.closeLinuxProcess(pid);
}
}
DefaultOfficeManagerConfiguration config = new DefaultOfficeManagerConfiguration();
// 设置LibreOffice.org 3的安装目录
config.setOfficeHome(getOfficeHome());
// 端口号
config.setPortNumber(8100);
config.setTaskExecutionTimeout(1000 * 60 * 25L);
// 设置任务执行超时为10分钟
config.setTaskQueueTimeout(1000 * 60 * 60 * 24L);
// 设置任务队列超时为24小时
// 启动LibreOffice的服务
OfficeManager getOfficeManager = config.buildOfficeManager();
getOfficeManager.start();
return getOfficeManager;
}