GhostScript有问题打开文件与空间在他们的名字

本文关键字:他们的 空间 有问题 文件 GhostScript | 更新日期: 2023-09-27 18:15:43

我正在用GhostScript做一些pdf处理,但我发现了一些奇怪的问题,当我有一个文件名,例如2。 GhostScript同样有一些问题打开这些特定的文件,我想知道我是否可能错过了一些参数或如何至少如果这些文件接近如何忽略它们?

  public static void PdfToJpg(string ghostScriptPath, string input, string output)
        {
            try
            {
                //To convert a figure to an image file: and to render the same image at 500dpi
                String ars = "-dNOPAUSE -sDEVICE=jpeg -r500 -o" + output + "%d.jpg " + input;
                Process proc = new Process();
                proc.StartInfo.FileName = ghostScriptPath;
                proc.StartInfo.Arguments = ars;
                proc.StartInfo.CreateNoWindow = true;
                proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                proc.Start();
                proc.WaitForExit();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

GhostScript有问题打开文件与空间在他们的名字

像这样指定FileNameWorkingDirectory

proc.StartInfo.FileName = Path.GetFileName(ghostScriptPath);
proc.StartInfo.WorkingDirectory = Path.GetDirectoryName(ghostScriptPath);

就像从shell调用Ghostscript一样,所以参数列表中的空格字符将被解释为一个参数的结束和下一个参数的开始。

当然,避免这种情况的方法是在文件名周围加上"。显然,您必须转义字符串中的引号。

所以它不是Ghostscript有问题在这里(GS是完全能够处理这样的文件名),它的事实,你没有满足要求的shell处理