从现有代码中获取错误代码:“在调用'gsapi_init_with_args'时发生错误:-100”,无法找到问题

问题描述

using System.Text;

使用Ghostscript.NET; 使用Ghostscript.NET.Processor;

命名空间Metro.MbaProcessing.Core { 内部静态类PdfToText { 私有常量字符串HandleTag =“%handle%”; 私有常量字符串HandleFormat =“ X2”;

    internal static string Process(string filePath,Encoding encoding)
    {
        GhostscriptVersionInfo gsv = GhostscriptVersionInfo.GetLastInstalledVersion();
        using var processor = new Ghostscriptprocessor(gsv);
        using var pipedOutput = new GhostscriptPipedOutput();

        string outputPipeHandle = $"{HandleTag}{int.Parse(pipedOutput.ClientHandle).ToString(HandleFormat)}";
        string[] switches =
        {
            $"-o{outputPipeHandle}","-empty","-dQUIET","-dSAFER","-dBATCH","-dnopAUSE","-dnopROMPT","-sDEVICE=txtwrite",//$"-o{outputPipeHandle}","-q","-f",filePath
        };
        processor.StartProcessing(switches,null);

        return encoding.GetString(pipedOutput.Data);
    }
}

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)