gpt4 book ai didi

c# - GhostscriptRasterizer 对象返回 0 作为 PageCount 值

转载 作者:太空狗 更新时间:2023-10-30 00:22:43 24 4
gpt4 key购买 nike

            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 文件,当我尝试使用 Adob​​e Acrobat DC 或 Foxit Reader 打开任何 pdf 文件时,首先阅读器崩溃,在大约 10 到 15 分钟内变得“无响应”秒,然后打开 pdf 文件。

最佳答案

我昨天遇到了同样的问题,我从这里下载了9.26版https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs926/gs926aw32.exe ,并且有效!

我认为这是 ghostscript 9.27 版本的一个错误。

关于c# - GhostscriptRasterizer 对象返回 0 作为 PageCount 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56205425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com