我在将pdf转换为image时遇到了一个奇怪的问题。我正在pdf hover上执行转换代码。它第一次运行良好,然后开始给我" ghostscript转换错误"从下一次开始。给出错误的代码如下。
int result = InitAPI(gsInstancePtr, args.Length, args);
返回错误代码-100。完整代码如下。
public static void CallAPI(string[] args)
{
// Get a pointer to an instance of the Ghostscript API and run the API with the current arguments
IntPtr gsInstancePtr;
lock (resourceLock)
{
CreateAPIInstance(out gsInstancePtr, IntPtr.Zero);
try
{
int result = InitAPI(gsInstancePtr, args.Length, args);
if (result < 0)
{
throw new ExternalException("Ghostscript conversion error", result);
}
}
finally
{
Cleanup(gsInstancePtr);
}
}
}
/// <summary>
/// Frees up the memory used for the API arguments and clears the Ghostscript API instance
/// </summary>
private static void Cleanup(IntPtr gsInstancePtr)
{
ExitAPI(gsInstancePtr);
DeleteAPIInstance(gsInstancePtr);
}
我做错了什么?
答案 0 :(得分:0)
嗯,第一个问题是,你没有使用Ghostscript,至少不是直接使用Ghostscript。可能你正在使用Ghostscript.NET?
从Ghostscript本身错误-100表示致命错误,可能在stdout或stderr上提供其他信息,您需要捕获并报告该错误。