c# - 在 Web 应用程序中使用 Ghostscript(PDF 缩略图)

标签 c# asp.net pdf ghostscript

我正在为 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/

相关文章:

android - 在 Android 中查看 PDF 文件

c# - 如何将文本框绑定(bind)到 XML 文件(带命名空间)

c# - 尝试从列表接收数据时出现 System.ObjectDisposedException

c# - InputPane 禁用隐藏 (Windows Phone 8.1)

c# - DB ID 需要一个更小的 GUID 替代品,但 URL 仍然是唯一且随机的

c# - AD 使用 MembershipUser 更新电子邮件地址 - 访问被拒绝

c# - 在只有 2.0 框架的服务器上执行编译后的 3.5 代码时出现问题

c# - 在 .NET 4 中实现 RegEx 超时

pdf - 将 PDF 文件旋转 n 度,其中 n 不是 90 的倍数

android - Android应用程序填写PDF表格