在 ASP.NET Azure 网站上使用 Ghostscript.Net

Using Ghostscript.Net on an ASP.NET Azure Website

我正在使用 Ghostscript.NET 将 PDF 页面转换为 jpg。当我在本地 运行 时一切正常,但是当我将它发布到 Azure 网站时我收到错误:

"此托管库 运行 在 32 位进程下运行,需要在此机器上安装 32 位 Ghostscript 本机库!要下载正确的 Ghostscript 本机库,请访问:http://www.ghostscript.com/download/gsdnld.html"

显然我不能只在 Azure 网站运行正在运行的服务器上安装 Ghostscript,我无权执行此操作。有什么方法可以在发布配置文件中包含 Ghostscript 库,并让 Ghostscript.NET 从中读取?

或者,是否有 any 包可以让我在 ASP.NET 服务器上将 PDF 页面转换为 jpg 缩略图,而根本不使用 Ghostscript?我也尝试过 GhostScriptSharp,但也没有成功。

你有几个选择。

  1. 将您的网站托管为 Azure Cloud Service Web 角色。这允许您对正在创建的服务器做出反应,并且您可以 运行 安装程序(如果您可以自动化它们)来准备机器。

  2. 将此功能拆分为 Azure 云服务工作者角色(您可以在其中进行相同的机器准备)并让它响应 Azure Queue 项目。这样您的网站几乎保持原样。

不过要小心,Cloud Services can get expensive if they are just sitting there doing nothing because its still running on a VM. You can have your Cloud Service scale 基于队列是否有项目。

您可以尝试安装本机 ghostscript 库 到您的本地计算机并获取gsdll32.dll(或gsdll64.dll 如果您 运行 在 x64 位环境中),您可以 将其与其他 dll 一起部署到您的服务器

看看这个例子如何告诉 Ghostscript.NET 在哪里搜索本地 ghostscript 库 dll:https://github.com/jhabjan/Ghostscript.NET/blob/master/Ghostscript.NET.Samples/Samples/CustomGsdllLocationSample.cs