有没有办法在不安装Ghostscript的情况下引用其DLL文件?

4

我正在使用Magick.NET将图像(.PS 格式转换为 .PNG),Magick.NET内部使用Ghostscript来转换 .ps 文件。是否有一种方法可以添加对Ghostscript DLL的引用而不安装它。 PS:我正在使用ASP.NET MVC4

1个回答

6

可以在不安装Ghostscript的情况下使用它。您应该先在自己的计算机上下载并安装Ghostscript。如果您想要使用Magick.NET的x64版本,则应安装Ghostscript的x64版本。您需要安装它,因为您需要将文件gsdll64.dll或gsdll32.dll复制到您的应用程序中。我没有测试过这一点,所以在它起作用之前,您可能需要将dll复制到bin目录中。您可以先尝试将其放在bin目录外。

在应用程序中使用Magick.NET之前,请确保进行以下调用:

MagickNET.SetGhostscriptDirectory(@"c:\directory\where\you\put\the\dll\of\ghostscript");

无论安装在哪里,我都需要bin文件夹。 - Nate-
2
string binDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); int i = binDir.IndexOf(':'); binDir = binDir.Substring(i + 2); MagickNET.SetGhostscriptDirectory(binDir);string binDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); int i = binDir.IndexOf(':'); binDir = binDir.Substring(i + 2); MagickNET.SetGhostscriptDirectory(binDir); - Nate-
可能有更简洁的方法来完成这个任务。——很抱歉我无法在评论中更好地格式化代码。 - Nate-
2
谢谢, 当使用 Ghostscript.net dll 时怎么办(也需要安装 gs)? 我尝试将dll复制到bin文件夹中,但没有结果,需要进行安装。 - Emin Hasanov
我认为你应该使用以下代码告诉Magick.NET文件的位置。 有关详细信息,请访问此处: https://github.com/dlemstra/Magick.NET/tree/master/docs - malik masis

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接