我正在为 C# 和 ghostscript 使用 ghostscriptsharp 包装器。我想从 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 应用程序时,它工作正常(生成了一个新的 Web 服务器实例)。当我创建 WindowsForm 应用程序时,它也可以工作。生成缩略图。
当我直接使用网络浏览器 (http://localhoast/mywebappliation/..) 访问应用程序时,它不起作用。不生成缩略图。但也没有抛出异常。
我将 gsdll32.dll 放在了 windows xp 的 system32 文件夹中。 Ghostscript 运行时也已安装。我已在 IIS-Webproject (.Net 2.0) 中授予完全访问权限。
有人知道为什么我无法从我的网络应用程序访问 Ghostscript 吗?访问 IIS 服务器上的 dll 文件是否存在任何安全问题?
问候语 克劳斯
最佳答案
尝试改变当前目录
string workingDirectory = @"C:\tmp";
Directory.SetCurrentDirectory(workingDirectory);
GhostscriptWrapper.GeneratePageThumb("c:\\sample.pdf", "c:\\sample.jpg", 1, 100, 100);
关于c# - 在 Web 应用程序中使用 Ghostscript(PDF 缩略图),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2506623/