从Java程序执行Ghostscript的错误



我在JUNIT测试中执行Ghostscript命令,并带有错误。但是,当我在终端执行相同的命令时,该命令完成没有错误。

Command: /usr/local/bin/gs -sOutputFile="OUTPUT_PATH" -sDEVICE=pdfwrite -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -dCompatibilityLevel=1.4 -dNOPAUSE -dBATCH "INPUT_PATH"

我使用Java Runtime执行命令。

Process pr = Runtime.getRuntime().exec(command);
int exitValue = pr.waitFor();
if (exitValue != 0) {
   ....
}

执行中的错误。

GPL Ghostscript 9.21: **** Could not open the file "OUTPUT_PATH" .

问题是由构建命令时输出路径的双引号引起的。

最新更新