除非用户登录到打印计算机,否则PrintDocument.Print的速度很慢 [英] PrintDocument.Print is slow unless user is logged in to the printing computer

查看:349
本文介绍了除非用户登录到打印计算机,否则PrintDocument.Print的速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序托管在服务器'A'(SA)上,一个Web服务用于打印托管在服务器'B'(SB)上. SA创建并打印需要打印的图像,然后将其发送到SB.这样做时,打印速度很慢,大约需要15秒.但是,如果我以用户身份从SA托管的应用程序的webconfig中使用远程桌面登录SB,则它将在不到两秒钟的时间内打印出来.当我登录时,似乎SB正在启动某些东西,这使它可以更快地打印.知道这可能是什么,是否有办法即使我没有登录也能使打印速度更快?

I have a web application hosted on server 'A' (SA) and a web service for printing hosted on server 'B' (SB). SA creates and image that needs printing and sends it to SB. When doing this, printing is fairly slow, around fifteen seconds. However, if I log into SB using remote desktop as the user from the webconfig of the app hosted on SA, then it will print in less than two seconds. It seems as if SB is starting something up when I log into it that is making it print faster. Any idea what this could be and if there's a way that I could keep this printing fast even if I'm not logged in?

编辑:正在打印的图像大小约为20 KB.

Size of the image being printed is about 20 KB.

这是SB上托管的服务的代码:

Here's the code from of the service that is hosted on SB:

public void PrintImage(Stream printImage, string printServer, string printer)
    {
        string printerName = String.Format(@"\\{0}\{1}", printServer, printer);

        Image image = Image.FromStream(printImage);

        PrintDocument printDocument = new PrintDocument();
        PrinterSettings settings = new PrinterSettings();
        settings.PrinterName = printerName;
        printDocument.PrinterSettings = settings;

        printDocument.PrintPage += (s, e) =>
        {
            e.Graphics.DrawImage(image, 0, 0);
        };

        printDocument.Print();
    }

感谢您抽出时间来阅读此内容:)

Thanks for taking time to read through this :)

推荐答案

我们发现,如果在SB上创建打印机映射,则无需远程桌面连接即可执行相同的速度.

We found that if we created a printer mapping on SB, it would execute just as fast without a remote desktop connection.

这篇关于除非用户登录到打印计算机,否则PrintDocument.Print的速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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