GhostscriptRasterizer对象返回0作为PageCount值 [英] GhostscriptRasterizer Objects Returns 0 as PageCount value

查看:154
本文介绍了GhostscriptRasterizer对象返回0作为PageCount值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

            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;
            }

我在Google上进行了搜索,但没有解决方案,也没有关于rasterizer.Open()函数的有用文档.

I have googled on it, but got no solution, and no helpful documentation about the rasterizer.Open() function.

Console.WriteLine(rasterizer.PageCount);始终打印0,无论我加载哪个pdf文件.

The Console.WriteLine(rasterizer.PageCount); always prints 0, regardless which pdf file I load.

txtStatus是UI中的多行文本框. txtOpenLocation是UI中的另一个TextBox,不能由用户编辑,其值由OpenFileDialog设置.

txtStatusis a multiline TextBox in UI. txtOpenLocation is another TextBox in UI, non-editable by user, and its value is set by a OpenFileDialog.

我正在使用Visual Studio 2019社区版.

I am using Visual Studio 2019 Community Edition.

另一个值得一提的观察结果是-当我尝试使用Adobe Acrobat DC或Foxit Reader打开任何pdf文件时,对于我机器上的每个pdf文件,首先,阅读器崩溃,大约10到15秒钟变得无响应"秒,然后打开pdf文件.

Another observation I feel worth mentioning— for every pdf file on my machine, when I try to open any pdf file with either Adobe Acrobat DC or Foxit Reader, first the reader crashes, becomes 'not responsive' for about 10 to 15 seconds and then it opens the pdf file.

推荐答案

昨天我遇到了同样的问题,我从此处

I had the same problem yesterday, I downloaded version 9.26 from here https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs926/gs926aw32.exe, and works!

我认为这是ghostscript 9.27发布的错误.

I think this is a bug of ghostscript 9.27 release.

这篇关于GhostscriptRasterizer对象返回0作为PageCount值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆