當我將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