繁体   English   中英

Ghostscript.Net在Windows Server 2012 R2中不起作用

[英]Ghostscript.Net doesn't working in Windows Server 2012 R2

我在我的项目中使用Ghostscript.NET在网络上打印Pdf文件。 使用Windows 10版本64位和Ghostscript驱动程序到32位(对于Windows 32位为Ghostscript 9.22),可以从https://www.ghostscript.com/download/gsdnld.html下载,在本地运行良好。 安装32位版本的动机是例外,

Ghostscript.NET.GhostscriptLibraryNotInstalledException:此托管库在32位进程下运行,并且需要在此计算机上安装32位Ghostscript本机库! 要下载适当的Ghostscript本机库,请访问: http : //www.ghostscript.com/download/gsdnld.html

,这在使用Ghostscript 64位驱动程序时出现在我的应用程序日志中。

我发布应用程序的目标操作系统是Windows Server 2012 R2。 使用相同的Ghostscript驱动程序(对于Windows 32位为Ghostscript 9.22),print命令无限期地循环,而对我的应用程序无响应。

为此,我禁用了防火墙和防病毒功能,以消除它们成为循环原因的可能性。

我的应用程序从磁盘读取pdf文件,并使用Ghostscript将其发送到网络打印机。 为了模拟该过程,我使用TeamViewer远程连接到客户端计算机。 因此,我从这台计算机上调用了REST Web服务,该服务将文件保存到磁盘,并使用Ghostscript在网络打印机中打印文档。

try
                {
                    var task = Task.Run(() =>
                    {
                        using (GhostscriptProcessor processor = new GhostscriptProcessor(GhostscriptVersionInfo.GetLastInstalledVersion(), true))
                        {
                            List<string> switches = new List<string>();
                            switches.Add("-empty");
                            switches.Add("-dPrinted");
                            switches.Add("-dBATCH");
                            switches.Add("-dNOPAUSE");
                            switches.Add("-dNOSAFER");
                            switches.Add("-dPDFFitPage");
                            switches.Add("-dNumCopies=" + numCopias);
                            switches.Add("-sDEVICE=mswinpr2");
                            switches.Add("-sOutputFile=%printer%" + "\\\\" + printerIP + "\\" + printerNAME);
                            switches.Add("-f");
                            switches.Add(inputFile);

                            processor.StartProcessing(switches.ToArray(), null);
                        }
                    });

                    if (!task.Wait(TimeSpan.FromSeconds(Int32.Parse(ConfigurationManager.AppSettings["MAX_PRINTER_DELAY"]))))
                    {
                        Log.Info(String.Format("A impressão do arquivo ({0}) ({1}) foi encerrada porque ultrapassou MAX_PRINTER_DELAY = {2}!", inputFile, printerNAME, ConfigurationManager.AppSettings["MAX_PRINTER_DELAY"]));
                    }

                }
                catch (GhostscriptLibraryNotInstalledException e)
                {
                    Log.Info("O GhostScript não está instalado.");
                    Log.Error(e);
                }
                catch (GhostscriptException e)
                {
                    Log.Info("O GhostScript apresentou erro.");
                    Log.Error(e);
                }
                catch (Exception exception)
                {
                    Log.Error(exception);
                }

我正在使用Ghostscript.NET 1.2.1.0版。

有人能帮我吗?

Microsoft Windows安全体系结构似乎不允许Asp Net API在不使用模拟的情况下直接作为打印机访问COM设备。 通过使用第三方库和连接到具有更高Intranet用户级别的计算机(作为IIS用户)的本地打印机,系统打印了文件。 开发Windows服务程序(以Admin用户身份安装并可以访问COM设备)可以得到最佳答案(根据我的观点,源代码实现在我需要的情况下无需使用大量“重构”即可清晰且可重用)。目录,然后使用其他程序作为Adobe Reader将您的内容发送到打印机。 我实际情况的目标打印机是IP打印机,而不是本地打印机。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM