我正在使用Ghostscript.NET在我的项目打印Pdf文件跨网络。本地工作正常,使用Windows 10、64位版本和Ghostscript驱动程序从https://www.ghostscript.com/download/gsdnld.html下载到32位(Ghostscript 9.22 for Windows 32位)。安装32位版本的动机是例外,
Ghostscript.NET.GhostscriptLibraryNotInstalledException:这个托管库在32位进程下运行,需要在这台机器上安装32位Ghostscript本机库!要下载适当的Ghostscript本机库,请访问:http://www.ghostscript.com/download/gsdnld.html
,这发生在我的应用程序日志中,当使用Ghostscript 64位驱动程序时。
我发布应用程序的目标操作系统是Windows 2012 R2。使用相同的Ghostscript驱动程序(用于Windows 32位的Ghostscript 9.22 ),打印命令循环无限期,而不响应我的应用程序。
为此,我禁用了防火墙和防病毒,以消除它们是循环原因的可能性。
我的应用程序从磁盘读取pdf文件,并使用Ghostscript将其发送到网络打印机。为了模拟过程,我使用TeamViewer远程连接到客户端机器。因此,我从这台机器上调用一个REST服务,它将文件保存到磁盘,并使用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。
有人能帮我吗?
发布于 2018-02-09 00:53:17
似乎不允许Asp直接以打印机的形式访问COM设备,而无需使用模拟。通过使用第三方库和连接到内部网用户级别较高的计算机的本地打印机作为IIS用户,系统打印该文件。最好的答案(我认为,在我需要的时候,源代码实现是清晰和可重用的,无需“重新处理”)是开发一个Windows服务程序(安装为管理用户,可以访问COM设备),它监视目录并使用Adobe的另一个程序将内容发送到打印机。我的真实场景的目标打印机是IP打印机,而不是本地打印机。
https://stackoverflow.com/questions/47942416
复制相似问题