问题遇到的现象和发生背景
遇到了一个word转pdf的需求,经过几番波折,决定使用LibreOffice+jodconverter的方式来实现
操作环境、软件版本等信息
现在的情况是,在windows下以及linux下都能实现word转pdf,
但是一旦使用docker来部署项目,将LibreOffice在Linux的安装路径挂载到docker,启动项目,调用到word转pdf的功能时,就会爆出下面的错误
[2023-11-08 16:38:23.313] [WARN ] [] [jodconverter-offprocmng-20] [o.j.local.office.LocalOfficeProcessManager:703] >> An I/O error prevents us to determine office version
2023-11-08T08:38:23.315243788Z java.io.IOException: Cannot run program "/opt/libreoffice7.5/program/soffice.bin": error=2, No such file or directory
2023-11-08T08:38:23.315259448Z at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
2023-11-08T08:38:23.315266187Z at org.jodconverter.local.office.LocalOfficeProcessManager.detectOfficeDescriptor(LocalOfficeProcessManager.java:691)
2023-11-08T08:38:23.315272789Z at org.jodconverter.local.office.LocalOfficeProcessManager.startProcessAndConnect(LocalOfficeProcessManager.java:374)
2023-11-08T08:38:23.315294489Z at org.jodconverter.local.office.LocalOfficeProcessManager.lambda$start$1(LocalOfficeProcessManager.java:213)
2023-11-08T08:38:23.315301412Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2023-11-08T08:38:23.315308024Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2023-11-08T08:38:23.315314409Z at java.lang.Thread.run(Thread.java:748)
2023-11-08T08:38:23.315320627Z Caused by: java.io.IOException: error=2, No such file or directory
2023-11-08T08:38:23.315326988Z at java.lang.UNIXProcess.forkAndExec(Native Method)
2023-11-08T08:38:23.315333543Z at java.lang.UNIXProcess.(UNIXProcess.java:247)
2023-11-08T08:38:23.315340109Z at java.lang.ProcessImpl.start(ProcessImpl.java:134)
2023-11-08T08:38:23.315346263Z at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
2023-11-08T08:38:23.315373884Z ... 6 common frames omitted
2023-11-08T08:38:23.327367427Z [2023-11-08 16:38:23.326] [INFO ] [] [jodconverter-offprocmng-20] [o.j.local.office.LocalOfficeProcessManager:416] >> Starting process with --accept 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ServiceManager' and profileDir '/tmp/.jodconverter_socket_host-127.0.0.1_port-2002_tcpNoDelay-1'
2023-11-08T08:38:23.329965909Z [2023-11-08 16:38:23.328] [ERROR] [] [jodconverter-offprocmng-20] [o.j.local.office.LocalOfficeProcessManager:215] >> Could not start the office process.
2023-11-08T08:38:23.329998652Z org.jodconverter.core.office.OfficeException: An error prevents us to start a process with --accept 'socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ServiceManager'
2023-11-08T08:38:23.330008428Z at org.jodconverter.local.office.LocalOfficeProcessManager.executeStartProcessAndConnect(LocalOfficeProcessManager.java:442)
2023-11-08T08:38:23.330015568Z at org.jodconverter.local.office.LocalOfficeProcessManager.startProcessAndConnect(LocalOfficeProcessManager.java:395)
2023-11-08T08:38:23.330022130Z at org.jodconverter.local.office.LocalOfficeProcessManager.lambda$start$1(LocalOfficeProcessManager.java:213)
2023-11-08T08:38:23.330028832Z at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
2023-11-08T08:38:23.330035097Z at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
2023-11-08T08:38:23.330041936Z at java.lang.Thread.run(Thread.java:748)
2023-11-08T08:38:23.330048405Z Caused by: java.io.IOException: Cannot run program "/opt/libreoffice7.5/program/soffice.bin": error=2, No such file or directory
2023-11-08T08:38:23.330105761Z at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
2023-11-08T08:38:23.330115350Z at org.jodconverter.local.office.StartProcessAndConnectRetryable.startProcess(StartProcessAndConnectRetryable.java:143)
2023-11-08T08:38:23.330121855Z at org.jodconverter.local.office.StartProcessAndConnectRetryable.attempt(StartProcessAndConnectRetryable.java:95)
2023-11-08T08:38:23.330128447Z at org.jodconverter.core.office.AbstractRetryable.execute(AbstractRetryable.java:86)
2023-11-08T08:38:23.330134695Z at org.jodconverter.core.office.AbstractRetryable.execute(AbstractRetryable.java:60)
2023-11-08T08:38:23.330141247Z at org.jodconverter.local.office.LocalOfficeProcessManager.executeStartProcessAndConnect(LocalOfficeProcessManager.java:428)
2023-11-08T08:38:23.330186993Z ... 5 common frames omitted
2023-11-08T08:38:23.330196061Z Caused by: java.io.IOException: error=2, No such file or directory
2023-11-08T08:38:23.330202279Z at java.lang.UNIXProcess.forkAndExec(Native Method)
2023-11-08T08:38:23.330208680Z at java.lang.UNIXProcess.(UNIXProcess.java:247)
2023-11-08T08:38:23.330215306Z at java.lang.ProcessImpl.start(ProcessImpl.java:134)
2023-11-08T08:38:23.330221513Z at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
2023-11-08T08:38:23.330227868Z ... 10 common frames omitted
我想要达到的结果
可以实现word转pdf的功能