Stirling-PDF icon indicating copy to clipboard operation
Stirling-PDF copied to clipboard

Error Internal Server Error:Cannot run program "gs": CreateProcess error=2, 系统找不到指定的文件。

Open university666 opened this issue 1 year ago • 1 comments

i download and run Stirling-PDF.jar When i use the compress pdf, I encountered such an error message:

Error Internal Server Error:Cannot run program "gs": CreateProcess error=2, 系统找不到指定的文件。 java.io.IOException: Cannot run program "gs": CreateProcess error=2, 系统找不到指定的文件。 at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1170) at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1089) at stirling.software.SPDF.utils.ProcessExecutor.runCommandWithOutputHandling(ProcessExecutor.java:97) at stirling.software.SPDF.utils.ProcessExecutor.runCommandWithOutputHandling(ProcessExecutor.java:80) at stirling.software.SPDF.controller.api.misc.CompressController.optimizePdf(CompressController.java:127) at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) at java.base/java.lang.reflect.Method.invoke(Method.java:580) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:262) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:190) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:917) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:829) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014) at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:914) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:590) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)

Please help to see what the problem is.

university666 avatar Jan 24 '24 09:01 university666

Standalone jar have other dependencies for these functions

Either need to follow the local setup guide or set ENV variable

ENDPOINTS_GROUPS_TO_REMOVE To value CLI

Frooodle avatar Jan 24 '24 09:01 Frooodle

@Frooodle Okay, I understand. Thank you! I have reviewed the local installation guide and indeed need to install some other dependencies. The above is from machine translation. If it sounds a bit awkward to read, please forgive me.

university666 avatar Jan 29 '24 01:01 university666

@Frooodle Okay, I understand. Thank you! I have reviewed the local installation guide and indeed need to install some other dependencies. The above is from machine translation. If it sounds a bit awkward to read, please forgive me.

在后续版本中不知为何这个功能被删除了,兄弟你解决了吗?

buynonsense avatar Jan 30 '24 15:01 buynonsense

确保安装gs和环境变量设置正确,如果你是在windows环境上运行jar包,那可能是因为代码里调用的gs命令是以gs开头,而不是gswin32或gswin64(这取决于gs的版本)

make sure you install gs and set the ENV variable correctly, if you are running on win system, it may be because the gs command called in the code starts with ‘gs’, rather than ‘gswin64c’ or 'gswin32c' (depending on your gs version)

List<String> command = new ArrayList<>();
command.add("gs");

cansushang avatar Apr 25 '24 08:04 cansushang