我爲c#和ghostscript使用ghostscriptsharp包裝。我想從pdf文件中生成縮略圖。有關示例代碼的更多信息請參見here。在Web應用程序中使用Ghostscript(PDF縮略圖)
有不同的方法從ghostscript-c-dll「gsdll32.dll」導入。
[DllImport("gsdll32.dll", EntryPoint = "gsapi_new_instance")]
private static extern int CreateAPIInstance(out IntPtr pinstance,
IntPtr caller_handle);
[DllImport("gsdll32.dll", EntryPoint = "gsapi_init_with_args")]
private static extern int InitAPI(IntPtr instance, int argc, IntPtr argv);
//...and so on
我正在使用GhostscriptWrapper在Web應用程序(.net 2.0)中生成縮略圖。這個類使用上面導入的方法。
protected void Page_Load(object sender, EventArgs e){
GhostscriptWrapper.GeneratePageThumb("c:\\sample.pdf", "c:\\sample.jpg", 1, 100, 100);
}
當我通過敲擊鍵「F5」它工作正常調試網絡應用程序在Visual Studio 2008(Web服務器的新實例生成)。當我創建WindowsForm應用程序時,它也可以工作。生成縮略圖。
當我直接使用web瀏覽器訪問應用程序(http://localhoast/mywebappliation/.)時,它不起作用。沒有生成縮略圖。但也沒有拋出異常。
我將gsdll32.dll放在windows xp的system32文件夾中。 Ghostscript Runtime也被安裝。我在IIS-Webproject(.Net 2.0)中提供了完全訪問權限。
有誰知道我爲什麼不能從我的web應用程序訪問Ghostscript?是否有訪問IIS服務器上的DLL文件的安全問題?
問候 克勞斯
我已經給所有可能的用戶(iis用戶,aspnetuser等)寫入權限爲c:\,gsdll32.dll,gs.exe,但它沒有工作。 – 2010-03-31 18:00:17
您需要將gsdll32.dll放入webs bin文件夾。 – Adrian 2010-04-01 09:41:05