txtStatus.Text = "";
if (!File.Exists(txtOpenLocation.Text))
{
txtStatus.Text = "File Not Found";
return;
}
txtStatus.Text = "File Found";
const string DLL_32BITS = "gsdll32.dll";
const string DLL_64BITS = "gsdll64.dll";
//select DLL based on arch
string NomeGhostscriptDLL;
if (Environment.Is64BitProcess)
{
NomeGhostscriptDLL = DLL_64BITS;
}
else
{
NomeGhostscriptDLL = DLL_32BITS;
}
GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(NomeGhostscriptDLL);
var rasterizer = new GhostscriptRasterizer();
try
{
rasterizer.Open(txtOpenLocation.Text, gvi, true);
Console.WriteLine(rasterizer.PageCount); //This line always prints 0
} catch(Exception er)
{
txtStatus.AppendText("\r\nUnable to Load the File: "+ er.ToString());
return;
}
我已经在谷歌上搜索了它,但没有解决方案,也没有关于rasterizer.Open()函数的有用文档。无论我加载哪个pdf文件,Console.WriteLine(rasterizer.PageCount)始终打印0。txtStatus是UI中的多行文本框,txtOpenLocation是UI中的另一个文本框,由OpenFileDialog设置其值且用户无法编辑。我正在使用Visual Studio 2019社区版。我感觉值得提及的另一点是,在我的计算机上,对于每个pdf文件,当我尝试使用Adobe Acrobat DC或Foxit Reader打开任何pdf文件时,阅读器首先崩溃,'not responsive'约10至15秒,然后才打开pdf文件。
gsdll32.dll
和gsdll64.dll
是从Ghostscript应用程序的安装目录中收集的。Ghostscript没有抛出任何错误。 - Muhammad Rasel Parvejghostscript.net.1.2.1.nupkg
。然后将其解压以获取Ghostscript.NET.dll。 - Muhammad Rasel Parvej