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() 函数的有用文档。
The Console.WriteLine(rasterizer.PageCount);
总是打印0
,无论我加载哪个 pdf 文件。
txtStatus
是 UI 中的多行文本框。txtOpenLocation
是 UI 中的另一个 TextBox,用户不可编辑,其值由OpenFileDialog
.
我使用的是 Visual Studio 2019 社区版。
我觉得值得一提的另一个观察结果是,对于我机器上的每个 pdf 文件,当我尝试使用 Adobe Acrobat DC 或 Foxit Reader 打开任何 pdf 文件时,首先阅读器崩溃,变得“无响应”大约 10 到 15 秒,然后它会打开 pdf 文件。
我昨天也遇到了同样的问题,我从这里下载了9.26版本https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs926/gs926aw32.exe,并且有效!
我认为这是 Ghostscript 9.27 版本的一个错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)