.net 上的 Ghostscript 安装问题

Ghostscript installation issue on .net

为了在我的 MVC C# 应用程序中安装 Ghostscript,我遵循了大量 SO 指南,但我无法识别下面的代码。它一直说“找不到 GhostscriptRasterizer(您是否缺少 using 指令或程序集引用?)”

public ActionResult PDFToImages(string pdfFilePath)
        {
            //...

            using (var rasterizer = new GhostscriptRasterizer())
            {
                //...
            }

            //...
        }

我正在使用 Visual Studio,这是我已经尝试过的:

如果您的 objective 是直接使用 Ghostscript .NET,则不需要从您的项目中引用原始的 Ghostscript DLL(正如我所说,直到您愿意这样做)。

我在 Windows 7 和 windows 10 上测试了 Ghostscript .NET,Visual Studio Community 2017 只需按照以下步骤操作:

  1. 为 Windows(32 位).

    安装 Ghostscript 9.52
  2. 使用 Nuget 包管理器,将 Ghostscript .NET 添加到我的解决方案中。

  3. 包括 using 代码行,根据需要(主命名空间和 Rasterizer 对于你的情况应该有效,我使用处理器, 另外):

    using Ghostscript.NET;
    using Ghostscript.NET.Processor;
    using Ghostscript.NET.Rasterizer;

我已经在一个新的控制台应用程序项目中检查了您提供的 using 子句(它使用了 Rasterizer class),但没有 return 任何错误,如果我之前执行这些步骤。

请再次尝试重复提到的操作,如果您成功地使用 Ghostscript,请告诉我。