当我将pdf转换为image时,我遇到了一个奇怪的问题。我正在执行pdf上的转换代码。它第一次运行良好,然后开始给出我从下一次出现“ghostscript转换错误”。给出错误的代码如下所示。Ghostscript在第一次正确执行后给出“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);
}
我在做什么错?
您是否尝试将第一个'arg'留空(空白)?当通过API调用Ghostscript时,忽略第一个参数(arg [0])。 – HABJAN 2014-10-07 08:10:16